PDA

View Full Version : Desperately need help


GreatShatnersGhost
03-13-2010, 09:28 PM
Please guys can anyone help me out, I am trying to modify UV`s using maxscript but I keep getting and unknow system exception everytim this line is executed:

obj.modifiers[#myUnwrap].unwrap.rotateSelectedVerticesCenter (degToRad -45.0)

for obj in importedFiles do
(
--find roof
RoofColor = point4 0.5 0.5 0.8 1
diff = obj.material.diffuse as point4
print diff
if diff == RoofColor do
(
RoofUV = (uvwmap())
RoofUV.name = "myUV1"
addModifier obj RoofUV

RoofUnwrap = (uvwunwrap())
RoofUnwrap.name = "myUnwrap"
addModifier obj RoofUnwrap

obj.modifiers[#myUnwrap].unwrap.selectVertices #{1..getNumVerts obj}
obj.modifiers[#myUnwrap].unwrap.rotateSelectedVerticesCenter (degToRad -45.0)
)
)

I gotta have this working by moday, if anyone has a clue as to what going wrong i would really appreciate it. Thanks in advance.

denisT
03-13-2010, 09:52 PM
Please guys can anyone help me out, I am trying to modify UV`s using maxscript but I keep getting and unknow system exception everytim this line is executed:

