<?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: Suppress a feature using a script in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9522624#M12754</link>
    <description>&lt;P&gt;Since there are no methods such as "itemByName" and "itemById" in the timeline, it is necessary to find the necessary one from all the elements with a loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This toggles control of the feature with the name Key (Fillet).&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;#Fusion360API Python script
import adsk.core, adsk.fusion, traceback

_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui = _app.userInterface
        des  :adsk.fusion.Design = _app.activeProduct

        # get timeline
        tl :adsk.fusion.Timeline = des.timeline

        # Get the future with the name of Key
        key = 'Fillet'
        features = findByLikeName(tl, key)

        for feature in features:
            if hasattr(feature, 'isSuppressed'):
                # has isSuppressed Property
                feature.isSuppressed = not feature.isSuppressed

            elif hasattr(feature, 'timelineObject'):
                # Sketch object
                timeObj = feature.timelineObject
                timeObj.isSuppressed = not timeObj.isSuppressed

            else:
                # other
                _ui.messageBox('Not Supported')

        # finish
        _ui.messageBox('Done')

    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def findByLikeName(
    tl :adsk.fusion.Timeline,
    name :str) -&amp;gt; list:

    import re

    lst = []
    tlo = adsk.fusion.TimelineObject.cast(None)
    for tlo in tl:
        if re.search(name, tlo.name):
            lst.append(tlo)

    return lst&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 18 May 2020 00:34:33 GMT</pubDate>
    <dc:creator>kandennti</dc:creator>
    <dc:date>2020-05-18T00:34:33Z</dc:date>
    <item>
      <title>Suppress a feature using a script</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9280085#M12749</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2020-01-28 at 17.16.24.png" style="width: 522px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/722494i4649673E0E2E442F/image-dimensions/522x414?v=v2" width="522" height="414" role="button" title="Screenshot 2020-01-28 at 17.16.24.png" alt="Screenshot 2020-01-28 at 17.16.24.png" /&gt;&lt;/span&gt;&lt;BR /&gt;I need to conditionally suppress a feature using a script.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I've found some threads about this issue, but no trial code nor working examples. I tried to do it by myself but unsuccessfully. I'm not a developer (just some Javascript for web pages) and I the learning curve of the scripting environment is too steep for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I share a&amp;nbsp;&lt;A href="https://a360.co/38LjrnV" target="_blank" rel="noopener"&gt;basic design&lt;/A&gt; to play with. If anybody could drop some lines of code to conditionally suppress the last feature, it'd be very helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 16:42:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9280085#M12749</guid>
      <dc:creator>martin.devarda</dc:creator>
      <dc:date>2020-01-28T16:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress a feature using a script</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9295605#M12750</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6139410"&gt;@martin.devarda&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created a script for trial.&lt;BR /&gt;After running the script, select a timeline.&lt;BR /&gt;Toggles Suppress &amp;lt;-&amp;gt; Unsuppress.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 349px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/725627i538E8AE30EAABC53/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;PRE&gt;#Fusion360API Python script

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app  :adsk.core.Application = adsk.core.Application.get()
        ui   :adsk.core.UserInterface = app.userInterface

        # user selection
        msg :str = 'Select Feature'
        selFiltter :str = 'Features,Occurrences'

        while True:
            sel :adsk.core.Selection = selectEnt(ui, msg ,selFiltter)

            if not sel:
                #Press ESC key
                break

            # Get the selected element
            # feature :adsk.fusion.Feature = sel.entity
            feature = sel.entity

            # Suppress &amp;lt;-&amp;gt; Unsuppress
            if hasattr(feature, 'isSuppressed'):
                # has isSuppressed Property
                feature.isSuppressed = not feature.isSuppressed
            elif hasattr(feature, 'timelineObject'):
                # Sketch object
                timeObj = feature.timelineObject
                timeObj.isSuppressed = not timeObj.isSuppressed
            else:
                # other
                ui.messageBox('Not Supported')

        # finish
        ui.messageBox('Done')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def selectEnt(
        ui :adsk.core.UserInterface,
        msg :str, 
        filtterStr :str) -&amp;gt; adsk.core.Selection:

    try:
        sel = ui.selectEntity(msg, filtterStr)
        return sel
    except:
        return None&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 15:06:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9295605#M12750</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2020-02-04T15:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress a feature using a script</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9364627#M12751</link>
      <description>&lt;P&gt;Thanks, very helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2 more questions to reach my goal:&lt;BR /&gt;&lt;BR /&gt;1. how can I access objects to be suppressed/unsuppressed by id (if any) instead of manually selecting them? Consider that my objects (e.g. an extrude feature) have been created manually via UI, not programmatically. I see them in timeline, but I cannot find any sort of ID to reference them.&lt;BR /&gt;&lt;BR /&gt;2. how can I access a user defined parameter?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for your help&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 16:32:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9364627#M12751</guid>
      <dc:creator>luca.giorcelli9CG7C</dc:creator>
      <dc:date>2020-03-07T16:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress a feature using a script</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9365367#M12752</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;1. how can I access objects to be suppressed/unsuppressed by id (if any) ～&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I did not understand the meaning of Id.&lt;/P&gt;
