View Full Version : Repositioning Vertices
02-18-2006, 03:57 PM
This is going to seem very elementary to you script wizards, but it's defeating me. When I make a half model (epoly) with the boundary on the x=0 plane, the boundary vertices sometimes get shifted off the plane. Assuming that I have a named vertex selection set called "Boundary", I want to write a script that goes through the boundary vertices one-by-one and resets their x pos values to zero.
As the model develops, and new vertices appear on the boundary, I'm trying to write another script which adds a selected vertex to the named selection set.
I'll be very grateful if you can point me in the right direction
02-18-2006, 08:38 PM
Here's a script I wrote to do this very thing. I got tired of having to constantly reset the middle verts of an object while modeling with the Symmetry modifier. So this will take the selected verts of an editable poly object and move them on the object's local x axis back to the object's local zero position. It works even if there are modifiers on top of the base modifier, like Symmetry. This should get you started anyway. Feel free to modify it to use the vert selection set (haven't tried that myself).
modObj = modPanel.getCurrentObject()
if classOf modObj == editable_poly and subObjectLevel == 1 then (
-- turn off constrain to edge or face
local edgeCon = modObj.constrainType
modObj.constrainType = 0
selVerts = polyOp.getVertSelection modObj as array
for i in selVerts do (
vertPos = polyOp.getVert modObj i
polyOp.setVert modObj i [0,vertPos.y,vertPos.z]
-- reset constraints
modObj.constrainType = edgeCon
02-19-2006, 12:14 PM
Thanks a lot. There is no way in the world I could have come up with something as sophisticated as that. I get the impression that it acts as a modifier in the stack, rather than as a one-shot action. Anyway, will now try it out and see if I can be any smarter at implementing it than I am at understanding it.
02-19-2006, 03:19 PM
Nope, it's not a modifier. You just select the verts you want to realign and then run it to snap them back to zero. Probably best to make it a macroscript so you can create a shortcut key or button for it.
02-23-2006, 07:59 PM
It works a treat, James.
Yes, I traced through your code (using maxscript help) and found what the mod bit does - I'm such a beginner at maxscript that I'd not seen that before. I decided it works so neatly, I won't attempt any bungling mods. It's very easy to click on the vertex selection set before I invoke your script, which I've added to a quad menu. The whole reset job takes just a few seconds.
Thanks a lot.
02-23-2006, 07:59 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.