<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Copying pivot rotation of an object to another object in script in 3ds Max Programming Forum</title>
    <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10238010#M5450</link>
    <description>&lt;P&gt;How about: $source.parent = $target&lt;/P&gt;&lt;P&gt;or something similar based on that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Apr 2021 15:17:32 GMT</pubDate>
    <dc:creator>domo.spaji</dc:creator>
    <dc:date>2021-04-14T15:17:32Z</dc:date>
    <item>
      <title>Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10233075#M5445</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;What I need to do is copy the pivot rotation of an object to a second object's rotation without moving the second object. I've been reading the help and googling this, but I don't understand what needs to be done.&lt;/P&gt;&lt;P&gt;I'd really appreciate some help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TIA&lt;/P&gt;&lt;P&gt;Ken&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 02:39:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10233075#M5445</guid>
      <dc:creator>kenc</dc:creator>
      <dc:date>2021-04-13T02:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10234592#M5446</link>
      <description>&lt;P&gt;I was able to finally figure it out my self.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 14:12:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10234592#M5446</guid>
      <dc:creator>kenc</dc:creator>
      <dc:date>2021-04-13T14:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10236021#M5447</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/365603"&gt;@kenc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I was able to finally figure it out my self.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Good for you, but it would be nice to share the solution in case anyone else comes across a similar problem.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 23:57:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10236021#M5447</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2021-04-13T23:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10236038#M5448</link>
      <description>&lt;P&gt;I'm sorry. I realized I didn't share till you replied denisT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All I need to do rotate the second object by the amount and direction of the first. Then position it to the same point as the first object. The objects are symmetrical.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 00:07:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10236038#M5448</guid>
      <dc:creator>kenc</dc:creator>
      <dc:date>2021-04-14T00:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10236088#M5449</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/365603"&gt;@kenc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I'm sorry. I realized I didn't share till you replied denisT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All I need to do rotate the second object by the amount and direction of the first. Then position it to the same point as the first object. The objects are symmetrical.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;BTW... this is an interesting and non-trivial task.&lt;/P&gt;&lt;P&gt;try to align the pivots only for two objects in this test scene:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;with redraw off, undo off
