<?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 How to Move and Rotate Bodies? in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-move-and-rotate-bodies/m-p/12971341#M170964</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I'm working on a project where I need to find the plane with the largest area and use its normal vector as the Z-axis to establish a User Coordinate System (UCS). My next step is to rotate and move the skewed bodies (i.e., the models that are not aligned) into another coordinate system. However, I haven't been able to find any relevant API or examples that could help me achieve this. Could someone please provide some guidance?&lt;/P&gt;&lt;P&gt;Here's the code I have so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN&gt;/// Aligns all bodies based on the plane with the largest area.&lt;/SPAN&gt;
&lt;SPAN&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN&gt;/// &amp;lt;param name="doc"&amp;gt;The PartDocument containing the model.&amp;lt;/param&amp;gt;&lt;/SPAN&gt;
&lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;static&lt;/SPAN&gt; &lt;SPAN&gt;void&lt;/SPAN&gt;&lt;SPAN&gt; CorrectTheModel(PartDocument doc)&lt;/SPAN&gt;{
    &lt;SPAN&gt;// Get the plane with the largest area.&lt;/SPAN&gt;
&lt;SPAN&gt;    Plane maxFace = GetMaxAreaFace(doc).Geometry &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt; Plane;&lt;/SPAN&gt;    ComponentDefinition oCompDef = doc.ComponentDefinition;

    &lt;SPAN&gt;// Get the normal vector of the plane with the largest area.&lt;/SPAN&gt;
    &lt;SPAN&gt;double&lt;/SPAN&gt;&lt;SPAN&gt;[] normals = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;double&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;3&lt;/SPAN&gt;&lt;SPAN&gt;];&lt;/SPAN&gt;&lt;SPAN&gt;    maxFace.Evaluator.GetNormal(&lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;double&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;], ref normals);&lt;/SPAN&gt;
    &lt;SPAN&gt;double&lt;/SPAN&gt;&lt;SPAN&gt;[] points = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;double&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;3&lt;/SPAN&gt;&lt;SPAN&gt;];&lt;/SPAN&gt;&lt;SPAN&gt;    maxFace.Evaluator.GetPointAtParam(&lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;double&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;] { &lt;/SPAN&gt;&lt;SPAN class=""&gt;0.5&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN class=""&gt;0.5&lt;/SPAN&gt;&lt;SPAN&gt; }, ref points);&lt;/SPAN&gt;&lt;SPAN&gt;    Application ThisApplication = doc.&lt;/SPAN&gt;&lt;SPAN&gt;Parent&lt;/SPAN&gt; &lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt; Application;&lt;/SPAN&gt;
    &lt;SPAN&gt;// Create the Z-axis vector.&lt;/SPAN&gt;
    &lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; VectorZ = ThisApplication.TransientGeometry.CreateVector(normals[&lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;], normals[&lt;/SPAN&gt;&lt;SPAN class=""&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;], normals[&lt;/SPAN&gt;&lt;SPAN class=""&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;]);&lt;/SPAN&gt;    &lt;SPAN&gt;// Create the Y-axis vector.&lt;/SPAN&gt;
    &lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; VectorY = ThisApplication.TransientGeometry.CreateVector(&lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN class=""&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;
    &lt;SPAN&gt;// Calculate the X-axis vector.&lt;/SPAN&gt;
    &lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; VectorX = VectorY.CrossProduct(VectorZ);&lt;/SPAN&gt;
    &lt;SPAN&gt;// Create the origin point.&lt;/SPAN&gt;
&lt;SPAN&gt;    Point Origin = ThisApplication.TransientGeometry.CreatePoint(points[&lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;], points[&lt;/SPAN&gt;&lt;SPAN class=""&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;], points[&lt;/SPAN&gt;&lt;SPAN class=""&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;]);&lt;/SPAN&gt;
    &lt;SPAN&gt;// Create a transformation matrix for the new coordinate system.&lt;/SPAN&gt;
    Matrix newMatrix = ThisApplication.TransientGeometry.CreateMatrix();
   newMatrix.SetCoordinateSystem(Origin, VectorX, VectorY, VectorZ);

    &lt;SPAN&gt;// Define the new UCS.&lt;/SPAN&gt;
    &lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; oUCSDef = oCompDef.UserCoordinateSystems.CreateDefinition();&lt;/SPAN&gt;
    oUCSDef.Transformation = newMatrix;

    &lt;SPAN&gt;// Add the new UCS to the component definition.&lt;/SPAN&gt;
    oCompDef.UserCoordinateSystems.Add(oUCSDef);

    &lt;SPAN&gt;foreach&lt;/SPAN&gt;&lt;SPAN&gt; (SurfaceBody body in doc.ComponentDefinition.SurfaceBodies)&lt;/SPAN&gt;    {
        &lt;SPAN&gt;// Here is where I need help: how can I perform a coordinate system to coordinate system trans       formation for all the bodies?&lt;/SPAN&gt;
    }
}&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Aug 2024 03:53:23 GMT</pubDate>
    <dc:creator>huyc2GQZL</dc:creator>
    <dc:date>2024-08-21T03:53:23Z</dc:date>
    <item>
      <title>How to Move and Rotate Bodies?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-move-and-rotate-bodies/m-p/12971341#M170964</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I'm working on a project where I need to find the plane with the largest area and use its normal vector as the Z-axis to establish a User Coordinate System (UCS). My next step is to rotate and move the skewed bodies (i.e., the models that are not aligned) into another coordinate system. However, I haven't been able to find any relevant API or examples that could help me achieve this. Could someone please provide some guidance?&lt;/P&gt;&lt;P&gt;Here's the code I have so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN&gt;/// Aligns all bodies based on the plane with the largest area.&lt;/SPAN&gt;