&lt;P&gt;This script is suppresses all "Extrude Feature".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;#Fusion360API Python script

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app :adsk.core.Application = adsk.core.Application.get()
        ui  :adsk.core.UserInterface = app.userInterface
        des :adsk.fusion.Design = app.activeProduct
        
        Suppressionlist = []
        for tlObj in des.timeline:
            if tlObj.entity.objectType == 'adsk::fusion::ExtrudeFeature':
                if tlObj.isSuppressed == False:
                    Suppressionlist.append(tlObj)

        if len(Suppressionlist) &amp;lt; 1:
            msg = 'No "Extrude Feature" to suppress'
            ui.messageBox(msg)
            return
        
        msg = 'Suppresses all "Extrude Feature". Is it OK?'
        resOk = adsk.core.DialogResults.DialogOK
        btnOkCancel = adsk.core.MessageBoxButtonTypes.OKCancelButtonType
        if ui.messageBox(msg, 'test', btnOkCancel) != resOk:
            return

        for tlObj in reversed(Suppressionlist):
            tlObj.entity.isSuppressed = True

        # finish
        ui.messageBox('Done')

    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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;2. how can I access a user defined parameter?&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is like this.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;#Fusion360API Python script

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app :adsk.core.Application = adsk.core.Application.get()
        ui  :adsk.core.UserInterface = app.userInterface
        des :adsk.fusion.Design = app.activeProduct
        
        prm :adsk.fusion.UserParameter = des.userParameters.itemByName('my_param')
        ui.messageBox(str(prm.value))

    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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Mar 2020 13:42:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9365367#M12752</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2020-03-08T13:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress a feature using a script</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9521784#M12753</link>
      <description>&lt;LI-CODE lang="general"&gt;# Get the selected element
            # feature :adsk.fusion.Feature = sel.entity
            feature = sel.entity&lt;/LI-CODE&gt;&lt;P&gt;According to lines above,&amp;nbsp;&amp;nbsp;the feature to be suppressed must be &lt;U&gt;manually selected&lt;/U&gt; in timeline, which is not my case. I'd like to reference the feature programmatically, without manually selecting them in timeline.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I &lt;U&gt;reference features programmatically&lt;/U&gt;?&amp;nbsp;Does Fusion assign names (or unique ID) to features? If yes, how can I know the name (or ID) of a feature in my timeline?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 17 May 2020 10:34:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9521784#M12753</guid>
      <dc:creator>martin.devarda</dc:creator>
      <dc:date>2020-05-17T10:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress a feature using a script</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9522624#M12754</link>
      <description>&lt;P&gt;Since there are no methods such as "itemByName" and "itemById" in the timeline, it is necessary to find the necessary one from all the elements with a loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This toggles control of the feature with the name Key (Fillet).&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;#Fusion360API Python script
import adsk.core, adsk.fusion, traceback

