<?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: How to addNewComponenet using Transformation Matrix in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11909580#M3919</link>
    <description>&lt;P&gt;Yes, I think the CAD software outputting the matrix is slightly wrong. The determinant is&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;1.000000015592180721 when it should be 1 if it was Orthoginal (from my basic understanding). Thanks you everyone for your help.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Apr 2023 11:01:58 GMT</pubDate>
    <dc:creator>Joshua.mursic</dc:creator>
    <dc:date>2023-04-20T11:01:58Z</dc:date>
    <item>
      <title>How to addNewComponenet using Transformation Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11894391#M3913</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to add a component using a transformation matrix.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;newComponent = root.occurrences.addNewComponent(partMatrix)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to add a new component using the partmatrix I get the error:&lt;/P&gt;&lt;P&gt;RuntimeError: 3 : invalid argument transform&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the part Matrix in a dictionary called constructionData with the key "PartMatrix".&amp;nbsp; I tried to create a new matrix and then set it with the values of the partMatrix but this also errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;partMatrix:adsk.core.Matrix3D = constructionData["PartMatrix"]
mat= adsk.core.Matrix3D.create()
mat.setWithCoordinateSystem(partMatrix.getAsCoordinateSystem()[0],
                                        partMatrix.getAsCoordinateSystem()[1],                                                                                                                            
                                        partMatrix.getAsCoordinateSystem()[2],
                                        partMatrix.getAsCoordinateSystem()[3])
newComponent = root.occurrences.addNewComponent(mat)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I do this,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;partMatrix:adsk.core.Matrix3D = constructionData["PartMatrix"]
mat= adsk.core.Matrix3D.create()
transformMatrix.setToRotateTo(adsk.core.Vector3D.create(1,0,0),partMatrix.getAsCoordinateSystem()[1],adsk.core.Vector3D.create(1,0,0))
transformMatrix.setToRotateTo(adsk.core.Vector3D.create(0,1,0),partMatrix.getAsCoordinateSystem()[2],adsk.core.Vector3D.create(0,1,0))
transformMatrix.setToRotateTo(adsk.core.Vector3D.create(0,0,1),partMatrix.getAsCoordinateSystem()[3],adsk.core.Vector3D.create(0,0,1))
newComponent = root.occurrences.addNewComponent(mat)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to rotate the matrix. However because I am doing it in steps, the rotation is wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure why I am getting an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the matrix data as an array:&lt;/P&gt;&lt;P&gt;(-0.04609723612371068, 0.08869538091126858, 0.0028591374116374167, 0.0, 0.08869538091126858, 0.046153189469425746, -0.0017357773488455935, 0.0, -0.002859137411637416, 0.0017357773488455943, -0.09994404367405274, 0.0, 1.9448515944543634, 0.9751591343287863, 1.9185717820420838, 1.0)&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 18:57:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11894391#M3913</guid>
      <dc:creator>Joshua.mursic</dc:creator>
      <dc:date>2023-04-13T18:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to addNewComponenet using Transformation Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11894930#M3914</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Hi Mr JoshuaMursic,&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;... haven't analyzed all bits of the code but ... think about:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;STRONG&gt;transformMatrix.setToRotateTo(adsk.core.Vector3D.create(0,0,1),&lt;FONT color="#FF0000"&gt;partMatrix.getAsCoordinateSystem()[3]&lt;/FONT&gt;,adsk.core.Vector3D.create(0,0,1))&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Regards&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;MichaelT&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 23:26:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11894930#M3914</guid>
      <dc:creator>MichaelT_123</dc:creator>
      <dc:date>2023-04-13T23:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to addNewComponenet using Transformation Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11895088#M3915</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6490295"&gt;@Joshua.mursic&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A simple test was performed.&lt;BR /&gt;This one creates an occurrence without error.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Fusion360API Python script

import traceback
import adsk
import adsk.core as core
import adsk.fusion as fusion

def run(context):
    ui: core.UserInterface = None
    try:
        app: core.Application = core.Application.get()
        ui = app.userInterface
        des: fusion.Design = app.activeProduct
        root: fusion.Component = des.rootComponent

        mat: core.Matrix3D = adsk.core.Matrix3D.create()

        # https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-957d3c2d-294a-4fdb-8301-26ec31234655
        origin: core.Point3D = None
        xAxis: core.Vector3D = None
        yAxis: core.Vector3D = None
        zAxis: core.Vector3D = None
        origin, xAxis, yAxis, zAxis = mat.getAsCoordinateSystem()

        # https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-9a8c6abe-1b88-425a-b64c-cb0500554a5f
        mat.setWithCoordinateSystem(origin, xAxis, yAxis, zAxis)

        root.occurrences.addNewComponent(mat)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fix the size of xAxis so that it is half the size.&lt;/P&gt;
&lt;P&gt;This will cause an error when executed.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;・・・
        origin, xAxis, yAxis, zAxis = mat.getAsCoordinateSystem()

        xAxis.scaleBy(0.5)