obj.modifiers[#myUnwrap].unwrap.rotateSelectedVerticesCenter (degToRad -45.0)

for obj in importedFiles do
(
--find roof
RoofColor = point4 0.5 0.5 0.8 1
diff = obj.material.diffuse as point4
print diff
if diff == RoofColor do
(
RoofUV = (uvwmap())
RoofUV.name = "myUV1"
addModifier obj RoofUV

RoofUnwrap = (uvwunwrap())
RoofUnwrap.name = "myUnwrap"
addModifier obj RoofUnwrap

obj.modifiers[#myUnwrap].unwrap.selectVertices #{1..getNumVerts obj}
obj.modifiers[#myUnwrap].unwrap.rotateSelectedVerticesCenter (degToRad -45.0)
)
)

I gotta have this working by moday, if anyone has a clue as to what going wrong i would really appreciate it. Thanks in advance.

fist of all there is a couple comments:
1. According to your code all objects in imported files array have to be editable meshes (because you use getnumverts function)
2. All objects have to have Standard material applied (you check obj.mat.diffuse value)

Second:
1. To make UVW_Unwrap modifier work you have to open UVW Editor (RoofUnwrap.Edit())
2. Number of Geo Vertices has to be the same as the number of Map Vertices (or you have to use RoofUnwrap.NumberVertices() instead of getnumverts to select all vertices)

So, the code should to be:

for obj in importedFiles do
(
--find roof
RoofColor = point4 0.5 0.5 0.8 1
diff = obj.material.diffuse as point4
print diff
if diff == RoofColor do
(
RoofUV = uvwmap name:"myUV1"
addModifier obj RoofUV

RoofUnwrap = uvwunwrap name:"myUnwrap"
addModifier obj RoofUnwrap

RoofUnwrap.Edit()
RoofUnwrap.selectVertices #{1..RoofUnwrap.NumberVertices()}
RoofUnwrap.rotateSelectedVerticesCenter (degToRad -45.0)
)
)

GreatShatnersGhost
03-13-2010, 10:07 PM
I appreciate your quick response, the code looks cleaner now but i still get the same problem, ill post up the whole thing, maybe you could take another look.

Thanks for your help, Im usually in maya so this maxscript is quite tough to pick up in a day.

macroScript CreateProxies category:"HowTo"
(
print "Working2..."

local folder = "K:\\3dWork\\JonathanHills\\TheGarden\\assets\\proxy tests\\buildings02\\"
files = getFiles (folder +"*.obj")

print files.count

Mat0 = StandardMaterial()
Mat0.name = "Material0"
Mat1 = StandardMaterial()
Mat1.name = "Material1"
Mat2= StandardMaterial()
Mat2.name = "Material2"
Mat3 = StandardMaterial()
Mat3.name = "Material3"
Mat4 = StandardMaterial()
Mat4.name = "Material4"
Mat5 = StandardMaterial()
Mat5.name = "Material5"
Mat6 = StandardMaterial()
Mat6.name = "Material6"
Mat7 = StandardMaterial()
Mat7.name = "Material7"
Mat8 = StandardMaterial()
Mat8.name = "Material8"
Mat9 = StandardMaterial()
Mat9.name = "Material9"
Mat10 = StandardMaterial()
Mat10.name = "Material10"
Mat11 = StandardMaterial()
Mat11.name = "Material11"

for file in files do
(
macros.run "Medit Tools" "clear_medit_slots"

importFile file #noPrompt
importedFiles = selection
bImported = importedFiles
clearSelection

-- fix uv maps
for obj in importedFiles do
(
--find roof
RoofColor = point4 0.5 0.5 0.8 1
diff = obj.material.diffuse as point4
print diff
if diff == RoofColor do
(
RoofUV = uvwmap name:"myUV1"
addModifier obj RoofUV

RoofUnwrap = uvwunwrap name:"myUnwrap"
addModifier obj RoofUnwrap

RoofUnwrap.Edit()
RoofUnwrap.selectVertices #{1..RoofUnwrap.NumberVertices()}
RoofUnwrap.rotateSelectedVerticesCenter (degToRad -45.0)
)
)


-- reapply all textures so they only use the basic set
i=0;
for obj in importedFiles do
(
i=i+1
obj.name ="ImportedBuilding" + i as string
objmat = obj.material as string

if findstring objmat "mat0_" != undefined do
(
Mat0.Diffuse = obj.material.Diffuse
obj.material = Mat0
)
if findstring objmat "mat1_" != undefined do
(
Mat1.Diffuse = obj.material.Diffuse
obj.material = Mat1
)
if findstring objmat "mat2_" != undefined do
(
Mat2.Diffuse = obj.material.Diffuse
obj.material = Mat2
)
if findstring objmat "mat3_" != undefined do
(
Mat3.Diffuse = obj.material.Diffuse
obj.material = Mat3
)
if findstring objmat "mat4_" != undefined do
(
Mat4.Diffuse = obj.material.Diffuse
obj.material = Mat4
)
if findstring objmat "mat5_" != undefined do
(
Mat5.Diffuse = obj.material.Diffuse
obj.material = Mat5
)
if findstring objmat "mat6_" != undefined do
(
Mat6.Diffuse = obj.material.Diffuse
obj.material = Mat6
)
if findstring objmat "mat7_" != undefined do
(
Mat7.Diffuse = obj.material.Diffuse
obj.material = Mat7
)
if findstring objmat "mat8_" != undefined do
(
Mat8.Diffuse = obj.material.Diffuse
obj.material = Mat8
)
if findstring objmat "mat9_" != undefined do
(
Mat9.Diffuse = obj.material.Diffuse
obj.material = Mat9
)
if findstring objmat "mat10_" != undefined do
(
Mat10.Diffuse = obj.material.Diffuse
obj.material = Mat10
)
if findstring objmat "mat11_" != undefined do
(
Mat11.Diffuse = obj.material.Diffuse
obj.material = Mat11
)
)

-- Merge the mesh together to create the multi/sub object material


for i=2 to bImported.count do
(
--meshop.attach bImported[1] bImported[2] attachMat:#IDToMat condenseMat:false
)
--modPanel.addModToSelection (smooth ()) ui:off
fileloc = file + ".vrmesh"
--vrayMeshExport meshFile:fileloc autoCreateProxies:true

)
meditMaterials[1] = Mat1
meditMaterials[2] = Mat2
meditMaterials[3] = Mat3
meditMaterials[4] = Mat4
meditMaterials[5] = Mat5
meditMaterials[6] = Mat6
meditMaterials[7] = Mat7
meditMaterials[8] = Mat8
meditMaterials[9] = Mat9
meditMaterials[10] = Mat10
meditMaterials[11] = Mat11
meditMaterials[12] = Mat0

)

GreatShatnersGhost
03-14-2010, 02:15 PM
well i fixed it, its just that I dont really know how, heres what I ended up with

for obj in importedFiles do
(
--find roof
RoofColor = point4 0.5 0.5 0.8 1
diff = obj.material.diffuse as point4
if diff == RoofColor do
(
select obj
modpanel.addmodtoselection (global uvw = uvwmap()) ui:on
modpanel.addmodtoselection (global uvwun = UVWUnwrap()) ui:on

uvwun.Edit()
uvwun.selectVertices #{1..uvwun.NumberVertices()}
uvwun.rotateSelectedVerticesCenter (degToRad -45.0)
)
)

CGTalk Moderation
03-14-2010, 02:15 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.