Notifications
Clear all

[Closed] Reorder vertex numbers in an Editable Poly?

Whats up guys, working on a project using an in-house 3d engine, using Max to model everything.

We’re using the order of vertices in a single polygon to auto-draw another polygon right on top of it.

The problem is if I manually create another vertex on an edge, now the order of vertices (by their number) goes 1, 2, 5, 3, 4.

So the polygon that gets drawn is a funky, triangluated version. I called Max Support and they aren’t aware of a function in Max to reorder the vertices of a selected polygon. Is this something that could be accomplished with a script?

These are very simple flat polygons, so even if I had to do it one-by-one…

Thanks guys!
Ryan

1 Reply

Something along these lines should work:

(
	-- Create a new Editable Poly
	local NewEpoly = Editable_Mesh name:($.name + "_Copy")
	convertTo NewEpoly Editable_Poly
	
	-- Build the polygons
	for f = 1 to $.numFaces do (
		polyOp.CreatePolygon NewEpoly (
			for v in (polyOp.getFaceVerts $ f) collect (
				polyOp.CreateVert NewEpoly (polyOp.getVert $ v)
			)
		)
	)
	
	-- Select the new Editable Poly
	select NewEpoly
)

This script assumes an Editable Poly object is selected (with no modifiers applied) and rebuilds all polys so that each polys’ vertices are in ascending order. This obviously will create overlapping verts as welding would screw up the vertex ordering.
It could be made somewhat more ‘intelligent’ and (for example) allow for objects with modifiers applied, but I figured this might be enough for what you need.

Cheers,
Martijn