首页 插件专区 Max插件 显示 AlignPivotBasachi【源码备份】
AlignPivotBasachi【源码备份】
查看 10 下载 0 收藏 纠错
  • 应用平台: Windows 7 , Windows 8 , Windows 10 , Windows 11
  • 软件支持: 32位/64位
  • 界面语言: 多语言支持

-- aligns pivot like in Maya but better:


-- 1) to vertex or to direction between two selected vertecses

-- 2) to edge

-- 3) to face or to avarage direction of multiple faces

-- 4) if nothing is selected Script will reset pivot, wich means change from working to world

-- 5) continue press the script without any selection to switch between "Use Pivot Point Center" and "Use Selection Center" mods


-- changes only Working pivot, not actual world pivot of object

-- works with Editable poly and edit poly modifire

-- works with only one selected object


-- v 1.0

-- 24.05.2021


macroscript AlignPivotBasachi

category:"Basachi"

tooltip:"Align Pivot"

buttonText:"APB"

(

global SwitchSelCenter

fn EdgeSnap vertsOfSelEdge =

(

v1 =  polyOp.getVert $ vertsOfSelEdge[1]

v2 =  polyOp.getVert $ vertsOfSelEdge[2]

p = Point() --is

p.dir = v1 - v2 --it

WorkingPivot.setTM p.transform  -- genious

delete p -- ?

toolMode.coordsys #working_pivot

setCoordCenter  #Selection

SwitchSelCenter = false

)

fn FaceSnap SelFeces =

(

FaceNormal = [0,0,0] 

for face in SelFeces do

FaceNormal += polyop.getFaceNormal $ face

p = Point()     --is

p.dir = FaceNormal --it

WorkingPivot.setTM p.transform  -- genious

delete p -- ?

toolMode.coordsys #working_pivot

setCoordCenter  #Selection

SwitchSelCenter = false

)

fn ResetPivotToWorld =

(

toolMode.coordsys #world

if SwitchSelCenter == true then

(

if getCoordCenter() == #local then setCoordCenter #Selection

else setCoordCenter #Local

)

else SwitchSelCenter = true

)

case classof (modPanel.getCurrentObject()) of

(

Editable_Poly :

(

case subobjectLevel of

(

1 :

(

selVert = polyop.getVertSelection $ as array

if selVert.count == 0 then ResetPivotToWorld()

if selVert.count == 1 then FaceSnap (polyop.getFacesUsingVert $ selVert as array)

if selVert.count == 2 then EdgeSnap selVert

)

2 :

(

SelEdge = polyop.getEdgeSelection $ as array

if SelEdge.count == 0 then ResetPivotToWorld()

if SelEdge.count == 1 then EdgeSnap (polyop.getVertsUsingEdge $ SelEdge[1] as array)

)

4 :

(

SelFaces = polyop.getFaceSelection $ as array

if SelFaces.count == 0 then ResetPivotToWorld()

else FaceSnap SelFaces

)

5 :

(

SelFaces = polyop.getFaceSelection $ as array

if SelFaces.count == 0 then ResetPivotToWorld()

else FaceSnap SelFaces

)

default: ResetPivotToWorld()

)

)

Edit_Poly :

(

if ($ as string) != "$selection" then

(

case subobjectLevel of

(

1 :

(

selVert = $.modifiers[#Edit_Poly].GetSelection #Vertex as array

if selVert.count == 0 then ResetPivotToWorld()

if selVert.count == 1 then FaceSnap (polyop.getFacesUsingVert $ selVert as array)

if selVert.count == 2 then EdgeSnap selVert

)

2 :

(

SelEdge = $.modifiers[#Edit_Poly].GetSelection #Edge as array

if SelEdge.count == 0 then ResetPivotToWorld()

if SelEdge.count == 1 then EdgeSnap (polyop.getVertsUsingEdge $ SelEdge[1] as array)

)

4 :

(

SelFaces = $.modifiers[#Edit_Poly].GetSelection #Face as array

if SelFaces.count == 0 then ResetPivotToWorld()

else FaceSnap SelFaces

)

5 :

(

SelFaces = $.modifiers[#Edit_Poly].GetSelection #Face as array

if SelFaces.count == 0 then ResetPivotToWorld()

else FaceSnap SelFaces

)

default: ResetPivotToWorld()

)

)

else messageBox "only one object allowed" beep: 0

)

default: ResetPivotToWorld()

)

)


发表评论
  • 顺带评个分
提交
  • 834544123 在线客服

  • 周一至周五:9:00-21:00

    周末及节日:9:00-18:00

  • QQ&微信:
    834544123
    QQ群:
    16538234