&lt;SPAN&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN&gt;/// &amp;lt;param name="doc"&amp;gt;The PartDocument containing the model.&amp;lt;/param&amp;gt;&lt;/SPAN&gt;
&lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;static&lt;/SPAN&gt; &lt;SPAN&gt;void&lt;/SPAN&gt;&lt;SPAN&gt; CorrectTheModel(PartDocument doc)&lt;/SPAN&gt;{
    &lt;SPAN&gt;// Get the plane with the largest area.&lt;/SPAN&gt;
&lt;SPAN&gt;    Plane maxFace = GetMaxAreaFace(doc).Geometry &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt; Plane;&lt;/SPAN&gt;    ComponentDefinition oCompDef = doc.ComponentDefinition;

    &lt;SPAN&gt;// Get the normal vector of the plane with the largest area.&lt;/SPAN&gt;
    &lt;SPAN&gt;double&lt;/SPAN&gt;&lt;SPAN&gt;[] normals = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;double&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;3&lt;/SPAN&gt;&lt;SPAN&gt;];&lt;/SPAN&gt;&lt;SPAN&gt;    maxFace.Evaluator.GetNormal(&lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;double&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;], ref normals);&lt;/SPAN&gt;
    &lt;SPAN&gt;double&lt;/SPAN&gt;&lt;SPAN&gt;[] points = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;double&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;3&lt;/SPAN&gt;&lt;SPAN&gt;];&lt;/SPAN&gt;&lt;SPAN&gt;    maxFace.Evaluator.GetPointAtParam(&lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;double&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;] { &lt;/SPAN&gt;&lt;SPAN class=""&gt;0.5&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN class=""&gt;0.5&lt;/SPAN&gt;&lt;SPAN&gt; }, ref points);&lt;/SPAN&gt;&lt;SPAN&gt;    Application ThisApplication = doc.&lt;/SPAN&gt;&lt;SPAN&gt;Parent&lt;/SPAN&gt; &lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt; Application;&lt;/SPAN&gt;
    &lt;SPAN&gt;// Create the Z-axis vector.&lt;/SPAN&gt;
    &lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; VectorZ = ThisApplication.TransientGeometry.CreateVector(normals[&lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;], normals[&lt;/SPAN&gt;&lt;SPAN class=""&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;], normals[&lt;/SPAN&gt;&lt;SPAN class=""&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;]);&lt;/SPAN&gt;    &lt;SPAN&gt;// Create the Y-axis vector.&lt;/SPAN&gt;
    &lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; VectorY = ThisApplication.TransientGeometry.CreateVector(&lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN class=""&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;
    &lt;SPAN&gt;// Calculate the X-axis vector.&lt;/SPAN&gt;
    &lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; VectorX = VectorY.CrossProduct(VectorZ);&lt;/SPAN&gt;
    &lt;SPAN&gt;// Create the origin point.&lt;/SPAN&gt;
&lt;SPAN&gt;    Point Origin = ThisApplication.TransientGeometry.CreatePoint(points[&lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;], points[&lt;/SPAN&gt;&lt;SPAN class=""&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;], points[&lt;/SPAN&gt;&lt;SPAN class=""&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;]);&lt;/SPAN&gt;
    &lt;SPAN&gt;// Create a transformation matrix for the new coordinate system.&lt;/SPAN&gt;
    Matrix newMatrix = ThisApplication.TransientGeometry.CreateMatrix();
   newMatrix.SetCoordinateSystem(Origin, VectorX, VectorY, VectorZ);

    &lt;SPAN&gt;// Define the new UCS.&lt;/SPAN&gt;
    &lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; oUCSDef = oCompDef.UserCoordinateSystems.CreateDefinition();&lt;/SPAN&gt;
    oUCSDef.Transformation = newMatrix;

    &lt;SPAN&gt;// Add the new UCS to the component definition.&lt;/SPAN&gt;
    oCompDef.UserCoordinateSystems.Add(oUCSDef);

    &lt;SPAN&gt;foreach&lt;/SPAN&gt;&lt;SPAN&gt; (SurfaceBody body in doc.ComponentDefinition.SurfaceBodies)&lt;/SPAN&gt;    {
        &lt;SPAN&gt;// Here is where I need help: how can I perform a coordinate system to coordinate system trans       formation for all the bodies?&lt;/SPAN&gt;
    }
}&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Aug 2024 03:53:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-move-and-rotate-bodies/m-p/12971341#M170964</guid>
      <dc:creator>huyc2GQZL</dc:creator>
      <dc:date>2024-08-21T03:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to Move and Rotate Bodies?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-move-and-rotate-bodies/m-p/12971601#M170968</link>
      <description>&lt;P&gt;I don't understand the purpose of this feature. Can you post some screenshot what do you expect?&lt;/P&gt;&lt;P&gt;But in general. There are limited possibilities of manipulating surface bodies in part. Much easier can be to create new assembly and parts from bodies and place them to this assembly. Or you can create new part where you can create copy of original bodies with given transformation. Here is the &lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-8B91A087-4399-4327-A97E-B65F482CBD9B" target="_blank"&gt;sample in VBA&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 07:13:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-move-and-rotate-bodies/m-p/12971601#M170968</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2024-08-21T07:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to Move and Rotate Bodies?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-move-and-rotate-bodies/m-p/12971625#M170969</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank you for your response! The &lt;/SPAN&gt;NonParametricBaseFeatures&lt;SPAN&gt; function creates independent surfaces after running, but what I'm aiming for is more similar to the native Inventor functionality: moving solid bodies.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="huyc2GQZL_0-1724225431064.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1400194i5AD72CF50831D0E1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="huyc2GQZL_0-1724225431064.png" alt="huyc2GQZL_0-1724225431064.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 07:32:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-move-and-rotate-bodies/m-p/12971625#M170969</guid>
      <dc:creator>huyc2GQZL</dc:creator>
      <dc:date>2024-08-21T07:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to Move and Rotate Bodies?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-move-and-rotate-bodies/m-p/12971746#M170972</link>
      <description>&lt;P&gt;This is represented in API as&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-6752E8DF-9300-4B38-9859-18822E91F96A" target="_blank" rel="noopener"&gt;MoveFeature&lt;/A&gt;. There is no problem to translate part in space, but it is hard to define its rotation.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 12:16:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-move-and-rotate-bodies/m-p/12971746#M170972</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2024-08-21T12:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to Move and Rotate Bodies?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-move-and-rotate-bodies/m-p/12974327#M171030</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Yes, I have discovered no other means to wrap a function for the automatic matrix transformation of the entity.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for reply&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 08:58:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-move-and-rotate-bodies/m-p/12974327#M171030</guid>
      <dc:creator>huyc2GQZL</dc:creator>
      <dc:date>2024-08-22T08:58:13Z</dc:date>
    </item>
  </channel>
</rss>

