Notifications
Clear all

[Closed] Repositioning Vertices

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

Cheers

John

4 Replies

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
 	)
 )

James

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.

Thanks again

John

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.

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.

John