<?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: Inconsistency between Matrix3D.translation documentation and actual behavior in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6728744#M19138</link>
    <description>&lt;P&gt;Good news! We are getting this fixed in the next update coming this December!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 05 Dec 2016 19:15:54 GMT</pubDate>
    <dc:creator>keqingsong</dc:creator>
    <dc:date>2016-12-05T19:15:54Z</dc:date>
    <item>
      <title>Inconsistency between Matrix3D.translation documentation and actual behavior</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6647777#M19133</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Based on Matrix3D.translation documentation:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;it "Gets and sets the translation component of the matrix"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but setting it actually resets the&amp;nbsp;matrix to an identify matrix, then sets the translation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is a code block showing this inconsistency:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import adsk.core, adsk.fusion, adsk.cam, traceback, math

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        transform = adsk.core.Matrix3D.create()
        transform.setToRotation(math.pi/3, adsk.core.Vector3D.create(0, 1, 0), adsk.core.Point3D.create(0, 0, 0))
        ui.messageBox(str(transform.asArray()))
        transform.translation = adsk.core.Vector3D.create(20, 20, 20)
        ui.messageBox(str(transform.asArray()))

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The following picture shows the result:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Capture_09.png" style="width: 413px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/286111i5B4D18196BBD0C0B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture_09.png" alt="Capture_09.png" /&gt;&lt;/span&gt;﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Navid&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2016 19:18:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6647777#M19133</guid>
      <dc:creator>nnikbin</dc:creator>
      <dc:date>2016-10-26T19:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistency between Matrix3D.translation documentation and actual behavior</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6649652#M19134</link>
      <description>&lt;P&gt;Hi Navid,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can share my script that creates copy of component in the active document. There is also Matrix3D.translation and it works as expected. So you can use it for your propose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It modifies translation matrix by setCell method&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;trans.setCell(0, 3, 15.0);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jan (Autodesk Fusion 360 team)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//Author-JP&lt;BR /&gt;//Description-tocite schody&lt;/P&gt;
