Notifications
Clear all

[Closed] How to rotate selected sub object only?

I’m looking around and not finding any examples of this on scriptspot, nor in the maxscript refrence.

The listener tells me that i can use ‘rotate $.selectedFaces (quat 0 0 1 30)’ but it doesn’t appear to work in a scripted context.

Anyone have an idea on this?

Cheers,
Dave.

3 Replies

Hmm, that’s a good question. I couldn’t figure it out either. You can always detach the faces to a new object, rotate that object, and then reattach it to the original object; but that seems like an overly complicated way to do something that should be relatively easy.

yea, its especially odd as its already implemented in the transform type in dialog…

Oh well, to the bottomless pit that is the max wishlist i go

you could transform the positions of selected vertices(faces) one by one by using a matrix transform.

fn rotateTransform coord offsetT quatT = ( coord=coord*(transMatrix (-[offsetT.x,offsetT.y,offsetT.z]))*(quatT as matrix3)*(transMatrix [offsetT.x,offsetT.y,offsetT.z]) )

fn getCenter obj selVerts =
	(
	coord=polyOp.getVert obj 1
	minU=coord.x; minV=coord.y; minW=coord.z; maxU=coord.x; maxV=coord.y; maxW=coord.z
	for v in selVerts do
		(
		coord=polyOp.getVert obj v
		if coord.x<minU then minU=coord.x
		if coord.y<minV then minV=coord.y
		if coord.z<minW then minW=coord.z
		if coord.x>maxU then maxU=coord.x
		if coord.y>maxV then maxV=coord.y
		if coord.z>maxW then maxW=coord.z
		)--for
	[(minU+((maxU-minU)/2.0)),(minV+((maxV-minV)/2.0)),(minW+((maxW-minW)/2.0))]
	)--fn

max modify mode
quatT=quat 30 [0,0,-1]
obj=selection[1]
selFaces=polyOp.getFaceSelection obj
if selFaces.count>0 do
	(
	selVerts=polyOp.getVertsUsingFace obj selFaces
	center=getCenter obj selVerts
	for v in selVerts do
		(
		coord=polyOp.getVert obj v
		coord=rotateTransform coord center quatT
		polyOp.setVert obj #{v} coord
		)
	)

It is not probably the fastest way and a good scripter could optimize this…