[Closed] Detecting EditPolyMod and Editable Poly Object in script
Hi!
I am very very new at this MaxScript thing, but I though I should read a little about it since I was in need for a custom script.
What I wanted my script to do was using “Edge Ring” and open up “Connect Edge Dialog PopUp”, in one hotkey.
I tried it out a little, and I got most of it to work, but I found out it needed different functions depending on the object, whether it was an Editable Poly object, or a Edit Poly modifier. I wrote 2 scripts, one working perfect for each one, so I though I could just script a function in to detect the what kind of an object it was, and execute function depending on that.
I tried a If/then/else thing, but I could get it to work, 99% likely because this is my first try at scripting and I have almost no clue.
So is there anyone who can quickly give me the answer? I would greatly appreciate it.
x = "Editable Poly"
(
If (modPanel.getCurrentObject() == "x") Then
(
$.EditablePoly.SelectEdgeRing ()
actionMan.executeAction 369982487 "40062" -- Command for opening up ConnectEdge Dialog
) --condition not valid
else
(
$.modifiers[#Edit_Poly].ButtonOp #SelectEdgeRing
actionMan.executeAction 1250838234 "40062" -- Command for opening up ConnectEdge Dialog
)
) --ScriptEnd
When I wrote “modPanel.GetCurrentObject()” in the MaxScript Listener I got either “Edit_Poly:Edit Poly” or “Editable Poly”, so I thought that was enough to use the if/then/else function, but I couldn’t get it to work. As it is written now, it only works on Edit_Poly modifier objects, because whatever I try the answer is always “false” in the If function.
Can somebody help?
Thank you
- Strandli
To see class of an object, use classOf method.
(
if(classof (modPanel.getCurrentObject()) == Editable_Poly) Then
(
$.EditablePoly.SelectEdgeRing ()
actionMan.executeAction 369982487 "40062" -- Command for opening up ConnectEdge Dialog
) --condition not valid
else
(
if(classof (modPanel.getCurrentObject()) == Edit_Poly) then
(
$.modifiers[#Edit_Poly].ButtonOp #SelectEdgeRing
actionMan.executeAction 1250838234 "40062" -- Command for opening up ConnectEdge Dialog
)
)
) --ScriptEnd
Thank you so much for your help, the script works now!
Although I’ve been encountering a weird problem (or user error most likely).
When I add a MacroScript name it only returns numbers in the MaxScript listener.
The script works flawlessly when the “macroScript ScriptName” line is gone, but I have to have a name and a category so I can assign this to a hotkey.
MacroScript EdgeRingConnect category:"CustomScripts" tooltip:"Connects a ring of edges"
(
(
if(classof (modPanel.getCurrentObject()) == Editable_Poly) Then
(
$.EditablePoly.SelectEdgeRing ()
actionMan.executeAction 369982487 "40062" -- Command for opening up ConnectEdge Dialog
) --condition not valid
else
(
if(classof (modPanel.getCurrentObject()) == Edit_Poly) then
(
$.modifiers[#Edit_Poly].ButtonOp #SelectEdgeRing
actionMan.executeAction 1250838234 "40062" -- Command for opening up ConnectEdge Dialog
)
)
) --ScriptEnd
)
When I evaluate that script the MaxScript Listener only says “27356”, this disappears as soon as I remove the first macroscript line.
Any idea to what I’m doing wrong?
Edit: Actually the scripts seems to work, it didn’t give me the number error when I ran it as a hotkey after I saved it. I am confused.
But I think it works, so if someone doesn’t have any additional wisdom to share, I think my problems are gone for now.