<?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: Find the transform from one occurence to it's parent in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-the-transform-from-one-occurence-to-it-s-parent/m-p/12713333#M1582</link>
    <description>&lt;P&gt;Sorry I made a mistake.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;・・・
        occ1: fusion.Occurrence = root.occurrences[0]
        occ2: fusion.Occurrence = occ1.component.occurrences[0]
        occ2 = occ2.createForAssemblyContext(occ1)
・・・&lt;/LI-CODE&gt;&lt;LI-CODE lang="general"&gt;Fusion360 Ver2.0.18950
occ1.transform2 : origin(1.0, 2.0, 3.0)_vecX(1.0, 0.0, 0.0)_vecY(0.0, 1.0, 0.0)_vecZ(0.0, 0.0, 1.0)
occ1.transform : origin(1.0, 2.0, 3.0)_vecX(1.0, 0.0, 0.0)_vecY(0.0, 1.0, 0.0)_vecZ(0.0, 0.0, 1.0)
occ2.transform2 : origin(2.0, 4.0, 6.0)_vecX(1.0, 0.0, 0.0)_vecY(0.0, 1.0, 0.0)_vecZ(0.0, 0.0, 1.0)
occ2.transform : origin(1.0, 2.0, 3.0)_vecX(1.0, 0.0, 0.0)_vecY(0.0, 1.0, 0.0)_vecZ(0.0, 0.0, 1.0)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;The transform2 property is working correctly.&lt;/P&gt;
&lt;P&gt;However, what you need is the transform property.&lt;/P&gt;</description>
    <pubDate>Wed, 17 Apr 2024 01:47:15 GMT</pubDate>
    <dc:creator>kandennti</dc:creator>
    <dc:date>2024-04-17T01:47:15Z</dc:date>
    <item>
      <title>Find the transform from one occurence to it's parent</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-the-transform-from-one-occurence-to-it-s-parent/m-p/12712794#M1579</link>
      <description>&lt;P&gt;More or less as the title says. I have several nested components in my design, and I need to find the transform from the parent component to it's child. I can do this easily for top level components to the root with occurence.transform2, how can I get a similar output for the nested ones to their parents?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 19:04:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-the-transform-from-one-occurence-to-it-s-parent/m-p/12712794#M1579</guid>
      <dc:creator>danielWNW3M</dc:creator>
      <dc:date>2024-04-16T19:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Find the transform from one occurence to it's parent</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-the-transform-from-one-occurence-to-it-s-parent/m-p/12713237#M1580</link>
      <description>&lt;P&gt;Let's say you have the following assembly and want to know the transformation between Subassembly1:1 and Part2:1. First; you need to have proxies of the two occurrences so when you get their current transformation using transform2; it will be relative to world space (or the base coordinate system in root).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Root&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;SubAssembly1:1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Part1:1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Subassembly2:1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Part2:1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Get the transforms of the two occurrences.
subAssembly1Trans = subAssembly1Occ.transform2
part2Trans = part2Occ.transform2

# Invert the transform of the occurrence higher up in the tree. This results
# in defining a matrix that if applied to the subassembly, will result in 
# an identity matrix which would position the assembly to the origin and
# aligned with the model X-Y-Z axes.
subAssembly1Trans.invert()

# Transform the other occurrence matrix using the inverted matrix. After
# this, part2Trans will define the transformation between the two
# occurrences.
part2Trans.transformBy(subAssembly1Trans)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 00:25:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-the-transform-from-one-occurence-to-it-s-parent/m-p/12713237#M1580</guid>
      <dc:creator>BrianEkinsADSK</dc:creator>
      <dc:date>2024-04-17T00:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: Find the transform from one occurence to it's parent</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-the-transform-from-one-occurence-to-it-s-parent/m-p/12713308#M1581</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11198104"&gt;@danielWNW3M&lt;/a&gt;&amp;nbsp;-San.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We created and tested simple data.&lt;/P&gt;
&lt;P&gt;The "ooc1" was moved X10mmY20mmZ30mm,&lt;BR /&gt;ooc2" is the data with X10mmY20mmZ30mm shifted further.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 605px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1350701i4186DE7F11140FE2/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;The following script was created and executed&lt;BR /&gt;The "transform" property is obsolete, but is still available in the current version 2.0.18950.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Fusion360API Python script

