strange error using some sweep parameters


#1

Hi
try this code taken from the reference:

theMod = sweep()

theShape = Circle radius:100

addModifier theShape theMod

classof (theMod[4].object)
theMod[4].width = 50 

it works fine, but try to modify it in this way:


(
theMod = sweep()
 
 theShape = Circle radius:100
 
 addModifier theShape theMod
 
 classof (theMod[4].object)
 theMod[4].width = 50 
)
 

It doesn’t work… the error is this:
– Error occurred in anonymous codeblock; filename: C:\Documents and Settings…; position: 121
– Frame:
– Unknown property: “object” in undefined

I can’t find the problem… do you have any idea?

thanks

P.S. sorry for my english…


#2

theMod[4] does not exist until the sweep modifier has been initialized on the object you apply it to.

When you run the code without the parentheses, maxscript executes each line by itself. After the ‘addModifier’ line, 3ds max refreshes, causing the modifier to initialize, making theMod[4] valid.

When you run the code with the parentheses, maxscript tries to execute the code as a whole block, and 3ds Max does not refresh until after the the closing parenthesis. But your code needs the sweep modifier to be initialized before that, or else it will fail; giving you the error you pasted.

One way (there might be a better way) to make sure the sweep modifier is initialized on the object(s) it is applied to is adding ‘redrawviews()’ after the ‘addModifier’ call.


#3

thank you, it works!


#4

Another trick to get around this problem is to use the classOf function on the object, which causes the object’s stack to refresh:

(
	theMod = sweep()
	theShape = Circle radius:100

	addModifier theShape theMod
	[b]classOf theShape[/b]
	theMod[4].width = 50 
)

Cheers,
Martijn


#5

nice trick!
It’s faster for heavy scenes.
Thanks to everybody!

cheers


#6

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.