<?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: Rounding Issues With A Matrix in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13051173#M772</link>
    <description>&lt;P&gt;I also just got an instance where this was the logged fixed matrix and it still errored? Any help would be greatly appreciated, I have no idea why this would give an error.&lt;/P&gt;&lt;LI-CODE lang="python"&gt; Fixed Matrix
 asArray: (-0.28937833718712835, -0.92790170939954, 0.23507146926036046, -1.8945223767122557, -0.9572147900317696, 0.2804771032288191, -0.07122106646776495, -0.058936886759475254, -0.00015398457080906255, 0.2456237208776513, 0.9693652376844187, 0.890460203796084, 0.0, 0.0, 0.0, 1.0)
 X length = 1.0
 Y length = 1.0
 Z length = 1.0
 XY Angle = 90.0
 XZ Angle = 90.0
 YZ Angle = 90.0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is how I am transforming the sketches&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for sketch in occurrence.component.sketches:
     mat = sketch.transform
     mat.transformBy(transformationMatrix)
     mat = forcePlanar(mat)
     sketch.transform = mat&lt;/LI-CODE&gt;</description>
    <pubDate>Sat, 28 Sep 2024 01:14:58 GMT</pubDate>
    <dc:creator>Joshua.mursic</dc:creator>
    <dc:date>2024-09-28T01:14:58Z</dc:date>
    <item>
      <title>Rounding Issues With A Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13051166#M771</link>
      <description>&lt;P&gt;I am getting this error when trying to perform a transform on a sketch.&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;RuntimeError: 2 : InternalValidationError : xlMat-&amp;gt;isValidNonScaledTransformMatrix()&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;I made this to try and force the matrix to by valid&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;def forcePlanar(matrix:adsk.core.Matrix3D):
    o,x,y,z = matrix.getAsCoordinateSystem()

    app.log("Original Matrix")
    app.log(f'asArray: {matrix.asArray()}')
    app.log(f'X length = {x.length}')
    app.log(f'Y length = {y.length}')
    app.log(f'Z length = {z.length}')
    app.log(f'XY Angle = {math.degrees(x.angleTo(y))}')
    app.log(f'XZ Angle = {math.degrees(x.angleTo(z))}')
    app.log(f'YZ Angle = {math.degrees(y.angleTo(z))}')
    app.log(" ")

    x.normalize()
    y.normalize()
    z.normalize()

    xVec = y.crossProduct(z)
    if math.degrees(xVec.angleTo(x)) &amp;gt; 90:
        xVec.scaleBy(-1)
        xVec.normalize()
    
    yVec = xVec.crossProduct(z)
    if math.degrees(yVec.angleTo(y)) &amp;gt; 90:
        yVec.scaleBy(-1)
        yVec.normalize()
    
    zVec = xVec.crossProduct(yVec)
    if math.degrees(zVec.angleTo(z)) &amp;gt; 90:
        zVec.scaleBy(-1)
        zVec.normalize()

    xVec.normalize()
    yVec.normalize()
    zVec.normalize()

    matrix = adsk.core.Matrix3D.create()
    matrix.setWithCoordinateSystem(o,xVec,yVec,zVec)

    app.log("Fixed Matrix")
    app.log(f'asArray: {matrix.asArray()}')
    app.log(f'X length = {xVec.length}')
    app.log(f'Y length = {yVec.length}')
    app.log(f'Z length = {zVec.length}')
    app.log(f'XY Angle = {math.degrees(xVec.angleTo(yVec))}')
    app.log(f'XZ Angle = {math.degrees(xVec.angleTo(zVec))}')
    app.log(f'YZ Angle = {math.degrees(yVec.angleTo(zVec))}')

    return matrix&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 I am still getting this error:&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; Original Matrix
 asArray: (-0.9866242022022309, 0.1492357286775443, -0.06558491377514467, 2.5736278824387266, 0.15800404365975573, 0.9744559705989259, -0.15959412129295647, -0.7649845830225152, -0.040092465825598715, 0.16782210417637858, 0.9850016931629284, 1.7089296320501064, 0.0, 0.0, 0.0, 1.0)
 X length = 0.9999999999999997
 Y length = 0.9999999999999998
 Z length = 0.9999999999999999
 XY Angle = 90.0
 XZ Angle = 90.0
 YZ Angle = 90.0
  
 Fixed Matrix
 asArray: (-0.9866242022022313, 0.14923572867754434, -0.06558491377514467, 2.5736278824387266, 0.15800404365975573, 0.9744559705989261, -0.1595941212929565, -0.7649845830225152, -0.04009246582559872, 0.1678221041763786, 0.9850016931629284, 1.7089296320501064, 0.0, 0.0, 0.0, 1.0)
 X length = 1.0
 Y length = 1.0
 Z length = 0.9999999999999999
 XY Angle = 90.0
 XZ Angle = 90.0
 YZ Angle = 90.0

