Dummy rollout as filler


#1

Hello,

I use to drag out the Command Panel so that I have two columns.
When I work with modifiers, sometimes the modifier has only one rollout and therefore not movable to the other column so that I can see it in its full height.

My idea is that if one could create a dummy rollout to use as filler, then I would be able to move the other rollout to the other column.

Is it possible to create such dummy rollouts on the current modifier in the modifier stack?


#2

with the sdk you could add an empty rollout to the command panel (I quite often had sticky rollouts when unload/loading dll during the build process) but I think any new modifier rollout panels will always be added to the start shunting the “sticky” panel down the command panel so you need to add a NOTIFY_POST_MODIFIER_ADDED event handler for this. Alternatively you can extend the modifier with an “empty” scripted modifier though if you want this to work with lots of different modifiers that may be quite tiresome to implement and use.


#3

yup, try:


cus = attributes testdef (
	rollout customRoll "Custom Rollout" (
		button website1 "http://remusjuncu.com/" width:150
		button website2 "remusjuncu.com/rappatools" width:150
		on website1 pressed do ( shellLaunch "http://remusjuncu.com/" "" )
		on website2 pressed do ( shellLaunch "http://remusjuncu.com/rappatools/" "" )
	)
)
custAttributes.add (Modpanel.getcurrentObject()) cus


#4

Thanks Rappy!

Great solution. I had found something on ScriptSpot, but that rollout did stick on the main mesh/object, not on the current modifier like yours.

Thanks alot :thumbsup:


#5

How would you remove it?

Also, how would you do if you wanted Max to remember to add a custom rollout on certain modifiers, each time they are created?
For example, I would like to have this custom rollout created each time I add a UVW Unwrap modifier.


#6

A friendly bump to remind of my other questions

  1. How do I remove a custom attribute?

  2. Is it possible to make max remember a custom attribute for a certain modifier, e.g. Edit Poly, each time when this modifier is created?


#7
cus = attributes testdef (
	rollout customRoll "Custom Rollout" (
		[B]button removeMe "remove" width:150[/B]
		button website1 "http://remusjuncu.com/" width:150
		button website2 "remusjuncu.com/rappatools" width:150
		[B]on removeMe pressed do ( custAttributes.delete (Modpanel.getcurrentObject()) 1 )[/B]
		on website1 pressed do ( shellLaunch "http://remusjuncu.com/" "" )
		on website2 pressed do ( shellLaunch "http://remusjuncu.com/rappatools/" "" )
	)
)
custAttributes.add (Modpanel.getcurrentObject()) cus

i think you can do this with a callback… check if (Modpanel.getcurrentObject()).custAttributes[1] is defined if not add the custom rollout…

if classof (Modpanel.getcurrentObject()) == Edit_Poly and (Modpanel.getcurrentObject()).custAttributes[1] == undefined do custAttributes.add (Modpanel.getcurrentObject()) cus

or you could simply create a button for the mods you want to add and do something like

AddMod Edit_Poly
cus = at...

#8

Many thanks!

If I am in the create panel for example, and run the code, it says:

-- Unable to convert: undefined to type: MaxObject

… because it wants me in the Modifier Panel.

Is there a way to avoid this error message, eg allow creation from outside the modifier panel?


#9

Anytime :wink:


(
	if selection.count != 0 then (
		cus = attributes testdef (
			rollout customRoll "Custom Rollout" (
				button removeMe "remove" width:150
				button website1 "http://remusjuncu.com/" width:150
				button website2 "remusjuncu.com/rappatools" width:150
				on removeMe pressed do ( custAttributes.delete (Modpanel.getcurrentObject()) 1 )
				on website1 pressed do ( shellLaunch "http://remusjuncu.com/" "" )
				on website2 pressed do ( shellLaunch "http://remusjuncu.com/rappatools/" "" )
			)
		)
		if modPanel.getCurrentObject() != undefined then (
			custAttributes.add (Modpanel.getcurrentObject()) cus
		) else (
			for o in getCurrentSelection() do ( --		o = selection[1]
				if o.modifiers.count == 0 then ( custAttributes.add o cus ) else (
					custAttributes.add o.modifiers[1] cus -- o.modifiers.count
				)
			)
		)
	)
)

