Notifications
Clear all

[Closed] store a node to control an object later?

 JHN

Because it takes an index or a name in the modifier array
Why not directly manipulate the boxMod itself the parameter holds an instance of the modifier so manipulate directly.

boxMod.enabled = state

-Johan

well i tried b4, but wont work aswell. says “unknown property “enabled” in undefined for some reason

 JHN

Then you are not storing the modifier in the boxMod property properly.

-Johan

yeah, i realized that, but i did what you said, could you point what i am doing wrong?

 JHN

 -- Create a test modifier
 b = bend angle:45
 
 -- Add it before the attribute holder, so it gets index 2
 addModifier $ b before:1
 
 -- Get the attrib def
 ca = CustAttributes.getDef $.modifiers[1].controls
 
 -- redefine it
 cc = attributes controls
 redefine:ca
 (
 	parameters params rollout:roll
 	(
 		boxState type:#boolean default:false animatable:false ui:boxBut
 		boxNode type:#maxObject
 		boxMod type:#maxObject
 	)
 	rollout roll "Options"
 	(
 		checkbutton boxBut "Hide/Show"
 		on boxBut changed state do
 		(
 			max create mode -- circumvent the ui update problem
 			boxMod.enabled = not state
 			max modify mode
 			
 		)
 	)
 )
 -- assign the bend modifier to the boxmod parameter
 $.modifiers[1].controls.boxMod = $.modifiers[2]
 

-Johan

great
heres what i was doing wrong:
instead of

$.modifiers[1].controls.boxMod = $Box001.modifiers[1]

i was typing only

boxMod = $Box001.modifiers[1]

now it works
cheers

also, if you’re not sick of chewing maxscript for me: (if you are, thats ok, by now i would aswell)

for my case, this works:

checkbutton boxBut "Hide/Show"
		on boxBut changed state do
		(
			case state of
			(
				true: ( boxMod.enabled = true; boxMod.enabledInViews = true; boxMod.enabledInRenders = false)
				false: ( boxMod.enabled = false; boxMod.enabledInViews = false; boxMod.enabledInRenders = false)
			)
		)

but i have no clue how to make the 4 options switch work with a checkbutton, wich afaik, its only options were true/false.

checkbutton boxBut "Hide/Show"
		on boxBut changed state do
		(
			case state of
			(
				1 : for boxMod in theMods do ( boxMod.enabled = true; boxMod.enabledInViews = true; boxMod.enabledInRenders = true)
				2 : for boxMod in theMods do ( boxMod.enabled = true; boxMod.enabledInViews = false; boxMod.enabledInRenders = true)
				3 : for boxMod in theMods do ( boxMod.enabled = true; boxMod.enabledInViews = true; boxMod.enabledInRenders = false)
				4 : for boxMod in theMods do ( boxMod.enabled = false; boxMod.enabledInViews = true; boxMod.enabledInRenders = true)
			)
		)

idk if thats the right syntax, and/or what to put where is “theMods” since i already switched the “m” for my box modifier.

nonetheless, helped more than enough already. glad you did, thank you one more time
now back to maxscript documentation

 JHN

As you guessed, the state is a boolean on or off, the case in my example needs an integer 1…4.
So either drop the checkbox and go for something like radiobuttons (what I did) and hook those to an integer parameter or just stick with on/off if that’s enough for your needs.

-Johan

Page 2 / 2