ScriptSpot

Forum topic · General Scripting

Rotate pivot to align with edge of line

By hanselmoniz · 2015-02-16

Downloads
Description

for i in selection do

(p1 =getKnotPoint i 1 1

p2 =getKnotPoint i 1 2

dir = normalize (p2 - p1)

vec = case axis of

(

#x: obj.transform[1] 

#y: obj.transform[2] 

#z: obj.transform[3] 

)

tm = i.transform

vec = normalize vec

 

 

rtm = angleaxis (acos (dot vec dir)) (normalize (cross dir vec))

i.transform = translate (rotate (scalematrix tm.scale) (tm.rotation*rtm)) tm.pos

(if pos == true do obj.pos = p1

)

Comments (7)

Review

gini8 · 2020-03-25

Go into pivot mode and select axis. Press the Insert key on your keyboard to go into pivot mode. aboutallpet Then left click on the axis to align (it should turn yellow)

Thanks

tayabbs · 2019-12-20

Hello, I would like to thank you for sharing this interesting information. Moreover, the material mentioned here will be useful for a lot of people. Personally I will use it in my kakadu national park sample task.

reader

Pamelaight · 2019-10-11

Here are some important knowledge which is about how to rotate pivot to align with edge of line. This method is simplified here in detail and tell you that you like it in best custom writings reviews way because we describe it in good way for only your helping purpose.

.

miauu · 2015-02-16


(
	selObjsArr = selection as array
	for obj in selObjsArr do
	(
		p1 = getKnotPoint obj 1 1
		p2 = getKnotPoint obj 1 2
		dir = normalize (p2 - p1)
		vec = obj.transform[1] 
		tm = obj.transform
		vec = normalize vec
		dir = normalize dir
		rtm = angleaxis (acos (dot vec dir)) (normalize (cross dir vec))
		tempObjTM = translate (rotate (scalematrix tm.scale) (tm.rotation*rtm)) tm.pos
		--
		worldAlignPivot obj
		rotation = inverse tempObjTM.rotation
		in coordsys local obj.rotation *= rotation
		obj.objectoffsetrot *= rotation
		obj.objectoffsetpos *= rotation	
		obj.pivot = p1		
	)
)

Habib · 2018-10-18

Very handy, Thanks

Habib · 2019-05-01

Very handy, Thanks

StormBrig · 2019-05-01

you should try align pivot to direction script.