<?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: Cannot select object in component using activeSelections in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9688702#M11191</link>
    <description>&lt;P&gt;Hm, there seems to be no way to edit a post that is too old, so some more spamming instead.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution I wrote above, selecting the bodies for e.g. BoxFeature does not select the actual feature (which has implications when trying to run the edit command on the selection). Is there a correct way to select a Feature?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.assemblyContext is None and there is no createForAssemblyContext. Selecting a BoxFeature in the GUI, I can see that ui.activeSelections has a proxy tothat feature.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I found that I have to use &lt;STRONG&gt;all&lt;/STRONG&gt;OccurrencesByComponent to find nested occurrences.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Aug 2020 06:48:44 GMT</pubDate>
    <dc:creator>thomasa88</dc:creator>
    <dc:date>2020-08-13T06:48:44Z</dc:date>
    <item>
      <title>Cannot select object in component using activeSelections</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9651198#M11184</link>
      <description>&lt;P&gt;I'm trying to select a sketch that resides within a component. However, I get a runtime error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below snippet shows trying to select a sketch in a component and then a sketch that resides in the rootComponent.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ui.activeSelections.add(app.activeProduct.rootComponent.occurrences.item(0).component.sketches[0])
RuntimeError: 3 : invalid argument entity
ui.activeSelections.add(app.activeProduct.rootComponent.sketches[0])
True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;If I manually select the sketch in the timeline and grab the selection from activeSelections, I can add it back to activeSelections. So it seems the object I select manually is wrong in some way?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 11:36:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9651198#M11184</guid>
      <dc:creator>thomasa88</dc:creator>
      <dc:date>2020-07-23T11:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select object in component using activeSelections</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9651631#M11185</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7468050"&gt;@thomasa88&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also tried.&lt;BR /&gt;BRepBody etc. of Component other than RootComponent cannot be added too.&lt;/P&gt;
&lt;P&gt;This feels like a bug...&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 14:59:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9651631#M11185</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2020-07-23T14:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select object in component using activeSelections</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9653216#M11186</link>
      <description>&lt;P&gt;I just found that the component itself cannot be selected, when accessed as parentComponent. It can be selected when being accessed on its own.&lt;/P&gt;&lt;P&gt;The rootComponent can be selected when accessed as parentComponent. So it seems something is wrong with the child entity.&lt;/P&gt;&lt;P&gt;Sample document: &lt;A href="https://a360.co/39AIqw9" target="_blank" rel="noopener"&gt;https://a360.co/39AIqw9&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Item 0 is a sketch within the rootComponent. Item 2 is a sketch within a component (item 1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;t=design.timeline
ui.activeSelections.clear()
True
e0=t[0].entity

e2=t[2].entity

ui.activeSelections.add(e0.parentComponent)
True
ui.activeSelections.add(e2.parentComponent)
RuntimeError: 3 : invalid argument entity


e1=t[1].entity

e1 == e2.parentComponent
False                      # Expected this to be true

app.activeProduct.rootComponent == e0.parentComponent
True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit.&lt;/P&gt;&lt;P&gt;I was wrong about the component being selectable on its own. Its Occurence is selectable.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ui.activeSelections.add(root.allOccurrences[0].component.sketches[0])
RuntimeError: 3 : invalid argument entity
ui.activeSelections.add(root.allOccurrences[0].component)
RuntimeError: 3 : invalid argument entity
ui.activeSelections.add(root.allOccurrences[0])
True&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 24 Jul 2020 10:15:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9653216#M11186</guid>
      <dc:creator>thomasa88</dc:creator>
      <dc:date>2020-07-24T10:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select object in component using activeSelections</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9680117#M11187</link>
      <description>&lt;P&gt;Bump.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to know if this bug has been picked up by Autodesk?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that it might not be solved in foreseeable time, but it would be good to know that it's known. (Also, I guess this is just a generation error)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's really blocking my vertical timeline add-in.&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="screenshot.png" style="width: 261px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/805010iB5B58DF9EE148BC9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="screenshot.png" alt="screenshot.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Aug 2020 04:11:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9680117#M11187</guid>
      <dc:creator>thomasa88</dc:creator>
      <dc:date>2020-08-08T04:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select object in component using activeSelections</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9686391#M11188</link>
      <description>&lt;P&gt;This isn't a bug but is working as expected.&amp;nbsp; To start with it's a good idea to read this article to get an understanding of what a proxy is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-88A4DB43-CFDD-4CFF-B124-7EE67915A07A" target="_blank"&gt;http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-88A4DB43-CFDD-4CFF-B124-7EE67915A07A&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a sample script that demonstrates getting and selecting a sketch in a sub occurrence.&amp;nbsp; I've also attached the assembly I used to test it.&amp;nbsp; I created a new component (which internally created a new component) and then added a sketch to that component.&amp;nbsp; I then copied that occurrence and re-positioned the new one so I see two sketches.&amp;nbsp; The second occurrence is referencing the same component as the first so you're looking at two instances of the same sketch.&amp;nbsp; If you make a change to one you'll see the other one change.&amp;nbsp; That's because there is really only one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's why trying to add that sketch to the active selection doesn't work because the sketch belongs to another component and just providing the sketch isn't enough for Fusion to know how to use it in the context of the root component.&amp;nbsp; In this case there are two instances of the sketch so Fusion doesn't know which one should be selected.&amp;nbsp; Creating a proxy specifies which occurrence the sketch is relative to.&amp;nbsp; You can see I create two proxies, one for each occurrence and by changing which one is passed to the active selection it will select one or the other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def run(context):
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        des = adsk.fusion.Design.cast(app.activeProduct)
        root = des.rootComponent

        occ1 = root.occurrences.item(0)
        occ2 = root.occurrences.item(1)

        sk = occ1.component.sketches.item(0)
        skProxy1 = sk.createForAssemblyContext(occ1)
        skProxy2 = sk.createForAssemblyContext(occ2)

        ui.activeSelections.add(skProxy1)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) &lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 12 Aug 2020 06:52:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9686391#M11188</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2020-08-12T06:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select object in component using activeSelections</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9687676#M11189</link>
      <description>&lt;P&gt;I see. So I need to find all occurencies and make proxies through them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried going from from the Timeline and check the entries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For a sketch, there is the createForAssembly() function you mention. However, I need to find the occurences to create the proxies. I tried going via the parentComponent, but I could not find any occurrences through allOccurrencesor occurrences.&lt;/P&gt;&lt;P&gt;Then I realized that this works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;&amp;gt; e=t[2].entity
