Notifications
Clear all

[Closed] Problem Applying Sweep Modifier from inside Rollout

Do I need to update the sweep modifier somehow after I apply it from a rollout?

I am trying to apply a sweep modifier and set the properties of it via a rollout, but am running into an issue where after I assign the .CustomBuildInSection when the code is in a rollout it remains undefined.

When you run the code below and the message boxes display, it shows the custom section as undefined (the array in the first messagebox has no 4th index) but if you run the code outside of the rollout (just the btn2 pressed items on their own) then it works fine and the messagebox shows the 4th item in the array and the second one is not all undefined.

What should I be doing here to get it to work in the rollout?

if testDialog != undefined then destroyDialog testDialog
rollout testDialog "Untitled" width:162 height:300
(
	button btn2 "Button" pos:[50,72] width:54 height:56
	on btn2 pressed  do
	(
		sp = SplineShape pos:[0,0,0]
		addNewSpline sp
		addKnot sp 1 #smooth #curve [0,0,0]
		addKnot sp 1 #smooth #curve [10,10,10]
		updateShape sp
		theMod = sweep()	
		addModifier sp theMod
		theMod.CurrentBuiltInShape = 4
		messagebox (getSubAnimNames theMod as string)
		messagebox (theMod.shapes as string)
	)
)
createDialog testDialog
3 Replies

I had the same issue, take a look here, it should work.

cheers

Well, you’re right for your code, but some reason it’s not working on mine. I’m creating a spline by adding knots instead of just using a circle, I don’t see how that changes things though. Here’s mine with your added classOf and redrawviews() tricks, but it still errors.

Interestingly, adding those do change the results slightly, the second messagebox shows an ‘angle’ in the second array, but theMod[4] still doesn’t exist yet. Max 64bit 2010. Any ideas?

(
		sp = SplineShape pos:[0,0,0]
		addNewSpline sp
		addKnot sp 1 #smooth #curve [0,0,0]
		addKnot sp 1 #smooth #curve [10,10,10]
		updateShape sp
		theMod = sweep()	
		addModifier sp theMod
		classOf sp
		redrawviews()
		theMod.CurrentBuiltInShape = 4
		messagebox (getSubAnimNames theMod as string)
		messagebox (theMod.shapes as string)
	)

Found it, since I am changing theMod.CurrentBuiltInShape I need to update the object/modifier after changing the shape as well (or instead of) so this works for what I’m trying to do.

Thank for pointing me in the right direction, I appreciate it!

	(
		theMod = sweep()
		sp = SplineShape pos:[0,0,0]
		addNewSpline sp
		addKnot sp 1 #smooth #curve [0,0,0]
		addKnot sp 1 #smooth #curve [10,10,10]
		updateShape sp
		addModifier sp theMod
		theMod.CurrentBuiltInShape = 4
		classOf sp
		messagebox (getSubAnimNames theMod as string)
		messagebox (theMod.shapes as string)
	)