Rotate pivot to align with edge of line

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

)

AttachmentSize
max.jpg66.7 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gini8's picture

Review

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)

tayabbs's picture

Thanks

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.

Pamelaight's picture

reader

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's picture

.

(
	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's picture

Very handy

Very handy, Thanks

Habib

StormBrig's picture

you should try align pivot to

you should try align pivot to direction script.

Habib's picture

Very handy, Thanks

Very handy, Thanks

Habib

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.