&amp;gt; e.classType()
'adsk::fusion::Sketch'
&amp;gt; app.activeProduct.rootComponent.occurrencesByComponent(e.parentComponent).count
2&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;However for a BaseFeature feature, say BoxFeature, there is no createForAssemblyContext. Any idea how to solve that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 16:55:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9687676#M11189</guid>
      <dc:creator>thomasa88</dc:creator>
      <dc:date>2020-08-12T16:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select object in component using activeSelections</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9688626#M11190</link>
      <description>&lt;P&gt;Okay, I got it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;t=thomasa88lib.timeline.get_timeline()[1]
fe=t[1].entity
body=fe.bodies[0]
p=body.createForAssemblyContext(app.activeProduct.rootComponent.occurrencesByComponent(fe.parentComponent)[0])
ui.activeSelections.add(p)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know if there would be cases where fe.parentComponent and body.parentComponent would return different values? I'm planning to loop the bodies, to get the same behavior as select in the normal timeline.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2020 05:26:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9688626#M11190</guid>
      <dc:creator>thomasa88</dc:creator>
      <dc:date>2020-08-13T05:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select object in component using activeSelections</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9688702#M11191</link>
      <description>&lt;P&gt;Hm, there seems to be no way to edit a post that is too old, so some more spamming instead.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution I wrote above, selecting the bodies for e.g. BoxFeature does not select the actual feature (which has implications when trying to run the edit command on the selection). Is there a correct way to select a Feature?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.assemblyContext is None and there is no createForAssemblyContext. Selecting a BoxFeature in the GUI, I can see that ui.activeSelections has a proxy tothat feature.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I found that I have to use &lt;STRONG&gt;all&lt;/STRONG&gt;OccurrencesByComponent to find nested occurrences.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2020 06:48:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9688702#M11191</guid>
      <dc:creator>thomasa88</dc:creator>
      <dc:date>2020-08-13T06:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select object in component using activeSelections</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9693904#M11192</link>
      <description>&lt;P&gt;I would like to understand what you're trying to accomplish.&amp;nbsp; It's not a typical workflow to have a reference to an entity and then try to find an occurrence path to that entity.&amp;nbsp; One big problem with this approach is there can be more than one path.&amp;nbsp; That was demonstrated in my earlier response where there are two occurrences of the part that contains the sketch.&amp;nbsp; In that case there would be two valid paths to the sketch.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Aug 2020 15:18:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9693904#M11192</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2020-08-16T15:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select object in component using activeSelections</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9694410#M11193</link>
      <description>&lt;P&gt;Yes, in this case, I'm making a vertical timeline (so names can easily be seen and edited) and I want the "Select item in timeline" functionality. I also want the user to be able to double click a feature and open the edit dialog for that feature. For sketch and extrude this works fine now, but, for a Box, the edit dialog comes up with "empty" values, as I have not managed to select the box, but just the bodies of the box.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/thomasa88/VerticalTimeline" target="_blank"&gt;https://github.com/thomasa88/VerticalTimeline&lt;/A&gt;&lt;/P&gt;&lt;P&gt;(I'm planning to rework the user interaction, but for now, click and double-click on the lines, outside of&lt;/P&gt;&lt;P&gt;the name, to see the behavior.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In another case, I just want to highlight what entity the user is naming: &lt;A href="https://github.com/thomasa88/DirectName" target="_blank"&gt;https://github.com/thomasa88/DirectName&lt;/A&gt; (For people finding this link, I hope to soon have the add-in in the app store)&lt;/P&gt;&lt;P&gt;My current detection uses inputChanged, so the correct entity is not highlighted until after the user has modified a name.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2020 04:05:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/cannot-select-object-in-component-using-activeselections/m-p/9694410#M11193</guid>
      <dc:creator>thomasa88</dc:creator>
      <dc:date>2020-08-17T04:05:40Z</dc:date>
    </item>
  </channel>
</rss>

