ScriptSpot

Forum topic · Scripts Wanted

align object by selected edge

By airbrush · 2014-01-30

Description
Comments (1)

MerlinEl · 2019-06-24

maybe this?

fn alignObjectToSelectedEdge obj_src = (

local obj_trgt = (selection as Array)[1]
if classOf obj_trgt != Editable_Poly do return false
local edges = (polyOp.getEdgeSelection obj_trgt) as Array
if edges.count == 0 do return false
local everts = (polyOp.getVertsUsingEdge obj_trgt edges[1]) as Array
local p1 = polyOp.getVert obj_trgt everts[1]
local p2 = polyOp.getVert obj_trgt everts[2]
local dir = normalize (p2 - p1)
local tm = matrixFromNormal dir
tm.row4 = (p1 + p2) / 2
undo "Align object to Edge" on obj_src.transform = tm
)

alignObjectToSelectedEdge $Dummy002