Need some help with sweep modifier properties

Hi, I'm a noob in the MAXscript world, I'm tring to write a scipt that allows me to read some coordinates form a text file whith which I want to draw "fibers" using splines and then using a sweep modifier with a cylinder section, all these thing I could do easy, but when I try to change the radius of the cylinder_section, there is nothing I can do to accomplish it. I've tried:

addmodifier $fiber1 (sweep()) -- fiber1 is a spline
$fiber1.sweep.currentbuiltinshape = 4 -- 4 refers to a cylinder section $fiber1.sweep.cylinder_section.radius = 10 --

But it returns unknown property "cylinder_section" in sweep:Sweep and also tried

mn = sweep()
addmodifier $fiber* mn
mn.currentbuiltinshape = 4
mn[4].radius =10

it doesn't work either, returns unkown property "radius" in undefined.

The weird thing is that when I input this code in the listener it works, but when I run the script it doesn't work.

thanks in advance

AttachmentSize
coordinates.txt6.58 MB
import_fortran.ms3 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
LittleLordPotala's picture

Another idea...

I don't have this error message on Max 2012 64bits sp2.

I'm not sure but I think this error can sometimes occur if Maxscript attempts to call a property that is "not yet" loaded. In that particular case, Maxscript has to wait for this property.

An easy way to verify it, is to execute the script step by step in the Maxscript listener.

Another question would be : when you apply manually the sweep modifier with a circle shape, can you access the radius property in Maxscript listener ?
(For this, just select your spline with the sweep mod and type in the command : $.modifiers["sweep"][4].radius)
If you cannot access this property, you have a bug and the solution is probably to reinstall Max...
If it works, then you can try the following code :

  1. obj = $
  2. sweepMod = sweep()
  3. addmodifier obj sweepMod
  4. when parameters obj change id:#paramChange handleAt:#redrawViews do
  5. (
  6. sweepMod[4].radius = 5
  7. deleteAllChangeHandlers id:#paramChange
  8. )
  9. sweepMod.currentbuiltinshape = 4
  10. redrawViews()

If it still doesn't work, you can also use callback events (see the Maxscript documentation for "callbacks.addScript").

Hope it helps. Best regards.

LittleLordPotala's picture

The solution :

--To create instanced modifiers :
obj = $fiber* --and if you select objects -> obj = $selection
addmodifier obj (sweep())
obj[1].modifiers["sweep"].currentbuiltinshape = 4
obj[1].modifiers["sweep"][4].radius = 3

--And an option to make it unique, only if needed :
mdf = for i in obj collect i.modifiers["sweep"]
InstanceMgr.MakeModifiersUnique obj mdf #individual

/*
But if you only need to create cylinders with spline,
you don't need a script, you can use in the modify panel
editable spline -> rendering -> "enable in renderer" + "enable in viewport"
and change the radial parameters as you like.
And each new spline you create will automatically have this parameters.*/
--Of course, you can change the spline parameters with a script :
obj = $fiber*
for i in obj do
(
obj.render_renderable = true
obj.render_displayRenderMesh = true
obj.render_thickness = 5
obj.render_sides = 12
)

wassimj's picture

Still does not work

I am facing the same problem as the original poster. I followed the example in the AutoDesk Maxscript tutorial. I have the following script (mySplineShape is a spline shape I have pre-created):

sweepMod = sweep()
addmodifier mySplineShape sweepMod
sweepMod.currentbuiltinshape = 4
sweepMod[4].radius = 5

It applies the sweep modifier with a circle, but then I immediately get the dialog box:

-- Unknown property: "radius" in undefined

And indeed sweepMod[4] is undefined. While sweepMod[1] sweepMod[2] and sweepMod[3] are defined.

I tried the script solution above as such:

addmodifier mySplineShape (sweep())
mySplineShape.modifiers["sweep"].currentbuiltinshape = 4
mySplineShape.modifiers["sweep"][4].radius = 5

but I still get the exact same error.

wassimj's picture

Finally found the solution!

I finally found the solution on another forum: http://forums.cgsociety.org/archive/index.php?t-654208.html

Basically, you need to update the stack. You could do this by inserting either a redrawViews or simply asking for the classOf aShape.

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.