Failed:
Traceback (most recent call last):
line 346, in transformSketch:
sketch.transform = matrix
^^^^^^^^^^^^^^^^

File "C:\......\adsk\fusion.py", line 45318, in _set_transform
return _fusion.Sketch__set_transform(self, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: 2 : InternalValidationError : xlMat-&amp;gt;isValidNonScaledTransformMatrix()&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;Am I doing something wrong here? I am not sure how to stop the vectors from being ever so slightly not unit length.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2024 01:07:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13051166#M771</guid>
      <dc:creator>Joshua.mursic</dc:creator>
      <dc:date>2024-09-28T01:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Issues With A Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13051173#M772</link>
      <description>&lt;P&gt;I also just got an instance where this was the logged fixed matrix and it still errored? Any help would be greatly appreciated, I have no idea why this would give an error.&lt;/P&gt;&lt;LI-CODE lang="python"&gt; Fixed Matrix
 asArray: (-0.28937833718712835, -0.92790170939954, 0.23507146926036046, -1.8945223767122557, -0.9572147900317696, 0.2804771032288191, -0.07122106646776495, -0.058936886759475254, -0.00015398457080906255, 0.2456237208776513, 0.9693652376844187, 0.890460203796084, 0.0, 0.0, 0.0, 1.0)
 X length = 1.0
 Y length = 1.0
 Z length = 1.0
 XY Angle = 90.0
 XZ Angle = 90.0
 YZ Angle = 90.0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is how I am transforming the sketches&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for sketch in occurrence.component.sketches:
     mat = sketch.transform
     mat.transformBy(transformationMatrix)
     mat = forcePlanar(mat)
     sketch.transform = mat&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 28 Sep 2024 01:14:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13051173#M772</guid>
      <dc:creator>Joshua.mursic</dc:creator>
      <dc:date>2024-09-28T01:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Issues With A Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13051820#M773</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;-San.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is that process done in direct mode?&lt;/P&gt;
&lt;P&gt;It is stated that a normal sketch in parametric mode will fail.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 716px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1415525i4D4A541CA15E52DE/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-7b5689f8-c8a6-492f-b9a1-4bcbfe289505" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-7b5689f8-c8a6-492f-b9a1-4bcbfe289505&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2024 14:24:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13051820#M773</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2024-09-28T14:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Issues With A Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13051830#M774</link>
      <description>&lt;P&gt;it is in direct modelling mode&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2024 14:34:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13051830#M774</guid>
      <dc:creator>Joshua.mursic</dc:creator>
      <dc:date>2024-09-28T14:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Issues With A Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13052065#M775</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also get the same error trying to transform a component.&lt;/P&gt;&lt;P&gt;Something is not good in that matrix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How did you get that matrix?&lt;/P&gt;&lt;P&gt;There is a way to rebuild it from scratch (like rotate N° on X axis, then M° o Y, and so on) and not from the values you posted previously?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jorge&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2024 19:06:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13052065#M775</guid>
      <dc:creator>Jorge_Jaramillo</dc:creator>
      <dc:date>2024-09-28T19:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Issues With A Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13053027#M776</link>
      <description>&lt;P&gt;I am not very familiar with matrices yet, but I think that the issue might be something like this. Where the angles are all 90 and the vectors are of unit length, but the X vector is pointing in the negative direction. I am not sure if this makes a difference or not. I am going to change the functions that are creating the transformation matrices. Thank you everyone for the help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Joshuamursic_0-1727623902056.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1415712i47E1D91F6B376667/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Joshuamursic_0-1727623902056.png" alt="Joshuamursic_0-1727623902056.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Sep 2024 15:31:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13053027#M776</guid>
      <dc:creator>Joshua.mursic</dc:creator>
      <dc:date>2024-09-29T15:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Issues With A Matrix</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13055078#M777</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6490295"&gt;@Joshua.mursic&lt;/a&gt;&amp;nbsp;-San.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I haven't tried it, but I don't think Fusion360 supports left-handed coordinate systems.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2024 14:53:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rounding-issues-with-a-matrix/m-p/13055078#M777</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2024-09-30T14:53:28Z</dc:date>
    </item>
  </channel>
</rss>

