Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

3 REPLIES 3
Reply
Message 1 of 4
bksong
801 Views, 3 Replies

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

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

 

3 REPLIES 3
Message 2 of 4
denisT.MaxDoctor
in reply to: bksong

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...

 

Message 3 of 4
bksong
in reply to: denisT.MaxDoctor

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

 

 

Message 4 of 4
Swordslayer
in reply to: bksong

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report