Notifications
Clear all

[Closed] MakePlanarin reference local coordinate

Can 3DSMAX make subobject planar along reference coordinate axis??
I found some code. But It is same to ” $.EditablePoly.MakePlanarIn #X

obj=selection[1]
currentFaces=polyOp.getFaceSelection obj
currentVerts=polyOp.getVertsUsingFace obj currentFaces
theScale=[1,0,1]

– array of position
polyOpGetVert=polyOp.getVert
vPosArray=for v in currentVerts collect polyOpGetVert obj v

– center
theCenter=[0,0,0]
for vPos in vPosArray do theCenter+=vPos
theCenter/=vPosArray.count

– scale
polyOpSetVert=polyOp.setVert
m=(transMatrix -theCenter)*(scaleMatrix theScale)
i=0
undo off (
for v in currentVerts do ( polyOpSetVert obj v ( (vPosArray[i+=1]*m)+theCenter) )
)

Please help me… How can I make sub-object planar along reference coordinate axis??

3 Replies

here is my version:


 fn makePlanarToTransformAxis poly verts: axis:#z = if iskindof poly Editable_Poly do
 (
 	if verts == unsupplied do verts = poly.selectedverts
 	if not (verts = verts as bitarray).isempty do
 	(
 		axis = case axis of
 		(
 			 #x: 1
 			 #y: 2
 		default: 3
 		)
 		rtm = getTransformAxis poly 0
 		itm = inverse rtm
 		pp = for v in verts collect 
 		(
 			p = (polyop.getvert poly v)*itm
 			p[axis]
 		)
 		center = (amin(pp) + amax(pp))/2
 		normal = normalize rtm[axis]
 		offsets = for p in pp collect (normal*(center-p))
 		polyop.movevert poly verts offsets
 		update poly
 	)
 )
 

will be interesting to see any other solutions…

1 Reply
(@jack1eyed)
Joined: 1 year ago

Posts: 0

Thanks for help.
But this code acts spread vertexs widely. Except this, It works well.
I will modify and use this one. Thank you again.

Hm, I didn’t know you could do the unsupplied check