<?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: Create New Component Using API in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-new-component-using-api/m-p/7840004#M16518</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following sample demonstrates how to create new component and set "name" or "part number" by API.&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;PRE&gt;import adsk.core, adsk.fusion, traceback

def run(context):
  ui = None
  try:
    app = adsk.core.Application.get()
    ui  = app.userInterface

    design = adsk.fusion.Design.cast(app.activeProduct)
    root = design.rootComponent
    
    for i in range(10):
        occ = root.occurrences.addNewComponent(adsk.core.Matrix3D.create())
        occ.component.name = 'My Component{}'.format(i)

  except:
    if ui:
      ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/PRE&gt;</description>
    <pubDate>Fri, 09 Mar 2018 02:00:21 GMT</pubDate>
    <dc:creator>marshaltu</dc:creator>
    <dc:date>2018-03-09T02:00:21Z</dc:date>
    <item>
      <title>Create New Component Using API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-new-component-using-api/m-p/7839368#M16517</link>
      <description>&lt;P&gt;Can anybody help???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible, using Fusion 360 API, to capture the "Create New Component" function?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At present, I have to manually input a name for the new component. If the assembly is, for example, 1000 every time I right mouse click "Create New Component", can the part number be the assembly number + 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Part Numbers 1000-001, 1000-002, 1000-003 etc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance!!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Darren&lt;/P&gt;</description>
      <pubDate>Thu, 08 Mar 2018 20:37:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-new-component-using-api/m-p/7839368#M16517</guid>
      <dc:creator>isocam</dc:creator>
      <dc:date>2018-03-08T20:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create New Component Using API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-new-component-using-api/m-p/7840004#M16518</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following sample demonstrates how to create new component and set "name" or "part number" by API.&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;PRE&gt;import adsk.core, adsk.fusion, traceback

def run(context):
  ui = None
  try:
    app = adsk.core.Application.get()
    ui  = app.userInterface

    design = adsk.fusion.Design.cast(app.activeProduct)
    root = design.rootComponent
    
    for i in range(10):
        occ = root.occurrences.addNewComponent(adsk.core.Matrix3D.create())
        occ.component.name = 'My Component{}'.format(i)

  except:
    if ui:
      ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Mar 2018 02:00:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-new-component-using-api/m-p/7840004#M16518</guid>
      <dc:creator>marshaltu</dc:creator>
      <dc:date>2018-03-09T02:00:21Z</dc:date>
    </item>
  </channel>
</rss>

