Find selected modifier index? ("Collapse To" hotkey)

Find selected modifier index? ("Collapse To" hotkey)

bksong
Enthusiast Enthusiast
1,303 Views
3 Replies
Message 1 of 4

Find selected modifier index? ("Collapse To" hotkey)

bksong
Enthusiast
Enthusiast

I'm trying to create a "Collapse To" hotkey on the currently selected modifier, but I'm struggling to find out how to determine the modifier index numbers. 

I guess the bigger question is what's the proper way to search for related commands? Apologies, I'm clueless on maxscript.

jxfJLoR

 

0 Likes
1,304 Views
3 Replies
Replies (3)
Message 2 of 4

denisT.MaxDoctor
Advisor
Advisor

if you are talking about only one object selected at that time, everything is more or less simple and doable. If we have multiple nodes selection, the task becomes more difficult.

 

I can answer on the first case...

 

0 Likes
Message 3 of 4

bksong
Enthusiast
Enthusiast

Oh, yup. Only for 1 selected object.

 

Apologies, I asked this in another thread yesterday and someone posted a macroscript below. The bigger question though is how do users find information on things like obj.modifiers.count?  I googled it and I couldn't find documentation, only old forum posts.

https://forums.autodesk.com/t5/3ds-max-modeling/how-to-assign-a-shortcut-to-the-quot-collapse-to-quo...

 

macroScript CollapseTo
	category:"DragAndDrop"
	toolTip:""

(--Begin Macro

 for obj in selection do
    (
        for i in obj.modifiers.count to 1 by -1 where
            obj.modifiers[i] == modPanel.getCurrentObject() do
            (
                maxops.CollapseNodeTo obj i off
                exit
            )
    )
	
	
)--End Macro

 

 

0 Likes
Message 4 of 4

Swordslayer
Advisor
Advisor

If it's just one object, you can use a function that's made for that:

 

 

macroScript CollapseTo category:"Shortcuts" toolTip:"Collapse To" buttonText:"Collapse To"
(
	if isValidNode $ and $.modifiers.count > 0 do
		maxOps.collapseNodeTo $ (modPanel.getModifierIndex $ (modPanel.getCurrentObject())) off
)

 

 

Node's modifiers property is a collection and all collections have count property, you don't look it up by searching a variable name someone used in code but instead search for concepts. If you download the maxscript reference help file, you can for starterts search for 'common properties' and check to search only in titles, then go from their respective footnote links further on.

0 Likes