_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui = _app.userInterface
        des  :adsk.fusion.Design = _app.activeProduct

        # get timeline
        tl :adsk.fusion.Timeline = des.timeline

        # Get the future with the name of Key
        key = 'Fillet'
        features = findByLikeName(tl, key)

        for feature in features:
            if hasattr(feature, 'isSuppressed'):
                # has isSuppressed Property
                feature.isSuppressed = not feature.isSuppressed

            elif hasattr(feature, 'timelineObject'):
                # Sketch object
                timeObj = feature.timelineObject
                timeObj.isSuppressed = not timeObj.isSuppressed

            else:
                # other
                _ui.messageBox('Not Supported')

        # finish
        _ui.messageBox('Done')

    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def findByLikeName(
    tl :adsk.fusion.Timeline,
    name :str) -&amp;gt; list:

    import re

    lst = []
    tlo = adsk.fusion.TimelineObject.cast(None)
    for tlo in tl:
        if re.search(name, tlo.name):
            lst.append(tlo)

    return lst&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 18 May 2020 00:34:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9522624#M12754</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2020-05-18T00:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress a feature using a script</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9522675#M12755</link>
      <description>&lt;P&gt;One thing to be aware of and also why the timeline doesn't have a findByName method is that it's possible to have duplicate names in the timeline.&amp;nbsp; For example, features are owned by a component and each feature must have a unique name but only within that component.&amp;nbsp; If you have a design with two components, each one can have a feature named "Extrude1".&amp;nbsp; Both of these features will show up as nodes in the timeline so just specifying a name is ambiguous.&amp;nbsp; Because of this, the solution&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950"&gt;@kandennti&lt;/a&gt;&amp;nbsp;provided by looking through the timeline will find the first item with the specified name, not necessarily the one you want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, because the timeline contains a mix of different types of entities, you can have duplicate names within the same component.&amp;nbsp; For example, I can have an extrusion named "Bill" and a construction plane named "Bill", both in the same component and both of them in the timeline.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the real-world it's likely things will have unique names and the solution of iterating over the timeline will give you the result you're looking for but I just want to point out there are other possibilities and there's a reason the API is like it is.&amp;nbsp; The itemByName method is supported in places where a name is guaranteed to be a unique identifier.&amp;nbsp; For example, the ConstructionPlanes collection supports it because the collection only provides access to construction planes and only the construction planes within a specific component so the names are guaranteed to be unique.&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 01:11:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9522675#M12755</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2020-05-18T01:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress a feature using a script</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9613744#M12756</link>
      <description>&lt;P&gt;It would be very useful to have a new parameter type for suppression or just use a regular variable as an enable or suppress option for features.&amp;nbsp; You could then assign that suppression name to the features you want to be able to enable/disable.&amp;nbsp; If the value is 0 then the features assigned to that parameter name would be suppressed.&amp;nbsp; I already use variables for enabling of adding or subtracting measurements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use a parameter called EnableBoltVersion and I assign it to a 0 or 1 (0 disabled, 1 enabled)&lt;/P&gt;&lt;P&gt;I then use EnableBoltVersion in dimensions like this...&lt;/P&gt;&lt;P&gt;45mm + (EnableBoltVersion * 43.2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When EnableBoltVersion is 0 43.2 is not added.&amp;nbsp; When it is 1, 43.2 is added.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be very useful to be able to assign EnableBoltVersion to a few features that I need to enable or suppress.&amp;nbsp; If it is 0 then the feature is suppressed and if it is not equal to 0 (negative or positive value), it is enabled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using a script to suppress features is a bit cumbersome and just another thing to manage and debug when a really simple feature added to fusion360 would really make it much easier to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 05:12:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9613744#M12756</guid>
      <dc:creator>agibson2</dc:creator>
      <dc:date>2020-07-02T05:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: Suppress a feature using a script</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9617299#M12757</link>
      <description>&lt;P&gt;I think that is a great idea.&amp;nbsp; It's not really an API feature but would be a core Fusion 360 feature that you could take advantage of through the API.&amp;nbsp; I suggest posting it on the &lt;A href="https://forums.autodesk.com/t5/fusion-360-feedback-hub/bd-p/6069" target="_blank" rel="noopener"&gt;Feedback Hub&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Jul 2020 00:24:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/suppress-a-feature-using-a-script/m-p/9617299#M12757</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2020-07-04T00:24:59Z</dc:date>
    </item>
  </channel>
</rss>

