ScriptSpot

Forum topic · Scripts Wanted

Align Verts - With Constraints

By JokerMartini · 2010-07-05

Downloads
Description

Does anyone know of any script that aligns verts but constrains the 2 end verts of the selection. See image for better explanation.

Select a column of verts and have the first and last verts in the selection remain unmoved,(highlighted green in the image) but have the other verts (highlighted yellow in the image) align on the x,y or z, axis.

Thanks
JokerMartini

Comments (1)

Graph · 2010-07-06

afaik, no but you can easily write one if you know wich one the "outer verts" are, based on what rules they are supposed to be first and last in 3d space

like so:


(
	
	
	fn pointLineProj pA pB pC = --gets the closest point on a line to a point in space
	( 
		local vAB=pB-pA ; local vAC=pC-pA ; local d=dot (normalize vAB) (normalize vAC) ;
		return (pA+(vAB*(d*(length vAC/length vAB)))) ;
	)

	
	local firstVert = 3
	local lastVert = 23
	local vertsToAlign = #(18, 13, 8)
	
	local obj = $Plane013
	
	local vert1Pos = polyOp.getVert obj firstVert node:obj
	local vert2Pos = polyOp.getVert obj lastVert node:obj
	
	for v in vertsToAlign do
	(
		local vPos = polyOp.getVert obj v node:obj
		
		local tPos = pointLineProj vert1Pos vert2Pos vPos
		
		polyOp.setVert obj #{v} tPos node:obj
	)
	
	
)