PDA

View Full Version : strange error using some sweep parameters


coren
07-17-2008, 09:14 PM
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...

ZeBoxx2
07-17-2008, 10:48 PM
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.

coren
07-19-2008, 11:27 AM
thank you, it works!

magicm
07-19-2008, 03:15 PM
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
classOf theShape
theMod[4].width = 50
)
Cheers,
Martijn

coren
07-21-2008, 08:28 AM
nice trick!
It's faster for heavy scenes.
Thanks to everybody!

cheers

CGTalk Moderation
07-21-2008, 08:28 AM
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.