Home Technical Talk

[MAXScript] Hiding faces on many objects under an Epoly mod

polycounter
Offline / Send Message
Justo polycounter
Been all morning trying to figure this one out. I have these lines to let me hide faces/objects:

	if Ribbon_Modeling.isFaceMode() then
		macros.run "Editable Polygon Object" "EPoly_Hide"
	else
		actionMan.executeAction 0 "223"  -- Tools: Hide Selection

And it works great, except for when i want to hide faces from multiple objects being grouped under an Edit Poly modifier. The error simply displays "Operation failed"; no explanation in the Maxscript Listener, nothing. 

Any ideas as to what's wrong? Does the macros.run function not work when called in an instanced modifier? 

Replies

  • monster
    Options
    Offline / Send Message
    monster polycounter
    If you change macros.run to macros.edit then you can read the code of the macro. In this case looks like the Filters struct the macro uses doesn't support multiple objects selected. If you use macros from the "Ribbon - Modeling" it'll support both Edit Poly and Editable Poly.

    	if Ribbon_Modeling.isFaceMode() then
    		macros.run "Ribbon - Modeling" "HideSelected"
    	else
    		actionMan.executeAction 0 "223"  -- Tools: Hide Selection

  • Justo
    Options
    Offline / Send Message
    Justo polycounter
    @monster
    Thank you yet again Juan. Do you know how can I see in the MaxScript Help docs all functions under Ribbon Modeling? I actually spent a good while searching there, because since our last talk yesterday now I knew to look there before giving up, but no keywords I used gave me anything useful. At most, the only thing I ever found there was the Ribbon interface controls...

    I always use the Scripting & Customization filter when looking for Maxscript stuff. Am i doing it wrong?

  • PolyHertz
    Options
    Offline / Send Message
    PolyHertz polycount lvl 666
    Not entirely clear what you're trying to do with the ribbon, but this is what I use to hide faces on Edit_Poly modifiers:

    setCommandPanelTaskMode #modify<br>modClass = classOf (modPanel.getCurrentObject())<br>modFullName = modpanel.getCurrentObject()<br><br>if (modClass == Edit_Poly) do (<br>    Try	(<br>        modFullName.ButtonOp #HideVertex<br>        modFullName.ButtonOp #HideFace<br>    )Catch()<br>)

    You can hide faces on Editable Poly via:

    Try($.ButtonOp #HideSelection)Catch()
  • monster
    Options
    Offline / Send Message
    monster polycounter
    @PolyHertz
    Justo and I had PMs where I suggested using ribbon functions since those already check for EPoly vs EditablePoly states.

    @Justo
    A better way than what I suggested earlier (because ribbon handles vert mode as well) is to not check for face mode, just check if your are in object mode.
    (
    	if subObjectLevel == 0 or subObjectLevel == undefined then
    		hide selection
    	else
    		macros.run "Ribbon - Modeling" "HideSelected"
    )

    As for as help docs, this stuff isn't documented. Like I suggested earlier macros.edit will show the code used in any macro. And you can open the PolyBoost.ms (or something like that) in the 3ds Max install folder. Some commands like this will output their functions
    //This command will list the polyboost functions
    show polyboost
    //This command will list some ribbon stuff
    Ribbon_Modeling
    //This command can help you find stuff, just change the search string
    apropos "search string"


  • Justo
    Options
    Offline / Send Message
    Justo polycounter
    @PolyHertz Yes, like Juan said, I wanted to hide stuff in both modifiers with one script.

    I'm really curious though, since I've never ran across the need to do so making game art, at what times have you needed to hide verts? I can't think of a situation in which that'd be truly necessary, unless I was editing some really highly decimated mesh and I wanted to hide vertices as I edit the shape with soft selection (that would still be a bit uncomfortable though, I think). 
  • PolyHertz
    Options
    Offline / Send Message
    PolyHertz polycount lvl 666
    If you're talking about:

    modFullName.ButtonOp #HideVertex

    iirc I put that there to fix some sort of bug in an older version of Max I was using at the time. Probably no reason to have it there in modern versions of Max, but no real reason to remove it either. I don't ever really hide just verts.

    Here's my full hide/unhide script, which does work for single and multiple Edit_Poly modifiers, and well as Editable_Poly:

    macroScript g_hide<br>category: "GregsScripts"<br>buttonText: "Hide"<br>(<br>	erStat = showEndResult<br>	showEndResult = false<br>	setCommandPanelTaskMode #modify<br>	modClass = classOf (modPanel.getCurrentObject())<br>	modFullName = modpanel.getCurrentObject()<br><br>	If (($ != undefined) and (subobjectLevel != 0)) do (<br>		if (modClass == Editable_Poly) do (Try($.ButtonOp #HideSelection)Catch())<br>		if (modClass == Edit_Poly) do (<br>			Try	(<br>				modFullName.ButtonOp #HideVertex<br>				modFullName.ButtonOp #HideFace<br>				)Catch()<br>		)<br>	)<br>	If (($ != undefined) and (subobjectLevel == 0)) do (max hide selection)<br><br>	showEndResult = erStat;		<br>)<br>	<br>	<br>macroScript g_unHide<br>category: "GregsScripts"<br>buttonText: "Unhide"<br>(<br>	erStat = showEndResult<br>	showEndResult = false<br>	setCommandPanelTaskMode #modify<br>	modClass = classOf (modPanel.getCurrentObject())<br>	modFullName = modpanel.getCurrentObject()<br>	<br>	objlvl = subobjectLevel<br>	If (objlvl != 0) do (<br>		if (modClass == Editable_Poly) do (<br>			$.unhideAll #Vertex<br>			$.unhideAll #Face<br>		)<br>		if (modClass == Edit_Poly) do (<br>			modFullName.ButtonOp #UnhideAllFace<br>			modFullName.ButtonOp #UnhideAllVertex<br>		)<br>	)<br>	If (objlvl == 0) do (max unhide all)<br>	<br>	showEndResult = erStat;<br>)<br>

    Unless you're really concerned about how compact your code is, I don't see any reason to use a different method then what I posted above.
  • Justo
    Options
    Offline / Send Message
    Justo polycounter
    PolyHertz said:
    iirc I put that there to fix some sort of bug in an older version of Max I was using at the time. Probably no reason to have it there in modern versions of Max, but no real reason to remove it either. I don't ever really hide just verts.


    Ahh, I see Greg. And yes, I've also never had to hide verts...ever.
    PolyHertz said:
    Unless you're really concerned about how compact your code is, I don't see any reason to use a different method then what I posted above.

    Your script works great. It's not that I'm concerned on how compact it is, but I simply do not understand why not use monster's lines haha. Unless I'm mistaken, and if so by all means I'd love to learn, he summed up in four lines all funcionalities of what you did. Is that not so?
  • PolyHertz
    Options
    Offline / Send Message
    PolyHertz polycount lvl 666
    Yea, as far as I can tell both methods work equally well.

    However, I prefer my method because it's easier to fix should a newer version of Max changes something that results in it breaking (Like monster said; what he's showing isn't documented). Also, if for some reason I end up having to use a really old version of Max, I know it'll still work, where as I'm not sure how backwards compatible the ribbon method is.
  • Justo
    Options
    Offline / Send Message
    Justo polycounter
    Ohh, good points. Thanks for clearing that up. 
Sign In or Register to comment.