Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

I need a script code for align axis to world

I need a script code for align axis to world

Waseem_Dabbas
Advocate Advocate
1,134 Views
10 Replies
Message 1 of 11

I need a script code for align axis to world

Waseem_Dabbas
Advocate
Advocate

Hi,

I want to make code that aligns the Z axis of a certain element's center to the Z axis of a scene?

in short, I want the code of this button 👇🏻

 

Waseem_Dabbas_1-1680553876865.png

 

 

0 Likes
Accepted solutions (1)
1,135 Views
10 Replies
Replies (10)
Message 2 of 11

denisT.MaxDoctor
Advisor
Advisor

see MXS Help:

Same as Hierarchy/Pivot/Affect Object Only - Align to World.

AlignPivot <node>-- mapped method

 
0 Likes
Message 3 of 11

Waseem_Dabbas
Advocate
Advocate

@denisT.MaxDoctor 

Thank you for answering

After Writing the code, nothing happened, did I miss something?

Waseem_Dabbas_0-1680612373950.png

 

The Z axis of the selected object should follow the Z axis of the scene.

0 Likes
Message 4 of 11

denisT.MaxDoctor
Advisor
Advisor
alignPivot $

 

hmm... you need to learn MaxScript syntax if you want to use it.

0 Likes
Message 5 of 11

istan
Advisor
Advisor
a typical "CG" problem 😉
0 Likes
Message 6 of 11

Waseem_Dabbas
Advocate
Advocate
Accepted solution

For those who have the same question, here is the solution:

   for i in selection do 
    (
        WorldAlignPivot i
    )

 

0 Likes
Message 7 of 11

denisT.MaxDoctor
Advisor
Advisor

denisTMaxDoctor_0-1729021385663.png


Funny how it goes... in the MXS Help, the distance from AlignPivot to WorldAlignPivot is just three lines, but in real life, it takes a year and a half to get through them.

 

It will probably take another year and a half to learn what a “mapped function” is...

0 Likes
Message 8 of 11

istan
Advisor
Advisor

@denisT.MaxDoctor wrote:

denisTMaxDoctor_0-1729021385663.png

It will probably take another year and a half to learn what a “mapped function” is...


But the help is not quite right on this point either. It should rather be <node | nodecollection>, if collections can also be passed.

0 Likes
Message 9 of 11

denisT.MaxDoctor
Advisor
Advisor

I didn't say you have to follow Help exactly... it was enough to believe what I said and check how it works. 😎

0 Likes
Message 10 of 11

istan
Advisor
Advisor

wrong receiver..

I always trust you! 😁

0 Likes
Message 11 of 11

istan
Advisor
Advisor

I always trust you! 😁

0 Likes