Also works with multiple objects selected…

Note: I have no experience with custAttributes :wip:


#10

Dont worry - you are doing awesome so far :wavey:


#11

Seems like I need more help.

I tried to explore the concept of callbacks.
The first test was to add a custom rollout upon object creation. I failed already, but it works almost :smiley:

cus = attributes testdef (
	rollout customRoll "Custom Rollout" (
		button removeMe "remove" width:150
		button website1 "http://remusjuncu.com/" width:150
		button website2 "remusjuncu.com/rappatools" width:150
		on removeMe pressed do ( custAttributes.delete (Modpanel.getcurrentObject()) 1 )
		on website1 pressed do ( shellLaunch "http://remusjuncu.com/" "" )
		on website2 pressed do ( shellLaunch "http://remusjuncu.com/rappatools/" "" )
	)
)

callbacks.removeScripts id:#addCustomRollout;

fn custAdd = (
	for o in getCurrentSelection() do ( --		o = selection[1]
			if o.modifiers.count == 0 then ( custAttributes.add o cus ) else (
				custAttributes.add o.modifiers[1] cus -- o.modifiers.count
			)
		)
	
)

callbacks.addScript #sceneNodeAdded "custAdd()" id:#addCustomRollout;

Problem so far: When I create an object, it seems like nothing is added to it. If I create another object, a custom rollout is added to the previous one.

Like said, this is just a test but I wonder why it adds the rollout after a second object is made.

If you can help me to modify this script to give me an example of a callback that reacts with a certain modifier creation.


#12

(
	global _customRollout
	callbacks.removeScripts id:#_CustomRollout

	struct _customRollout (
		private
		roll = (
			attributes testdef (
				rollout customRoll "Custom Rollout" (
					button removeMe "remove" width:150
					button website1 "http://remusjuncu.com/" width:150
					button website2 "remusjuncu.com/rappatools" width:150
					on removeMe pressed do ( custAttributes.delete (Modpanel.getcurrentObject()) 1 )
					on website1 pressed do ( shellLaunch "http://remusjuncu.com/" "" )
					on website2 pressed do ( shellLaunch "http://remusjuncu.com/rappatools/" "" )
				)
			)
		),
		public
		fn add = (
			if modPanel.getCurrentObject() != undefined then (
				custAttributes.add (Modpanel.getcurrentObject()) roll
			) else (
				for o in getCurrentSelection() do ( --		o = selection[1]
					if o.modifiers.count == 0 then ( custAttributes.add o roll ) else (
						custAttributes.add o.modifiers[1] roll -- o.modifiers.count
					)
				)
			)
		),
		fn addCallback node = if isvalidNode node and not isProperty node.baseobject "_cusdef" then (
			custAttributes.add node.baseobject roll
		),
		fn addCallbackMod mod = if mod.count == 2 then (
			-- format "super:% , class: %, mod: %
" (superClassOf mod[2]) (classOf mod[2]) mod[2]
			-- will only add to TurboSmooth !
 			if (superClassOf mod[2]) == modifier and classOf mod[2] == TurboSmooth then (
				custAttributes.add mod[2] roll 
 			)
		),
		fn enable = (
			callbacks.removeScripts id:#_CustomRollout
			callbacks.addScript #sceneNodeAdded "_customRollout.addCallback (callbacks.notificationParam())" id:#_CustomRollout
			callbacks.addScript #postModifierAdded "_customRollout.addCallbackMod (callbacks.notificationParam())" id:#_CustomRollout
			format "Callback Enabled !
"
		),
		fn disable = (
			callbacks.removeScripts id:#_CustomRollout
			format "Callback Disabled !
"
		)
	)
	_customRollout = _customRollout()

	-- _customRollout.add()
	_customRollout.enable()
)


#13

Thanks Remus, splendid code!

Now I use it for Uvwmap. Since the modifier has only one rollout, it gets partially hidden. With the custom rollout, it gets forced to the other column in the command panel :thumbsup: