<?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: Loading and positioning an object in 3ds Max Programming Forum</title>
    <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196069#M20396</link>
    <description>Rotation is fun - if I could wrap my head around it I'd be a genius...&lt;BR /&gt;&lt;BR /&gt;Go to the Advanced Search and look for "rotation" (without the quotes) and select just this Maxscript forum from the list. There's 5 pages of results - quite a few will relate to reading data and positioning/rotating objects based on that data.&lt;BR /&gt;&lt;BR /&gt;You will almost certainly have to employ eulerAngles as in the 1st reply to this thread.</description>
    <pubDate>Wed, 13 Apr 2011 13:02:37 GMT</pubDate>
    <dc:creator>Steve_Curley</dc:creator>
    <dc:date>2011-04-13T13:02:37Z</dc:date>
    <item>
      <title>Loading and positioning an object</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196063#M20390</link>
      <description>Hello!&lt;BR /&gt;&lt;BR /&gt;With mel scripting, I can import an object into Maya and then move and rotate the object into the position and orientation that I want. A sample mel script is as follows:-&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;file -import -gr -gl -loadReferenceDepth "all" -shd "renderLayersByName" -gn "my_object" "C:/my_object.3ds";&lt;BR /&gt;currentTime 0;&lt;BR /&gt;select -r "my_object";&lt;BR /&gt;setAttr ".ro" 2;&lt;BR /&gt;setAttr ".rp" -type "double3" 0 0 0;&lt;BR /&gt;setAttr ".t" -type "double3" -44.059 0.0487435 4.16622 ;&lt;BR /&gt;setAttr ".r" -type "double3" 0.0 99.8438 0.0 ;&lt;BR /&gt;setKeyframe;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Is it possible to do something similar with a maxscript in 3DMax? Thanks in advance for any help.</description>
      <pubDate>Thu, 07 Apr 2011 15:51:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196063#M20390</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-04-07T15:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Loading and positioning an object</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196064#M20391</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Do you want a full transcription of the whole script or only rotate/move/scale commands ?&lt;BR /&gt;&lt;BR /&gt;To select an object and  move/rotate/scale it you can use either &lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;select $'my_object'&lt;BR /&gt;$.pos    = &lt;BR /&gt;$.rotate = (eulerAngles 0.0 99.8438 0.0)&lt;BR /&gt;$.scale  = &lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;select $'my_object'&lt;BR /&gt;move $ &lt;BR /&gt;rotate $ (eulerAngles 0.0 99.8438 0.0)&lt;BR /&gt;scale $ &lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;These are commands for basic position, rotation and scale controller types. If any other controller is assigned to position or rotation or scale then the value to be applied might be different but the way it works is similar.&lt;BR /&gt;&lt;BR /&gt;For rotation and scale you have to take care also of transformation center and system coordinates.&lt;BR /&gt;&lt;BR /&gt;To rotate about object's center and object's system coordinates :&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;in coordsys local (rotate $ (eulerAngles 0.0 99.8438 0.0))&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;To rotate the object about world center / system coordinates :&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;in coordsys world (rotate $ (eulerAngles 0.0 99.8438 0.0))&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;To rotate the object about another object center / system coordinates :&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;in coordsys $'ref_object' about $'ref_object' (rotate $ (eulerAngles 0.0 99.8438 0.0))&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Hope it will help&lt;BR /&gt;&lt;BR /&gt;amarhys</description>
      <pubDate>Fri, 08 Apr 2011 07:54:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196064#M20391</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-04-08T07:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: Loading and positioning an object</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196065#M20392</link>
      <description>Thank you for your help... it's most helpful. Just to let you know I am completely new to maxscript!&lt;BR /&gt;&lt;BR /&gt;It's the loading of the object that I am having difficulty in figuring out. In the mel script example of my first post, the very first command loads the object and have it assigned to a locator, which is like an empty group, but crucially one that I can give a name to during the running of the script.  I then know the name of the object in order to select it when I want  move or rotate the object in my mel script.&lt;BR /&gt;&lt;BR /&gt;I would like to do something similar with maxscript, import a 3ds file and and use maxscript to give the rootnode a name of my choosing in order for me to select it. I don't see an option like this in importFile&amp;amp;#40;&amp;amp;#41; command. Is this possible or am I missing something?&lt;BR /&gt;&lt;BR /&gt;The reason I need to give the rootnode a name is that I will be importing several objects with my maxscript.</description>
      <pubDate>Fri, 08 Apr 2011 11:34:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196065#M20392</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-04-08T11:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Loading and positioning an object</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196066#M20393</link>
      <description>When you ImportFile the object imported is automatically selected, therefore you only need to assign selection to a variable in order to reference it later. You don't actually need its name, though that is easily accessible if you want it. If there is more than 1 object imported from a single file, loop through the selection collection dealing with each one in turn. Note that they retain the names given to them when they were exported (from Max anyway), unless a scene object of the same name already exists in which case you get a pop-up dialog.</description>
      <pubDate>Fri, 08 Apr 2011 12:22:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196066#M20393</guid>
      <dc:creator>Steve_Curley</dc:creator>
      <dc:date>2011-04-08T12:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Loading and positioning an object</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196067#M20394</link>
      <description>That sounds good... it seems like it's possible to do what I need to do in maxscript. I'm going to see how far I can take this on my own... hopefully the answers I've gotten from here should be all that I need.&lt;BR /&gt;&lt;BR /&gt;Thanks for all the help.</description>
      <pubDate>Fri, 08 Apr 2011 12:45:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196067#M20394</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-04-08T12:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Loading and positioning an object</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196068#M20395</link>
      <description>I think I am getting there... well I thought I was. It seems I am struggling with setting keyframes for rotation. This is a sample of my maxscript:-&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;with animate on&lt;BR /&gt;(&lt;BR /&gt; at time 0 $.pos = &lt;BR /&gt; at time 0 $.rotation.x_rotation = 0.0&lt;BR /&gt; at time 0 $.rotation.y_rotation = 99.8438&lt;BR /&gt; at time 0 $.rotation.z_rotation = 0.0&lt;BR /&gt; &lt;BR /&gt; at time 25 $.pos = &lt;BR /&gt; at time 25 $.rotation.x_rotation = 0.0&lt;BR /&gt; at time 25 $.rotation.y_rotation = 99.8438&lt;BR /&gt; at time 25 $.rotation.z_rotation = 0.0 &lt;BR /&gt;)&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;To my mind, the above should make the object be still from frames 0 to 25. However, what I am seeing in Max is the object rotating around y. From looking at the curves, it seems my rotations around y seems to be accumulating. I think I am missing something basic and I am hoping someone can tell me what it is? Thanks.&lt;BR /&gt;&lt;BR /&gt;The odd thing is that the position is behaving as I would expect and not translating.</description>
      <pubDate>Wed, 13 Apr 2011 12:11:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196068#M20395</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-04-13T12:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Loading and positioning an object</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196069#M20396</link>
      <description>Rotation is fun - if I could wrap my head around it I'd be a genius...&lt;BR /&gt;&lt;BR /&gt;Go to the Advanced Search and look for "rotation" (without the quotes) and select just this Maxscript forum from the list. There's 5 pages of results - quite a few will relate to reading data and positioning/rotating objects based on that data.&lt;BR /&gt;&lt;BR /&gt;You will almost certainly have to employ eulerAngles as in the 1st reply to this thread.</description>
      <pubDate>Wed, 13 Apr 2011 13:02:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196069#M20396</guid>
      <dc:creator>Steve_Curley</dc:creator>
      <dc:date>2011-04-13T13:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: Loading and positioning an object</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196070#M20397</link>
      <description>Thanks for your reply, but I had a look already and wasn't able to find anything relevant. Hence the question.&lt;BR /&gt;&lt;BR /&gt;I believe my code that I published to be correct though and so I don't understand why I am seeing my object changing orientation between the keys.</description>
      <pubDate>Wed, 13 Apr 2011 13:43:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196070#M20397</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-04-13T13:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Loading and positioning an object</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196071#M20398</link>
      <description>Try&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;at time 0 $.rotation.x_rotation.controller.value = 0.0&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;and likewise for the other lines.&lt;BR /&gt;&lt;BR /&gt;You can also speed thing up a bit, and do a lot less typing, by assigning the controllers to variables.&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;--set these up first&lt;BR /&gt;   xRotC = $.rotation.x_rotation.controller&lt;BR /&gt;   yRotC = $.rotation.y_rotation.controller&lt;BR /&gt;   zRotC = $.rotation.z_rotation.controller&lt;BR /&gt;&lt;BR /&gt;   with animate on&lt;BR /&gt;      (&lt;BR /&gt;      at time 0 $.pos = &lt;BR /&gt;      at time 0 xRotC.value = 0.0&lt;BR /&gt;      at time 0 yRotC.value = 99.8438&lt;BR /&gt;      at time 0 zRotC.value = 0.0&lt;BR /&gt; &lt;BR /&gt;      at time 25 $.pos = &lt;BR /&gt;      at time 25 xRotC.value = 0.0&lt;BR /&gt;      at time 25 yRotC.value = 99.8438&lt;BR /&gt;      at time 25 zRotC.value = 0.0 &lt;BR /&gt;      ) &lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Apr 2011 14:21:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196071#M20398</guid>
      <dc:creator>Steve_Curley</dc:creator>
      <dc:date>2011-04-13T14:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: Loading and positioning an object</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196072#M20399</link>
      <description>Thanks Steve... that works!&lt;BR /&gt;&lt;BR /&gt;The thing I don't get is that the code I published does too, but only sometimes it seems! I guess you couldn't explain to me why my code has problems on occasion?&lt;BR /&gt;&lt;BR /&gt;It's a good tip to assign the controllers to variables but I am hoping to automate this process with a perl script so typing won't be an issue once I've worked out how maxscripting works. I have tons of mel scripts which require translating to their maxscripts equivalent.&lt;BR /&gt;&lt;BR /&gt;Thanks once again.</description>
      <pubDate>Wed, 13 Apr 2011 14:40:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196072#M20399</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-04-13T14:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: Loading and positioning an object</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196073#M20400</link>
      <description>If I could, I would - hence my comment earlier about (not) being a genius &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;It's all to do with transform matrices (whatever they are). There's a bunch of stuff in the help about it/them and I'm certain they've been discuss in here as well.&lt;BR /&gt;&lt;BR /&gt;The assigning to a variable isn't just about speed of creating the script it's about the speed of execution. Max has to traverse the whole hierarchy from "$" down to get to the controller before it can assign the value. By doing that once and storing it the access is much faster.</description>
      <pubDate>Wed, 13 Apr 2011 15:00:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196073#M20400</guid>
      <dc:creator>Steve_Curley</dc:creator>
      <dc:date>2011-04-13T15:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Loading and positioning an object</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196074#M20401</link>
      <description>After lots of fiddling around with the rotation, it seems I've managed to get maxscript to replicate in 3DS Max what my mel script does in Maya. It seems quite simple now but there was a bit of head-scratching to get the rotations to match.&lt;BR /&gt;&lt;BR /&gt;Anyway for posterity and for other maxscript newbies, I'm going to post the maxscript equivalent to the my mel script example in my initial post:-&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;myobjects = #()&lt;BR /&gt;&lt;BR /&gt;importFile "C:\my_object.3ds" #noprompt&lt;BR /&gt;append objects $selection&lt;BR /&gt;alignPivot myobjects&lt;BR /&gt;&lt;BR /&gt;with animate on (&lt;BR /&gt;&lt;BR /&gt; select myobjects&lt;BR /&gt; at time 0 $.position=&lt;BR /&gt; at time 0 $.rotation.controller.x_rotation = 0.0&lt;BR /&gt; at time 0 $.rotation.controller.y_rotation = 99.8438 &lt;BR /&gt; at time 0 $.rotation.controller.z_rotation = 0.0&lt;BR /&gt;&lt;BR /&gt;)&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Going from Yup to Zup requires the object be rotated -90 around the x-axis in Max.&lt;BR /&gt;&lt;BR /&gt;Thanks to everybody for their help.</description>
      <pubDate>Fri, 15 Apr 2011 12:17:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/loading-and-positioning-an-object/m-p/4196074#M20401</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-04-15T12:17:20Z</dc:date>
    </item>
  </channel>
</rss>

