Home Technical Talk

Symmetry Maxscript + Questions

I was tired of always setting up symmetrical meshes then adding the sym mod so I made this simple script awhile ago. It zeroes out the pivot, resets the xform, collapses the stack, then applies the sym. Works ok as is but I had some questions about making it better because I'm a dummy.
macroScript QuickSym Category:"_NM Tools" Tooltip:"QuickSym"  buttonText:"QuickSym" 
(
For Obj in selection do
Obj.Pivot = [0,0,0] 
resetxform $;
maxOps.CollapseNode $ off;
addModifier $ (symmetry())
)

Questions
1) This currently doesn't work with multiple meshes selected because of the collapse. I'm not sure how to collapse the stack of everything selected.

2) Something I also want to do is check if the mesh is in the -X and if so check the flip option in the sym modifier. What would be the best way to do this? I guess the easiest way would be to just check the pivot?

Replies

  • monster
    Options
    Offline / Send Message
    monster polycounter
    Perna's got some good advice.


    1. I try to avoid loops as much as possible and take advantage of the 3ds Max Mapped Function. This keeps your scripts speedy and shorter.

    The following will produce an instanced Symmetry modifier, which I tend to find handy. If you didn't want it instanced you'd need a for/do loop. I also added an undo context.
    macroScript QuickSym Category:"_NM Tools" Tooltip:"QuickSym"  buttonText:"QuickSym" 
    (
    	undo "Quick Symmetry" on
    	(
    		selection.pivot = [0,0,0]
    		resetxform selection
    		collapseStack selection
    		addModifier selection (symmetry())
    	)
    )
    
    

    2) You could check if selection.center.x is positive or negative. Or obj.center.x if you are inside a loop.
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    Something you can also do to check if the mesh is flipped on X axis or not would be to get the bounds of the mesh compared to the pivot.

    I disagree with perna in this case because the pivot has already been reset to [0,0,0], so we can safely assume you want the symmetry to be flipped around the 0 world position on the X axis.
    So if that is true, then if your mesh's bounds abs(minimum) is less than the abs(maximum) then you can assume that you probably want to flip the X axis on the modifier.

    This obviously wouldn't work the same if your object can be in any arbitrary position in space and you're not modelling around the 0 axis, although you could still use the object's pivot, subtract this from the bounds, and the same operation I described before will likely be correct.

    abs() is a math function you can find in the Maxscript reference docs, and the command for getting a node's bounding box is also mentioned in the docs.
  • nyx702
    Options
    Offline / Send Message
    @perna: Thanks for the help and tips. You're right I do need better foundations rather than hacking it together. I have read the Max Help (a few times actually) and it just doesn't stick. Everyone learns differently and it's really hard for me to digest this stuff by reading it. For me personally I feel I understand it better when I can dissect examples and ask questions

    @monster: That is super helpful. I was curious how you added the undo feature. That is awesome. See it's that kind of stuff I have trouble finding out from just reading the Max Help.

    @MoP: Thanks that is helpful. I didn't think about using the bounding box. I will try those things and see how it works. Even if it occasionally flips it the wrong way its still better than pressing it all the time.
  • trebor777
    Options
    Offline / Send Message
    trebor777 polycounter lvl 10
    Says the guy who creates Zbrush plugins xD

    Sorry ;) I just find it strange that you can't handle maxscript but can with Zscript. :)
Sign In or Register to comment.