(
	delete objects
	gc()
	
	--t = random 0 100
	--format "&amp;gt;&amp;gt; %\n" t
	seed 83
	
	size0 = random [4,4,4] [10,10,10]
	size1 = random [4,4,4] [10,10,10]

	rot0 = random -[180,180,180] [180,180,180]
	rot1 = random -[180,180,180] [180,180,180]

	pos0 = random -[10,10,10] [10,10,10]
	pos1 = random -[10,10,10] [10,10,10]

	fn aseuler rot = (eulerangles rot.x rot.y rot.z) 

	s = box name:#source length:size0.x widht:size0.y height:size0.z \
		pos:pos0 rotation:(aseuler rot0) wirecolor:green
	s.objectoffsetrot = aseuler (random rot0 rot1) 
	s.objectoffsetpos = random pos0 pos1
		
	t = box mane:#target length:size1.x widht:size1.y height:size1.z \
		pos:pos1 rotation:(aseuler rot1) wirecolor:orange
	t.objectoffsetrot = aseuler (random rot0 rot1) 
	t.objectoffsetpos = random pos0 pos1
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's check how well the problem was solved&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 00:36:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10236088#M5449</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2021-04-14T00:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10238010#M5450</link>
      <description>&lt;P&gt;How about: $source.parent = $target&lt;/P&gt;&lt;P&gt;or something similar based on that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 15:17:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10238010#M5450</guid>
      <dc:creator>domo.spaji</dc:creator>
      <dc:date>2021-04-14T15:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10238131#M5451</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8285824"&gt;@domo.spaji&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;How about: $source.parent = $target&lt;/P&gt;&lt;P&gt;or something similar based on that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;of course it will not work, only pivot must move!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 15:53:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10238131#M5451</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2021-04-14T15:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10238530#M5452</link>
      <description>&lt;P&gt;But of course it was not meant to be direct solution to your task.&lt;/P&gt;&lt;P&gt;Rather it is (usual) way for adding new/additional transform (center)&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 18:14:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10238530#M5452</guid>
      <dc:creator>domo.spaji</dc:creator>
      <dc:date>2021-04-14T18:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10238828#M5453</link>
      <description>&lt;P&gt;In MAX, you can align objects pivots using the Align Tool. The original question was how to do this using the max script. As stated above, the problem is solved, and I want to know how to do it for example for my test case. It's all.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 20:08:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10238828#M5453</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2021-04-14T20:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10238857#M5454</link>
      <description>&lt;P&gt;Sorry people but I am swamped with work right now and haven't had time to reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The way I did it is I have a chair with pivot rotated because the chair was rotated. I created a point helper and rotated it the same amount and direction as the chair. This of course moved the helper. I then used the chairs position for the helper position. This is a very easy scenario because I'm only using a helper point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the near future what I need to do (with script) is to clone the chair and have it's pivot rotation the same as the original chair.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again sorry for the lack of replies.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 20:16:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10238857#M5454</guid>
      <dc:creator>kenc</dc:creator>
      <dc:date>2021-04-14T20:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10241324#M5455</link>
      <description>&lt;P&gt;I now have some time to expand on this subject.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my scenario and must be done by script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I have a text file. In the text file is a line to merge a chair made of 4 parts. Next line is the rotation for the chair. Next line is position for the chair. Using script I merge the chair and insertion is at 0,0,0. I then group the 4 parts. I create a point helper and place it at 0,0,0, same as the chair insertion point. I set the group pivot position to the same as point helper pivot position.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. I then rotate the group, example 180. I then position it, example 100,100,100. Then delete point helper and ungroup chair.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Next line in the text file is to clone the same chair, which I do. Then group it and create a point helper. This clone has the same rotation as the first, 180. But when I rotate it, the whole chair moves along with the point helper. I then apply the position, say 200,0,0. The clone is positioned correctly but rotated by 180.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I need to happen is the chair not to rotate, it should have the rotational position as the first chair. Then place it at 200,0,0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So this is my scenario and I hope I have explained correctly to understand what I am trying to achieve.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 15:14:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10241324#M5455</guid>
      <dc:creator>kenc</dc:creator>
      <dc:date>2021-04-15T15:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10243451#M5456</link>
      <description>&lt;P&gt;the situation you describe has nothing to do with 'only pivot alignment', you simply need to align a group of nodes to another node or transform value.&lt;/P&gt;&lt;P&gt;so lets say we have a list of object and an orientation and position target. We need to align this list (all nodes) to the target keeping their original relative positions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;fn alignNodesToTarget nodes target method:#world = 
(
	origin_tm = case method of
	(
		#center: transmatrix nodes.center
		 #first: nodes[1].transform
		default: matrix3 1 -- WORLD
	)
	
	for node in nodes do (node.transform *= inverse origin_tm * target.transform)
)

delete objects
gc()

nodes = 
(
	b0 = cylinder radius:10 height:2 wirecolor:orange rotation:(eulerangles 0 0 90) isselected:on 
	b1 = cylinder radius:2 height:20 pos:[0,0,1] wirecolor:orange 
	b2 = box width:30 length:20 height:5 pos:[0,0,20] wirecolor:green
	b3 = box width:30 length:30 height:3 rotation:(eulerangles -70 0 0) pos:[0,15,40] wirecolor:green

	#(b0, b1, b2, b3)
)

target =  point name:#target cross:on box:on axistripod:on rotation:(eulerangles 0 0 45) pos:[50,20,20] wirecolor:red

/* run it!
alignNodesToTarget nodes target method:#world
*/

/* or run it!
alignNodesToTarget nodes target method:#first
*/&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 08:17:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10243451#M5456</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2021-04-16T08:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10243462#M5457</link>
      <description>&lt;P&gt;BTW. Of course, for a better pipeline, all imported (merged) objects must be grouped into one, or more correctly, there must be an XREF object or container. In this case we will not have a problem with instancing, and updating.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 08:22:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10243462#M5457</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2021-04-16T08:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10254190#M5458</link>
      <description>&lt;P&gt;Hi denisT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the time length between replies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the function, what exactly is going on in line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;for node in nodes do (node.transform *= inverse origin_tm * target.transform)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;on&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 16:26:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10254190#M5458</guid>
      <dc:creator>kenc</dc:creator>
      <dc:date>2021-04-20T16:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10254371#M5459</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/365603"&gt;@kenc&lt;/a&gt;&amp;nbsp;wrote:&lt;P&gt;In the function, what exactly is going on in line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;for node in nodes do (node.transform *= inverse origin_tm * target.transform)&lt;/PRE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="general"&gt;node.transform *= inverse origin_tm * target.transform&lt;/LI-CODE&gt;&lt;P&gt;It's the same as:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;node.transform = node.transform * inverse origin_tm * target.transform&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;now is the same step by step:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;it's a transformation of a matrix3 from one coordinate to another where:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;origin_tm&lt;/STRONG&gt; - source coordinate system&lt;BR /&gt;&lt;STRONG&gt;target.transform&lt;/STRONG&gt; - destination coordinate system&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;get node's transform in world (zero) coordinates:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;tm = node.transform * inverse origin_tm&lt;/LI-CODE&gt;&lt;P&gt;put transform in target's coordinates where node's transform is ZERO (relative is ZERO)&lt;/P&gt;&lt;LI-CODE lang="general"&gt;tm = tm * target.transform&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;this means that node's transform is aligned to target's transform:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;node.transform = tm&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 17:33:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10254371#M5459</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2021-04-20T17:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10254382#M5460</link>
      <description>&lt;P&gt;OK now I understand what is going no and is what (I think) I'm looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I won't be able to check this out till the weekend, I'm swapped right now. So I can mark this as 'solution' if OK with you?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 17:38:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10254382#M5460</guid>
      <dc:creator>kenc</dc:creator>
      <dc:date>2021-04-20T17:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10254437#M5461</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fn toMatrix3 tm = case of
(
(iskindof tm Matrix3): tm
 (iskindof tm Point3): transmatrix tm
	 (isvalidnode tm): tm.transform
	   (tm == #world): matrix3 1
			  default: matrix3 1 -- WORLD
)

fn alignNodesToTarget nodes target origin:#world = 
(
	target_tm = toMatrix3 target
	origin_tm = toMatrix3 origin
	
	for node in nodes do (node.transform *= inverse origin_tm * target_tm)
)


/*********************************** EXAMPLE SCENE SETUP *****************************************/

delete objects
gc()


nodes = 
(
	b0 = cylinder radius:10 height:2 wirecolor:orange rotation:(eulerangles 0 0 90) isselected:on 
	b1 = cylinder radius:2 height:20 pos:[0,0,1] wirecolor:orange 
	b2 = box width:30 length:20 height:5 pos:[0,0,20] wirecolor:green
	b3 = box width:30 length:30 height:3 rotation:(eulerangles -70 0 0) pos:[0,15,40] wirecolor:green

	#(b0, b1, b2, b3)
)

target1 =  point name:#target cross:on box:on axistripod:on rotation:(eulerangles 0 0 45) pos:[50,20,20] wirecolor:red
target2 =  point name:#target cross:on box:on axistripod:on rotation:(eulerangles 0 0 -45) pos:[-50,-20,40] wirecolor:orange
target3 =  point name:#target cross:on box:on axistripod:on rotation:(eulerangles 0 0 120) pos:[50,20,60] wirecolor:yellow


origin_first = nodes[1].transform -- THIS IS PROBABLY THE INITIAL TRANSFORM AFTER MERGE



/* run one after another:

alignNodesToTarget nodes target1 origin:origin_first

alignNodesToTarget nodes origin_first origin:target1

alignNodesToTarget nodes target2 origin:nodes[1]

alignNodesToTarget nodes target3 origin:target2

alignNodesToTarget nodes origin_first origin:nodes[1]

*/&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is more advanced example&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 18:06:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10254437#M5461</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2021-04-20T18:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10254798#M5462</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/365603"&gt;@kenc&lt;/a&gt;&amp;nbsp;wrote:&lt;P&gt;So I can mark this as 'solution' if OK with you?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This is your question, and you don't need anyone's permission to mark the answer as a solution. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;It just should work for you.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 20:37:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10254798#M5462</guid>
      <dc:creator>denisT.MaxDoctor</dc:creator>
      <dc:date>2021-04-20T20:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Copying pivot rotation of an object to another object in script</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10260111#M5463</link>
      <description>&lt;P&gt;denisT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your explanation is thorough and a quick test confirms it works for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry again for lengthy time between replies. I appreciate all your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This an accepted solution.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 15:47:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/copying-pivot-rotation-of-an-object-to-another-object-in-script/m-p/10260111#M5463</guid>
      <dc:creator>kenc</dc:creator>
      <dc:date>2021-04-22T15:47:19Z</dc:date>
    </item>
  </channel>
</rss>

