<?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 selectionCommandInput runtime error when addSelection JointOrigin in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/selectioncommandinput-runtime-error-when-addselection/m-p/12473878#M2220</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a script that needs to load selections saved in a yaml file. The selectionCommandInputs are created in the CommandCreateHandler. After the commands are created a custom event is fired that selects the saved selections.&lt;/P&gt;&lt;P&gt;It works fine for Occurences and Joints, but fails with runtime error 3 when trying to add a JointOrigin.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The origin_input has a selectionFilter for 'JointOrigins' and number of selections is limited to 1.&lt;/P&gt;&lt;P&gt;Am I doing something wrong here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jan 2024 10:46:59 GMT</pubDate>
    <dc:creator>simon.trendel</dc:creator>
    <dc:date>2024-01-03T10:46:59Z</dc:date>
    <item>
      <title>selectionCommandInput runtime error when addSelection JointOrigin</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/selectioncommandinput-runtime-error-when-addselection/m-p/12473878#M2220</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a script that needs to load selections saved in a yaml file. The selectionCommandInputs are created in the CommandCreateHandler. After the commands are created a custom event is fired that selects the saved selections.&lt;/P&gt;&lt;P&gt;It works fine for Occurences and Joints, but fails with runtime error 3 when trying to add a JointOrigin.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The origin_input has a selectionFilter for 'JointOrigins' and number of selections is limited to 1.&lt;/P&gt;&lt;P&gt;Am I doing something wrong here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 10:46:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/selectioncommandinput-runtime-error-when-addselection/m-p/12473878#M2220</guid>
      <dc:creator>simon.trendel</dc:creator>
      <dc:date>2024-01-03T10:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: selectionCommandInput runtime error when addSelection JointOrigin</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/selectioncommandinput-runtime-error-when-addselection/m-p/12477249#M2221</link>
      <description>&lt;P&gt;One thing I would try out is to get the&amp;nbsp;JointOrigin with assembly context and return it from your findJointOrigin function. That way the selection has the information for which exact JointOrigin you are specifying.&lt;BR /&gt;&lt;BR /&gt;Not entirely sure what your findJointOrigin function looks like but it seems you are iterating through Occurrences, so when you find the JointOrigin&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;return foundJointOrigin.createForAssmeblyContext(occurrenceInList)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Here's some more info with regards to this at the bottom in the "Proxies" section&amp;nbsp;&lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-88A4DB43-CFDD-4CFF-B124-7EE67915A07A" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-88A4DB43-CFDD-4CFF-B124-7EE67915A07A&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 18:50:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/selectioncommandinput-runtime-error-when-addselection/m-p/12477249#M2221</guid>
      <dc:creator>john.kirchner</dc:creator>
      <dc:date>2024-01-04T18:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: selectionCommandInput runtime error when addSelection JointOrigin</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/selectioncommandinput-runtime-error-when-addselection/m-p/12478401#M2222</link>
      <description>&lt;P&gt;awesome, many thanks. I'm starting to wrap my head around these proxies...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;like you suggested I modified the findJointOrigin recursive function to also return the occurrence the found joint origin lives in, that way I can create the proxy and successfully add it to the selection. Here are the respective code snippets for anybody interested:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def findJointOrigin(name, occurrences, currentLevel, joint_origin, occ):
    print("currentLevel: %d"%currentLevel)
    for occurrence in occurrences:
        print(occurrence.name)
        for jo in occurrence.component.jointOrigins:
            if jo.name == name:
                joint_origin.append(jo)
                occ.append(occurrence)
                return True
        if occurrence.childOccurrences:
            findJointOrigin(name,occurrence.childOccurrences,currentLevel+1, joint_origin, occ)&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;origin_input = adsk.core.SelectionCommandInput.cast(_robot_configuration_inputs.itemById('origin'))

origin = []
occ = []
findJointOrigin(_robot_config['robot']['origin'], _rootComp.occurrences.asList, 0, origin, occ)
if len(origin)&amp;gt;0:
    origin_proxy = origin[0].createForAssemblyContext(occ[0])
    origin_input.addSelection(origin_proxy)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 05 Jan 2024 09:20:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/selectioncommandinput-runtime-error-when-addselection/m-p/12478401#M2222</guid>
      <dc:creator>simon.trendel</dc:creator>
      <dc:date>2024-01-05T09:20:35Z</dc:date>
    </item>
  </channel>
</rss>

