<?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: Error while setting transform in Occurrences.addNewComponentCopy in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11623746#M4859</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950"&gt;@kandennti&lt;/a&gt;&amp;nbsp;thank you again for spending so much time on this.&amp;nbsp; I hadn't even heard of text commands before, so I'm delighted at this workaround.&amp;nbsp; Hopefully a solution for the original addNewComponentCopy issue will soon reveal itself, but in the meantime, I'm more than satisfied at making it work this way.&amp;nbsp; Thanks again!&lt;/P&gt;</description>
    <pubDate>Thu, 15 Dec 2022 22:12:59 GMT</pubDate>
    <dc:creator>brent.hagany</dc:creator>
    <dc:date>2022-12-15T22:12:59Z</dc:date>
    <item>
      <title>Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11610437#M4848</link>
      <description>&lt;P&gt;I'm pretty new to the API, and only barely understand proxies, so I'm hoping that there is a simple solution that I've overlooked.&amp;nbsp; When I am dealing with occurrences that are direct children of the root component, I have no issues with setting their transform2 properties directly, or with adding new component copies via the Occurrences.addNewComponentCopy method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I am dealing with occurrences that are nested within other occurrences (that is, not direct children of the root component), I begin to encounter issues with transform2.&amp;nbsp; I believe I have figured out how to make this work using a proxy occurrence when setting transform2 directly, but I get the same transform error when using addNewComponentCopy in a nested occurrence, and I don't see a way around this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've created a minimal script that demonstrates the problem:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;import adsk.core, adsk.fusion, traceback, math


def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        ###
        # setting up parent and child occurrences / components
        ###
        rootComponent = app.activeProduct.rootComponent
        parentOccurrence = rootComponent.occurrences.addNewComponent(adsk.core.Matrix3D.create())
        parentComponent = parentOccurrence.component
        childOccurrence = parentComponent.occurrences.addNewComponent(adsk.core.Matrix3D.create())


        ###
        # here's the demonstration part
        ###

        # setting transform works
        childOccurrence.transform = adsk.core.Matrix3D.create()

        # setting transform2 fails with
        # "RuntimeError: 3 : transform overrides can only be set on Occurrence proxy from root component"
        childOccurrence.transform2 = adsk.core.Matrix3D.create()

        # setting transform2 won't work unless I create a proxy occurrence
        # this works, but I'm not sure it's completely correct
        childOccurrenceProxy = childOccurrence.createForAssemblyContext(parentOccurrence)
        childOccurrenceProxy.transform2 = adsk.core.Matrix3D.create()

        # however, using addNewComponentCopy fails with the same error as
        # setting transform2 without a proxy
        childOccurrenceCopy = parentComponent.occurrences.addNewComponentCopy(
            childOccurrenceProxy.component,
            adsk.core.Matrix3D.create())
    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;The error I get (if you comment out the first naive attempt to set transform2) is this:&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="brenthagany_0-1670627152376.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1150770iD078BA743EAF3F26/image-size/medium?v=v2&amp;amp;px=400" role="button" title="brenthagany_0-1670627152376.png" alt="brenthagany_0-1670627152376.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any insight about how to work around this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Brent&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2022 23:06:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11610437#M4848</guid>
      <dc:creator>brent.hagany</dc:creator>
      <dc:date>2022-12-09T23:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11610661#M4849</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11993867"&gt;@brent.hagany&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think your understanding of proxies is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did a little testing.&lt;/P&gt;
&lt;P&gt;Running the following script will end up with the image.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Fusion360API Python script
import traceback
import adsk.fusion
import adsk.core

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        mat: adsk.core.Matrix3D = adsk.core.Matrix3D.create()
        mat.translation = adsk.core.Vector3D.create(-1,-1,-1)

        rootComponent: adsk.fusion.Component = app.activeProduct.rootComponent
        rootComponent.isOriginFolderLightBulbOn = True

        parentOccurrence: adsk.fusion.Occurrence = rootComponent.occurrences.addNewComponent(
            mat
        )
        parentComponent: adsk.fusion.Component = parentOccurrence.component
        parentComponent.isOriginFolderLightBulbOn = True

        childOccurrence: adsk.fusion.Occurrence  = parentComponent.occurrences.addNewComponent(
            mat
        )
        childOccurrence.component.isOriginFolderLightBulbOn = True

        print(f'version:{app.version}\n')
        dumpMatrix3D('**childOccurrence.transform**', childOccurrence.transform)
        dumpMatrix3D('**childOccurrence.transform2**', childOccurrence.transform2)
        print(f'**childOccurrence.name**\n{childOccurrence.name}\n')
        print(f'**childOccurrence.fullPathName**\n{childOccurrence.fullPathName}')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
            app.log('Failed:\n{}'.format(traceback.format_exc()))


