[Closed] moving poly verts and coord sys
Hi All,
I’m trying to make a small script that will take a selected poly, move it’s verts to the outside 2″, extrude inwards 2″ and finally extrude one more time with 0 as height and move the veths inward 2″. The code below works fine foir most of the cases but on some times it will move my verts in what seems to me as a rotated coordsys. I’ve tryed everything, like placing all the code in between “in coordsys world”, adding a dummy and using the node option for moveVert but with the exact same result.
[size=2]Here is the code:[/size]
(
local ss = $selection[1]
myDummy = Dummy()
function moveVerts moveValue =
(
local vertX = 0
local vertY = 0
local vertZ = 0
local centerPos = 0
myFaces = getFaceSelection ss as array
myVerts = polyOp.getVertsUsingFace ss myfaces as array
polyOp.setVertSelection ss myVerts
for i = 1 to myVerts.count do centerPos += (polyop.getVert ss myVerts[i] )/4
if (polyop.getVert ss myVerts[1] ).x != (polyop.getVert ss myVerts[3] ).x or (polyop.getVert ss myVerts[2] ).x != (polyop.getVert ss myVerts[3] ).x then vertX = moveValue
if (polyop.getVert ss myVerts[1] ).y != (polyop.getVert ss myVerts[3] ).y or (polyop.getVert ss myVerts[2] ).y != (polyop.getVert ss myVerts[3] ).y then vertY = moveValue
if (polyop.getVert ss myVerts[1] ).z != (polyop.getVert ss myVerts[3] ).z or (polyop.getVert ss myVerts[2] ).z != (polyop.getVert ss myVerts[3] ).z then vertZ = moveValue
for i = 1 to myverts.count do
(
if ((polyop.getVert ss myVerts[i] ).x - (centerPos).x) > 0 then polyOp.moveVert ss myVerts[i] [vertX,0,0]
else polyOp.moveVert ss myVerts[i] [-vertX,0,0]
if ((polyop.getVert ss myVerts[i] ).y - (centerPos).y) > 0 then polyOp.moveVert ss myVerts[i] [0,vertY,0]
else polyOp.moveVert ss myVerts[i] [0,-vertY,0]
if ((polyop.getVert ss myVerts[i] ).z - (centerPos).z) > 0 then polyOp.moveVert ss myVerts[i] [0,0,vertZ]
else polyOp.moveVert ss myVerts[i] [0,0,-vertZ]
)
)
moveVerts 2
polyOp.extrudeFaces ss ss.selectedfaces -2
polyOp.extrudeFaces ss ss.selectedfaces 0
moveVerts -2
delete ss.selectedfaces
delete myDummy
print "Done"
)
To have it run, create an editable poly, select one face and go.
If anybody have any idea I would greatly appreciate any response!
Thank you!
I just figured it out what it was causing it. The corner of my object was @ 0,0,0 and on the 2 sides that were on the x and y axys it was having the error. Once I moved my object everything worked fine …
Still, if you have any ideas why it did that or how to improve please post them!