Hey guys/girls the problem I'm having is that I have a max macroscript to align an objects pivot to the selection I have, be that a face, edge, bounding edge, or vert, it then averages then moves the pivot to said average. If nothing is selected it simply averages the to the centre of the object level.
The problem being is that when the code is run, when using a modifier stack to make the object an edit poly(edit poly modifier) it throws back the command
The problem isn't how to get past this command, as thats as simple as making sure the object has no stack and is editable poly, but I want to keep the object a sphere, or box and allow changes within the modifier and without it. I've been trying to wrap my head around this problem since this morning after I was sure it must have been a problem in the code, yet every time I've tried to adjust it, I can't figure out why it just won't work like I want, as it does when the original object is editable like so.
When I making a script that doesn't modify geometry I typically will use a mesh object so I don't have to fiddle around with EPoly, EMesh, Editable Poly, and Edit Mesh operation nonsense.
I feel like there is a better way to do this, but I was just following your scripts flow and logic.
macroScript crAlignPivotToSelection
category:"CR"
buttonText:"align Pivot to selection"
toolTip:"align Pivot to selection"
(
function FnSetPivot =
(
local obj = mesh mesh:$.mesh
local vertSel
case subobjectLevel of
(
1: vertSel = getVertSelection obj
2: vertSel = meshOp.getVertsUsingEdge obj (getFaceSelection obj)
3: vertSel = meshOp.getVertsUsingEdge obj (getFaceSelection obj)
4: vertSel = meshOp.getVertsUsingFace obj (getFaceSelection obj)
5: vertSel = meshOp.getVertsUsingFace obj (getFaceSelection obj)
)
setVertSelection obj vertSel
$.pivot = (translate $.objectTransform (averageSelVertCenter obj)).pos
delete obj
)
undo "Set Pivot" on
(
if subobjectLevel == 0 then
(
for i in selection do i.pivot = i.center
)
else
(
if selection.count == 1 do FnSetPivot()
)
)
)
Replies
I feel like there is a better way to do this, but I was just following your scripts flow and logic.
I see, thanks for taking the time to help out man.
Much appreciated