def dumpMatrix3D(msg: str, mat: adsk.core.Matrix3D):
    origin, xAxis, yAxis, zAxis = mat.getAsCoordinateSystem()
    msgLst = [
        f'origin:{origin.asArray()}',
        f'xAxis:{xAxis.asArray()}',
        f'yAxis:{yAxis.asArray()}',
        f'zAxis:{zAxis.asArray()}',
        ''
    ]
    print(msg)
    print('\n'.join(msgLst))&lt;/LI-CODE&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="1.png" style="width: 619px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1150811i90AC3B3F9F32CC5C/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 result of the print is as follows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;version:2.0.15027

**childOccurrence.transform**
origin:(-1.0, -1.0, -1.0)
xAxis:(1.0, 0.0, 0.0)
yAxis:(0.0, 1.0, 0.0)
zAxis:(0.0, 0.0, 1.0)

**childOccurrence.transform2**
origin:(-1.0, -1.0, -1.0)
xAxis:(1.0, 0.0, 0.0)
yAxis:(0.0, 1.0, 0.0)
zAxis:(0.0, 0.0, 1.0)

**childOccurrence.name**
Component2:1

**childOccurrence.fullPathName**
Component2:1&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result I expected is as follows&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;version:2.0.15027

**childOccurrence.transform**
origin:(-1.0, -1.0, -1.0)
xAxis:(1.0, 0.0, 0.0)
yAxis:(0.0, 1.0, 0.0)
zAxis:(0.0, 0.0, 1.0)

**childOccurrence.transform2**
origin:(-2.0, -2.0, -2.0)
xAxis:(1.0, 0.0, 0.0)
yAxis:(0.0, 1.0, 0.0)
zAxis:(0.0, 0.0, 1.0)

**childOccurrence.name**
Component2:1

**childOccurrence.fullPathName**
Component1:1+Component2:1
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think "transform2" and "fullPathName" are not working correctly.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Dec 2022 02:34:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11610661#M4849</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-12-10T02:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11611379#M4850</link>
      <description>Interesting! There is definitely something I don't understand about the history behind transform and transform2, so I'm not coming to this with any expectations about how they should work. The fullPathName thing definitely doesn't match my expectations though. Thank you for looking into this! If there is indeed a bug here, is there a process for reporting it?</description>
      <pubDate>Sat, 10 Dec 2022 17:58:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11611379#M4850</guid>
      <dc:creator>brent.hagany</dc:creator>
      <dc:date>2022-12-10T17:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11612266#M4851</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11993867"&gt;@brent.hagany&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have reported the problem on Fusion 360 Insider.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2022 13:29:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11612266#M4851</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-12-11T13:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11612325#M4852</link>
      <description>&lt;P&gt;Many thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2022 14:24:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11612325#M4852</guid>
      <dc:creator>brent.hagany</dc:creator>
      <dc:date>2022-12-11T14:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11619263#M4853</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11993867"&gt;@brent.hagany&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had made a big mistake.&lt;BR /&gt;"transform2" and "fullPathName" are working correctly.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Fusion360API Python script