・・・&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, the orientation of xAxis is corrected.&lt;/P&gt;
&lt;P&gt;This also causes an error when executed.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;・・・
        origin, xAxis, yAxis, zAxis = mat.getAsCoordinateSystem()

        xAxis.y += 1
        xAxis.normalize()
・・・&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So we see that the xyz vector is a unit vector and each axis must be perpendicular to the other.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 01:32:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11895088#M3915</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2023-04-14T01:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to addNewComponenet using Transformation Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11896216#M3916</link>
      <description>&lt;P&gt;I created the axis in the CAD environment using the matrix above.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Joshuamursic_0-1681475750844.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1202405i945DAAC976CB3BE4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Joshuamursic_0-1681475750844.png" alt="Joshuamursic_0-1681475750844.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;as you can see, all of the angles are perpendicular. So I do not know why the&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;root&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;occurrences&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;addNewComponent&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;partMatrix&lt;/SPAN&gt;&lt;SPAN&gt;) is giving errors.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am trying to import the part in at its position and then align it to the global coordinate system.&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 12:38:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11896216#M3916</guid>
      <dc:creator>Joshua.mursic</dc:creator>
      <dc:date>2023-04-14T12:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to addNewComponenet using Transformation Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11896921#M3917</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Joshuamursic_0-1681488496358.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1202506i0D0BF41CEA2587B4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Joshuamursic_0-1681488496358.png" alt="Joshuamursic_0-1681488496358.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I calculated the Determinant and it =&amp;nbsp;1.000000015592180721&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950"&gt;@kandennti&lt;/a&gt;&amp;nbsp;was correct and the matrix is not Orthogonal.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to normalize each axis:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;partCoordinate = partMatrix.getAsCoordinateSystem()
origin = partCoordinate[0]
xAxis = partCoordinate[1]
yAxis = partCoordinate[2]
zAxis = partCoordinate[3]

xAxis.normalize()
yAxis.normalize()
zAxis.normalize()

testMatrix = adsk.core.Matrix3D.create()
testMatrix.setWithCoordinateSystem(origin,xAxis,yAxis,zAxis)
newComponent = root.occurrences.addNewComponent(testMatrix)&lt;/LI-CODE&gt;&lt;P&gt;But this also fails.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the original data from the CAD output xml.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;&amp;lt;_00&amp;gt;-0.460972361237106780&amp;lt;/_00&amp;gt;
&amp;lt;_01&amp;gt;0.886953809112685840&amp;lt;/_01&amp;gt;
&amp;lt;_02&amp;gt;0.028591374116374167&amp;lt;/_02&amp;gt;
&amp;lt;_03&amp;gt;0&amp;lt;/_03&amp;gt;
&amp;lt;_10&amp;gt;0.886953809112685840&amp;lt;/_10&amp;gt;
&amp;lt;_11&amp;gt;0.461531894694257480&amp;lt;/_11&amp;gt;
&amp;lt;_12&amp;gt;-0.017357773488455935&amp;lt;/_12&amp;gt;
&amp;lt;_13&amp;gt;0&amp;lt;/_13&amp;gt;
&amp;lt;_20&amp;gt;-0.028591374116374160&amp;lt;/_20&amp;gt;
&amp;lt;_21&amp;gt;0.017357773488455942&amp;lt;/_21&amp;gt;
&amp;lt;_22&amp;gt;-0.999440436740527400&amp;lt;/_22&amp;gt;
&amp;lt;_23&amp;gt;0&amp;lt;/_23&amp;gt;
&amp;lt;_30&amp;gt;19.44851594454363300&amp;lt;/_30&amp;gt;
&amp;lt;_31&amp;gt;9.751591343287863400&amp;lt;/_31&amp;gt;
&amp;lt;_32&amp;gt;19.18571782042083700&amp;lt;/_32&amp;gt;
&amp;lt;_33&amp;gt;1&amp;lt;/_33&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I assumed that the xml elements were _00 for column 0 row 0 in the matrix. but none of the resulting vectors are normal.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 16:52:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11896921#M3917</guid>
      <dc:creator>Joshua.mursic</dc:creator>
      <dc:date>2023-04-14T16:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to addNewComponenet using Transformation Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11908390#M3918</link>
      <description>&lt;P&gt;If the matrix isn't orthogonal, the problem is with the code extracting the matrix information from the CAD model. One of your previous pictures shows the axes are perpendicular to each other but maybe it's being interpreted incorrectly to write out the matrix definition.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 23:14:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11908390#M3918</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2023-04-19T23:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to addNewComponenet using Transformation Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11909580#M3919</link>
      <description>&lt;P&gt;Yes, I think the CAD software outputting the matrix is slightly wrong. The determinant is&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;1.000000015592180721 when it should be 1 if it was Orthoginal (from my basic understanding). Thanks you everyone for your help.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 11:01:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-addnewcomponenet-using-transformation-matrix/m-p/11909580#M3919</guid>
      <dc:creator>Joshua.mursic</dc:creator>
      <dc:date>2023-04-20T11:01:58Z</dc:date>
    </item>
  </channel>
</rss>

