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
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.
2) You could check if selection.center.x is positive or negative. Or obj.center.x if you are inside a loop.
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.
@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.
Sorry I just find it strange that you can't handle maxscript but can with Zscript.