import traceback
import adsk.fusion
import adsk.core

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        mat: adsk.core.Matrix3D = adsk.core.Matrix3D.create()
        mat.translation = adsk.core.Vector3D.create(-1,-1,-1)

        rootComponent: adsk.fusion.Component = app.activeProduct.rootComponent
        rootComponent.isOriginFolderLightBulbOn = True

        parentOccurrence: adsk.fusion.Occurrence = rootComponent.occurrences.addNewComponent(
            mat
        )
        parentComponent: adsk.fusion.Component = parentOccurrence.component
        parentComponent.isOriginFolderLightBulbOn = True

        childOccurrence: adsk.fusion.Occurrence = parentComponent.occurrences.addNewComponent(
            mat
        )
        childOccurrence.component.isOriginFolderLightBulbOn = True

        # Fixed the following
        childOccProxy: adsk.fusion.Occurrence = childOccurrence.createForAssemblyContext(parentOccurrence)

        print(f'version:{app.version}\n')
        dumpMatrix3D('**childOccurrence.transform**', childOccProxy.transform)
        dumpMatrix3D('**childOccurrence.transform2**', childOccProxy.transform2)
        print(f'**childOccurrence.name**\n{childOccProxy.name}\n')
        print(f'**childOccurrence.fullPathName**\n{childOccProxy.fullPathName}')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
            app.log('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is not mentioned in the documentation, but I feel that the reassignment of childOccurrenceProxy.transform2 is not allowed, as per the error message.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2022 09:34:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11619263#M4853</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-12-14T09:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11619952#M4854</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11993867"&gt;@brent.hagany&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding the Occurrences.addNewComponentCopy method, when I do the same thing as the script in the GUI, I get a warning in position.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 338px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1152462i9F31BCD69848FA31/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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Although it is not mentioned in the documentation, I felt that the only components that can be used with the addNewComponentCopy method are those in rootComponent.occurrences.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-2E04975A-94C1-4C85-8077-A01DAC1B12F1" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-2E04975A-94C1-4C85-8077-A01DAC1B12F1&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2022 14:24:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11619952#M4854</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-12-14T14:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11620899#M4855</link>
      <description>&lt;P&gt;Thanks for following up&amp;nbsp;@kanndenti.&amp;nbsp; I'm pretty confused by both of your messages, though.&amp;nbsp; I'll try to be clear about why, for each.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;First confusion&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In message 6 of this thread, you said "&lt;SPAN&gt;I feel that the reassignment of childOccurrenceProxy.transform2 is not allowed, as per the error message."&amp;nbsp; But I don't get an error when reassigning childOccurrenceProxy.transform2 (to be specific, line 33 of my script above does not throw an error) -- it appears to work correctly.&amp;nbsp; I didn't have a problem with this part, I was just demonstrating what I knew to work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Second confusion&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In message 7, you show an error from following steps in the GUI.&amp;nbsp; However, my script is trying to recreate steps I can do without error in the GUI.&amp;nbsp; Specifically, I follow these steps in a new document:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Create a new component (Component1)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;With Component1 selected, create a second new component (Component2) as a child of Component1&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Right click Component2 in the browser, and select "Copy"&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Right click Component1 in the browser, and select "Paste New".&amp;nbsp; This creates a second child of Component1, called Component3.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;When I follow these steps, the timeline for the document looks like this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="brenthagany_0-1671048333278.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1152627i362E39C7BBACFE3E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="brenthagany_0-1671048333278.png" alt="brenthagany_0-1671048333278.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and my browser looks like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="brenthagany_1-1671048358478.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1152629i45B97F516B5A3B66/image-size/medium?v=v2&amp;amp;px=400" role="button" title="brenthagany_1-1671048358478.png" alt="brenthagany_1-1671048358478.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm confused about several things here:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;what steps did you take to try to recreate my script?&lt;/LI&gt;&lt;LI&gt;where is the position feature in your timeline coming from?&lt;/LI&gt;&lt;LI&gt;since I can copy Component2 and "Paste New" to create Component3 in the GUI, and&amp;nbsp;&lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-2E04975A-94C1-4C85-8077-A01DAC1B12F1" target="_blank" rel="noopener"&gt;the documentation for addNewComponentCopy&lt;/A&gt;&amp;nbsp;says '&lt;SPAN&gt;This is the equivalent of copying and using the "Paste New" command in the user interface,' I feel I must be missing something to recreate the GUI interaction I just described.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;Thanks again for your help and patience&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2022 20:16:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11620899#M4855</guid>
      <dc:creator>brent.hagany</dc:creator>
      <dc:date>2022-12-14T20:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11620925#M4856</link>
      <description>&lt;P&gt;For clarity -- recreating the GUI steps I outlined in the last message is my goal, and I am not primarily concerned with transforms.&amp;nbsp; I am only talking about transforms because addNewComponentCopy throws an error about transforms when I try to use it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More concretely, the following script is trying to recreate the GUI steps I outlined in message 8, but it fails with "RuntimeError: 3 : transform overrides can only be set on Occurrence proxy from root component".&amp;nbsp; I would be very pleased if I could make something like this work&lt;/P&gt;&lt;LI-CODE lang="general"&gt;import adsk.core, adsk.fusion, traceback, math


def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        ###
        # setting up parent and child occurrences / components
        ###
        rootComponent = app.activeProduct.rootComponent
        parentOccurrence = rootComponent.occurrences.addNewComponent(adsk.core.Matrix3D.create())
        parentComponent = parentOccurrence.component
        childOccurrence = parentComponent.occurrences.addNewComponent(adsk.core.Matrix3D.create())

        ###
        # Fails with "RuntimeError: 3 : transform overrides can only be set on Occurrence proxy from root component"
        ###
        childOccurrenceCopy = parentComponent.occurrences.addNewComponentCopy(
            childOccurrence.component,
            adsk.core.Matrix3D.create())
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2022 20:29:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11620925#M4856</guid>
      <dc:creator>brent.hagany</dc:creator>
      <dc:date>2022-12-14T20:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11621784#M4857</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11993867"&gt;@brent.hagany&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was confused because I had tried so many things.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;First confusion&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;The proxy was working correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Second confusion&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;I was getting different results because I was trying a Matrix3D that I was moving around, like this&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;        mat: adsk.core.Matrix3D = adsk.core.Matrix3D.create()
        mat.translation = adsk.core.Vector3D.create(-1,-1,-1)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Indeed, when the same process was performed in the GUI, no warning was issued. I do not know why.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 08:07:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11621784#M4857</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-12-15T08:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11621844#M4858</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11993867"&gt;@brent.hagany&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know the cause, but so far it seems that the only way to avoid stopping with an error is to use Try or a text command.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        ###
        # setting up parent and child occurrences / components
        ###
        rootComponent = app.activeProduct.rootComponent
        parentOccurrence = rootComponent.occurrences.addNewComponent(adsk.core.Matrix3D.create())

        parentComponent = parentOccurrence.component
        childOccurrence = parentComponent.occurrences.addNewComponent(adsk.core.Matrix3D.create())
        childOccurrenceProxy = childOccurrence.createForAssemblyContext(parentOccurrence)

        ###
        # Fails with "RuntimeError: 3 : transform overrides can only be set on Occurrence proxy from root component"
        ###
        try:
            childOccurrenceCopy = parentComponent.occurrences.addNewComponentCopy(
                childOccurrence.component,
                adsk.core.Matrix3D.create())
        except:
            pass

        childOccurrenceCopy_from_textCmd = exec_addNewComponentCopy(childOccurrenceProxy, parentOccurrence)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def exec_addNewComponentCopy(
    refarenceOcc: adsk.fusion.Occurrence,
    targetOcc: adsk.fusion.Occurrence) -&amp;gt; adsk.fusion.Occurrence:

    app: adsk.core.Application = adsk.core.Application.get()
    sels: adsk.core.Selections = app.userInterface.activeSelections

    sels.clear()
    sels.add(refarenceOcc)
    app.executeTextCommand(u'Commands.Start CopyCommand')

    sels.clear()
    sels.add(targetOcc)
    app.executeTextCommand(u'Commands.Start FusionPasteNewCommand')
    app.executeTextCommand(u'NuCommands.CommitCmd')

    return targetOcc.component.occurrences[-1]&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 15 Dec 2022 08:33:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11621844#M4858</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-12-15T08:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11623746#M4859</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950"&gt;@kandennti&lt;/a&gt;&amp;nbsp;thank you again for spending so much time on this.&amp;nbsp; I hadn't even heard of text commands before, so I'm delighted at this workaround.&amp;nbsp; Hopefully a solution for the original addNewComponentCopy issue will soon reveal itself, but in the meantime, I'm more than satisfied at making it work this way.&amp;nbsp; Thanks again!&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 22:12:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11623746#M4859</guid>
      <dc:creator>brent.hagany</dc:creator>
      <dc:date>2022-12-15T22:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11623951#M4860</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11993867"&gt;@brent.hagany&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My apologies for the confusion as well.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2022 00:40:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11623951#M4860</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-12-16T00:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Error while setting transform in Occurrences.addNewComponentCopy</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11624030#M4861</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950"&gt;@kandennti&lt;/a&gt;&amp;nbsp;no apologies are necessary, I assure you!&amp;nbsp; You have been a great help&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2022 01:57:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/error-while-setting-transform-in-occurrences-addnewcomponentcopy/m-p/11624030#M4861</guid>
      <dc:creator>brent.hagany</dc:creator>
      <dc:date>2022-12-16T01:57:19Z</dc:date>
    </item>
  </channel>
</rss>