&lt;P&gt;function run(context) {&lt;/P&gt;
&lt;P&gt;"use strict";&lt;BR /&gt; if (adsk.debug === true) {&lt;BR /&gt; /*jslint debug: true*/&lt;BR /&gt; debugger;&lt;BR /&gt; /*jslint debug: false*/&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; var ui;&lt;BR /&gt; try {&lt;BR /&gt; var app = adsk.core.Application.get();&lt;BR /&gt; ui = app.userInterface;&lt;BR /&gt; &lt;BR /&gt; var product = app.activeProduct;&lt;BR /&gt; var design = adsk.fusion.Design(product);&lt;BR /&gt; if (!design) {&lt;BR /&gt; ui.messageBox('No active Fusion design', 'No Design');&lt;BR /&gt; return;&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; // Get the root component of the active design. &lt;BR /&gt; var rootComp = design.rootComponent;&lt;BR /&gt; var occs = rootComp.allOccurrences;&lt;BR /&gt; &lt;BR /&gt; // Gather information about each unique component&lt;BR /&gt; var count = occs.count;&lt;BR /&gt; ui.messageBox(count.toString(), 'pocet');&lt;BR /&gt; &lt;BR /&gt; //jmena vsech component&lt;BR /&gt; var i;&lt;BR /&gt; for (i = 0;i &amp;lt; count;++i) {&lt;BR /&gt; var comp = occs.item(i).component;&lt;BR /&gt; ui.messageBox(comp.name, 'jmeno');&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; //var comp = occs.item(0).component;&lt;BR /&gt; //var jmeno = comp.name&lt;BR /&gt; //ui.messageBox(jmeno,'jmeno');&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; // Create a new occurrence. &lt;BR /&gt; var trans = adsk.core.Matrix3D.create();&lt;BR /&gt; //var occ = rootComp.occurrences.addNewComponent(trans);&lt;/P&gt;
&lt;P&gt;// Get the associated component. &lt;BR /&gt; //var newComp = occs.item(i).component;&lt;BR /&gt; //var newComp = occ.component;&lt;/P&gt;
&lt;P&gt;// Create a new occurrence for the component, offset by 15 cm in the X direction. &lt;BR /&gt; &lt;STRONG&gt;trans.setCell(0, 3, 15.0);&lt;/STRONG&gt;&lt;BR /&gt; var newOcc = rootComp.occurrences.addExistingComponent(occs.item(0).component, trans);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; &lt;BR /&gt; //ui.messageBox('Hello script'); &lt;BR /&gt; } &lt;BR /&gt; catch (e) {&lt;BR /&gt; if (ui) {&lt;BR /&gt; ui.messageBox('Failed : ' + (e.description ? e.description : e));&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;adsk.terminate(); &lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2016 13:10:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6649652#M19134</guid>
      <dc:creator>jan_priban</dc:creator>
      <dc:date>2016-10-27T13:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistency between Matrix3D.translation documentation and actual behavior</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6649951#M19135</link>
      <description>&lt;P&gt;Thank you for reporting this. &amp;nbsp;This is not expected behavior and I've logged a bug for the problem. &amp;nbsp;Following up with Jan's response, a workaround is to set the specific cells of the matrix that define the translation. &amp;nbsp;Here's a modified version of your code that creates the correct result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;import adsk.core, adsk.fusion, adsk.cam, traceback
import math

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        transform = adsk.core.Matrix3D.create()
        transform.setToRotation(math.pi/3, adsk.core.Vector3D.create(0, 1, 0), adsk.core.Point3D.create(0, 0, 0))
        ui.messageBox(str(transform.asArray()))
        
        &lt;FONT color="#0000FF"&gt;#transform.translation = adsk.core.Vector3D.create(20, 20, 20)&lt;/FONT&gt;
        transform.setCell(0, 3, 20) &lt;FONT color="#0000FF"&gt;# X component of translate&lt;/FONT&gt;
        transform.setCell(1, 3, 20) &lt;FONT color="#0000FF"&gt;# Y component of translate&lt;/FONT&gt;
        transform.setCell(2, 3, 20) &lt;FONT color="#0000FF"&gt;# Z component of translate&lt;/FONT&gt;
        ui.messageBox(str(transform.asArray()))

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Oct 2016 14:03:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6649951#M19135</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2016-10-27T14:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistency between Matrix3D.translation documentation and actual behavior</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6650080#M19136</link>
      <description>&lt;P&gt;Hi Brian,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for logging the bug. I was aware of the workaround by using setcell. I just wanted to report the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Navid&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2016 14:22:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6650080#M19136</guid>
      <dc:creator>nnikbin</dc:creator>
      <dc:date>2016-10-27T14:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistency between Matrix3D.translation documentation and actual behavior</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6650141#M19137</link>
      <description>&lt;P&gt;Hi Jan,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply,&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/483052"&gt;@jan.priban&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;There is also Matrix3D.translation and it works as expected.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As Brian confirmed, &amp;nbsp;"&lt;SPAN&gt;This is not expected behavior"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Navid&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2016 14:32:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6650141#M19137</guid>
      <dc:creator>nnikbin</dc:creator>
      <dc:date>2016-10-27T14:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistency between Matrix3D.translation documentation and actual behavior</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6728744#M19138</link>
      <description>&lt;P&gt;Good news! We are getting this fixed in the next update coming this December!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 19:15:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6728744#M19138</guid>
      <dc:creator>keqingsong</dc:creator>
      <dc:date>2016-12-05T19:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistency between Matrix3D.translation documentation and actual behavior</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6729761#M19139</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Keqing,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your good news &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Navid&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2016 06:21:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/inconsistency-between-matrix3d-translation-documentation-and/m-p/6729761#M19139</guid>
      <dc:creator>nnikbin</dc:creator>
      <dc:date>2016-12-06T06:21:43Z</dc:date>
    </item>
  </channel>
</rss>

