PDA

View Full Version : Script not working in loop


jbrophy
01-10-2006, 11:22 PM
Hey everyone

I am trying to create a batch Render to texture script. This is just the beginning of it, but I am having an odd occurance


TempObjects = selection as array

SelectedObjects = #()

for i = 1 to TempObjects.count do

(

if superclassof TempObjects[i] == geometryclass then append SelectedObjects TempObjects[i]

)

setCommandPanelTaskMode mode:#modify

for i = 1 to selectedObjects.count do

(

select SelectedObjects[i]

addmodifier SelectedObjects[i] (Unwrap_UVW())

SelectedObjects[i].modifiers[#unwrap_uvw].unwrap.setMapChannel 2

SelectedObjects[i].modifiers[#unwrap_uvw].flattenmapnoparams()

maxOps.CollapseNode SelectedObjects[i] off

SelectedObjects[i].bakechannel = 2

SelectedObjects[i].removeallbakeelements()

LM = LightingMap()

AddLightMap = SelectedObjects[i].InodeBakeProperties.addBakeElement LM

SelectedObjects[i].InodeBakeProperties.setparamvalue LM 1 1

SelectedObjects[i].InodeBakeProperties.setparamvalue LM 2 1

SelectedObjects[i].InodeBakeProperties.setparamvalue LM 3 1

)

Select SelectedObjects



Now the part
SelectedObjects[i].modifiers[#unwrap_uvw].flattenmapnoparams()
does not work when in the loop. I don;t get an error, but the object is not autoflattening the UVW. This same call works just fine if I do

$.modifiers[#unwrap_uvw].flattenmapnoparams()

Any suggestions?

Also any suggestions on a better way to go about this would be great. In the end I need to render multiple light maps for multiple objects

So Light set A is on. Render out light maps for all selected objects. Turn off light set A and turn on light set B, render out light maps for all selected objects....etc.

Thanks

Jesse

_stev_
02-01-2006, 05:01 PM
I have had the exact same problem working with modifiers in some of my scripts. I found that adding the line "Max Modify Mode" fixes this.

Stev

jbrophy
02-01-2006, 05:07 PM
Thanks for the reply. I wonder if it could be that simple.

I will give it a go.

CGTalk Moderation
02-01-2006, 05:07 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.