<?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: Example Code for calling third party add-ons? in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/example-code-for-calling-third-party-add-ons/m-p/7270149#M17759</link>
    <description>&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to invoke commands created by other modules.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Specifically, if you take the helical gear add-on&amp;nbsp;(&lt;A href="https://apps.autodesk.com/FUSION/en/Detail/Index?id=9029586664984391977&amp;amp;appLang=en&amp;amp;os=Win64" target="_blank"&gt;https://apps.autodesk.com/FUSION/en/Detail/Index?id=9029586664984391977&amp;amp;appLang=en&amp;amp;os=Win64&lt;/A&gt;), which created the 'Helical Gear' entry under Create in Model mode. &amp;nbsp;When I manually click the Helical Gear entry under the Create tab, I get a dialog that asks me for gear parameters like module, number of teeth, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I would like to create a function that can call in to that code automatically; something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;def create_gear_train(module, ...):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;helical&amp;nbsp;&amp;nbsp;= rootComp.features.helical_gear_add_on&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;# gear1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;gear1 = helical.createSimpleInput()&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;gear1.module = module&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;gear1.teeth = 15&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;# gear 2&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;gear2 =&amp;nbsp;&lt;SPAN&gt;helical.createSimpleInput()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;gear2.module = module&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;gear2.teeth = 30 &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;# ...&lt;BR /&gt;&lt;BR /&gt;That is, something that allows me to reuse the helical code from my own code. &amp;nbsp;The trick specific to the helical code is that it's creation methods seem tightly coupled to the UI system so even if I could just import the functions via the python 'import' command, I'd still need to initialize a&amp;nbsp;&lt;/SPAN&gt;HelicalGearAddin() class and fake/mock out the calls from the GUI. &amp;nbsp;Much better if I could just make an API call to fill in the fields like a regular, autocad supported feature (like createCylinder()).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From your mail "you can iterate them by id by Command-related API." sounds like the right thing but I don't think I understand. &amp;nbsp;How do I identify the ID of a third-party add-on? &amp;nbsp;Apologies if it's a dumb question but any pointers to example code should get me going in the right direction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Rob&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Aug 2017 04:10:15 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-08-02T04:10:15Z</dc:date>
    <item>
      <title>Example Code for calling third party add-ons?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/example-code-for-calling-third-party-add-ons/m-p/7268368#M17757</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a professional programmer but very new to CAD and Fusion 360. &amp;nbsp;I'm looking to write a python script to iteratively make calls to some of the third party gear add-ons (e.g., Helical Gear). &amp;nbsp;I've read a bunch of the API tutorials and it seems easy enough, but I haven't found one that talks about how to call other scripts/add-ons.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Questions:&lt;/P&gt;&lt;P&gt;1) Is it possible to call a third-party add on via API?&lt;/P&gt;&lt;P&gt;2) Does anyone have example code they can point me to?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Rob&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 13:06:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/example-code-for-calling-third-party-add-ons/m-p/7268368#M17757</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-01T13:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Example Code for calling third party add-ons?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/example-code-for-calling-third-party-add-ons/m-p/7270114#M17758</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What did you mean "make calls to third-party add-ons"? We didn't provide API to let clients call into addons. However you could call some functions written in other Python addons if you know their path and import them to your python script successfully. If you mean to invoke those commands written in other addons, you can iterate them by id by Command-related API.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Marshal&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 03:33:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/example-code-for-calling-third-party-add-ons/m-p/7270114#M17758</guid>
      <dc:creator>marshaltu</dc:creator>
      <dc:date>2017-08-02T03:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Example Code for calling third party add-ons?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/example-code-for-calling-third-party-add-ons/m-p/7270149#M17759</link>
      <description>&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to invoke commands created by other modules.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Specifically, if you take the helical gear add-on&amp;nbsp;(&lt;A href="https://apps.autodesk.com/FUSION/en/Detail/Index?id=9029586664984391977&amp;amp;appLang=en&amp;amp;os=Win64" target="_blank"&gt;https://apps.autodesk.com/FUSION/en/Detail/Index?id=9029586664984391977&amp;amp;appLang=en&amp;amp;os=Win64&lt;/A&gt;), which created the 'Helical Gear' entry under Create in Model mode. &amp;nbsp;When I manually click the Helical Gear entry under the Create tab, I get a dialog that asks me for gear parameters like module, number of teeth, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I would like to create a function that can call in to that code automatically; something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;def create_gear_train(module, ...):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;helical&amp;nbsp;&amp;nbsp;= rootComp.features.helical_gear_add_on&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;# gear1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;gear1 = helical.createSimpleInput()&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;gear1.module = module&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;gear1.teeth = 15&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;# gear 2&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;gear2 =&amp;nbsp;&lt;SPAN&gt;helical.createSimpleInput()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;gear2.module = module&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;gear2.teeth = 30 &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;# ...&lt;BR /&gt;&lt;BR /&gt;That is, something that allows me to reuse the helical code from my own code. &amp;nbsp;The trick specific to the helical code is that it's creation methods seem tightly coupled to the UI system so even if I could just import the functions via the python 'import' command, I'd still need to initialize a&amp;nbsp;&lt;/SPAN&gt;HelicalGearAddin() class and fake/mock out the calls from the GUI. &amp;nbsp;Much better if I could just make an API call to fill in the fields like a regular, autocad supported feature (like createCylinder()).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From your mail "you can iterate them by id by Command-related API." sounds like the right thing but I don't think I understand. &amp;nbsp;How do I identify the ID of a third-party add-on? &amp;nbsp;Apologies if it's a dumb question but any pointers to example code should get me going in the right direction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Rob&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 04:10:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/example-code-for-calling-third-party-add-ons/m-p/7270149#M17759</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-02T04:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Example Code for calling third party add-ons?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/example-code-for-calling-third-party-add-ons/m-p/7270204#M17760</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can invoke command by the following codes. The precondition is you need know the id or name of the command. And unfortunately it cannot be automated as a command dialog will pop up to collect users' inputs. I cannot figure out better way to do that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: you can find the command id from the source codes of the addin and the command name under "Create" tab.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Marshal&lt;/P&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;PRE&gt;import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
 
        #myCmdDef = ui.commandDefinitions.itemById('HelicalGearAddin')
        myCmdDef = None
        for cmdDef in ui.commandDefinitions:
            if cmdDef.name == 'Helical Gear':
                myCmdDef = cmdDef
                break
        if myCmdDef:
            myCmdDef.execute()
 
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 05:28:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/example-code-for-calling-third-party-add-ons/m-p/7270204#M17760</guid>
      <dc:creator>marshaltu</dc:creator>
      <dc:date>2017-08-02T05:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: Example Code for calling third party add-ons?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/example-code-for-calling-third-party-add-ons/m-p/7271069#M17761</link>
      <description>&lt;P&gt;Thanks for the help. &amp;nbsp;This is definitely a step in the right direction but still not quite there because as you say, I can't directly input into the dialog box. &amp;nbsp;Is there a way I can from the ui object get a list of active dialog boxes such that maybe I can discover the dialog box? &amp;nbsp;If not, I can still manually type in values if I can get a pointer to the resulting objects that come out of the dialog boxes (e.g., so that I can move them and rotate them afterwards). &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know and thank you for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Rob&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 13:10:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/example-code-for-calling-third-party-add-ons/m-p/7271069#M17761</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-02T13:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Example Code for calling third party add-ons?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/example-code-for-calling-third-party-add-ons/m-p/7272981#M17762</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately I cannot figure out the way to let you do what you wanted. We don't have API to automate users' inputs in command dialog.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Marshal&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2017 02:09:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/example-code-for-calling-third-party-add-ons/m-p/7272981#M17762</guid>
      <dc:creator>marshaltu</dc:creator>
      <dc:date>2017-08-03T02:09:07Z</dc:date>
    </item>
  </channel>
</rss>