import traceback
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

        occ1: fusion.Occurrence = root.occurrences[0]
        occ2: fusion.Occurrence = occ1.component.occurrences[0]

        dump(f"Fusion360 Ver{app.version}")
        dump_matrix(occ1.transform2,"occ1.transform2")
        dump_matrix(occ1.transform,"occ1.transform")
        dump_matrix(occ2.transform2,"occ2.transform2")
        dump_matrix(occ2.transform,"occ2.transform")

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def dump_matrix(
        mat: core.Matrix3D,
        msg: str = ""
) -&amp;gt; None:
    origin, vecX, vecY, vecZ = mat.getAsCoordinateSystem()
    info = "".join(
        [
            f"{msg} : ",
            f"origin{origin.asArray()}_",
            f"vecX{vecX.asArray()}_",
            f"vecY{vecY.asArray()}_",
            f"vecZ{vecZ.asArray()}",
        ]
    )
    dump(info)


def dump(
    msg: str,
) -&amp;gt; None:

    print(msg)
    core.Application.get().log(msg)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the result of the execution.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Fusion360 Ver2.0.18950
occ1.transform2 : origin(1.0, 2.0, 3.0)_vecX(1.0, 0.0, 0.0)_vecY(0.0, 1.0, 0.0)_vecZ(0.0, 0.0, 1.0)
occ1.transform : origin(1.0, 2.0, 3.0)_vecX(1.0, 0.0, 0.0)_vecY(0.0, 1.0, 0.0)_vecZ(0.0, 0.0, 1.0)
occ2.transform2 : origin(0.0, 0.0, 0.0)_vecX(1.0, 0.0, 0.0)_vecY(0.0, 1.0, 0.0)_vecZ(0.0, 0.0, 1.0)
occ2.transform : origin(1.0, 2.0, 3.0)_vecX(1.0, 0.0, 0.0)_vecY(0.0, 1.0, 0.0)_vecZ(0.0, 0.0, 1.0)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the result I expected from occ2.transform2.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;occ2.transform2 : origin(2.0, 4.0, 6.0)_vecX(1.0, 0.0, 0.0)_vecY(0.0, 1.0, 0.0)_vecZ(0.0, 0.0, 1.0)&lt;/LI-CODE&gt;
&lt;P&gt;It is probably broken now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think what you are looking for is the "transform" property.&lt;BR /&gt;I don't think "transform" property should be obsolete because "transform" property and "transform2" property have different meanings.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 01:23:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-the-transform-from-one-occurence-to-it-s-parent/m-p/12713308#M1581</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2024-04-17T01:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: Find the transform from one occurence to it's parent</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-the-transform-from-one-occurence-to-it-s-parent/m-p/12713333#M1582</link>
      <description>&lt;P&gt;Sorry I made a mistake.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;・・・
        occ1: fusion.Occurrence = root.occurrences[0]
        occ2: fusion.Occurrence = occ1.component.occurrences[0]
        occ2 = occ2.createForAssemblyContext(occ1)
・・・&lt;/LI-CODE&gt;&lt;LI-CODE lang="general"&gt;Fusion360 Ver2.0.18950
occ1.transform2 : origin(1.0, 2.0, 3.0)_vecX(1.0, 0.0, 0.0)_vecY(0.0, 1.0, 0.0)_vecZ(0.0, 0.0, 1.0)
occ1.transform : origin(1.0, 2.0, 3.0)_vecX(1.0, 0.0, 0.0)_vecY(0.0, 1.0, 0.0)_vecZ(0.0, 0.0, 1.0)
occ2.transform2 : origin(2.0, 4.0, 6.0)_vecX(1.0, 0.0, 0.0)_vecY(0.0, 1.0, 0.0)_vecZ(0.0, 0.0, 1.0)
occ2.transform : origin(1.0, 2.0, 3.0)_vecX(1.0, 0.0, 0.0)_vecY(0.0, 1.0, 0.0)_vecZ(0.0, 0.0, 1.0)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;The transform2 property is working correctly.&lt;/P&gt;
&lt;P&gt;However, what you need is the transform property.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 01:47:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-the-transform-from-one-occurence-to-it-s-parent/m-p/12713333#M1582</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2024-04-17T01:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: Find the transform from one occurence to it's parent</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-the-transform-from-one-occurence-to-it-s-parent/m-p/12715469#M1583</link>
      <description>&lt;P&gt;Thanks for the help! I ended up using transform 2 on the object and it's parent, inverting the parent, and using transformBy to get the transform between the two, as suggested by&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/9022460"&gt;@BrianEkinsADSK&lt;/a&gt;. and it's working just as I'd hoped.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 18:37:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-the-transform-from-one-occurence-to-it-s-parent/m-p/12715469#M1583</guid>
      <dc:creator>danielWNW3M</dc:creator>
      <dc:date>2024-04-17T18:37:48Z</dc:date>
    </item>
  </channel>
</rss>

