[Closed] Scale Selected polys Editable poly?
Im looking to do a simple scale around the local axis of the selected polys.
I havent really found anything to do it easily, or im not checking the right area in the maxscript help.
Any ideas how do do this in editable poly?
Thanks
Bronson
Hi gibbz
Indeed to scale faces in maxscript you have to scale the vertices of this faces
here is an example:
obj=selection[1]
currentFaces=#{1..4} -- the face selection
theCenter=[0,0,0] -- or the center of selection ... or the pivot of your object
theScale=[2.0,2.0,2.0]
currentVerts=polyOp.getVertsUsingFace obj currentFaces
for v in currentVerts do (
currentVertPos=polyOp.getVert obj v
currentVertPos=((currentVertPos*(transMatrix -theCenter))*(scaleMatrix theScale))*(transMatrix theCenter)
polyOp.setVert obj v currentVertPos
)
Hey thanks. Is there an easy way to get the center of the current selection, or do i have to do it using max/min of the position of the selected vertecies?
Cheers
Bronson
To get the center of the current selection would be:
selection.center
HalfVector.
PS: ok, I think you mean the center of the current selection of faces?..
yes the center of the selected faces while in editable poly. I can always do it manually if theres nothing easy.
Thanks
To my opinion yes: The center is calculated from vertices.
obj=selection[1]
currentFaces=polyOp.getFaceSelection obj
currentVerts=polyOp.getVertsUsingFace obj currentFaces
theScale=[1.5,1.5,1.5]
-- 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) )
)
I don’t know if there is a means simpler than that one.
ah i ended up using the transform matrix. Seemes to work a treat, thanks guys