<?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 of embedding IronPython into a C# addin in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/example-of-embedding-ironpython-into-a-c-addin/m-p/3755776#M133117</link>
    <description>&lt;P&gt;This is an IronPython script I just wrote today, I use it to set the active document's BOMStructure to Reference:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Set BOM value of active document to Reference&lt;BR /&gt;# may need differing sections for handling components vs. assemblies?&lt;BR /&gt;import clr&lt;BR /&gt;import System&lt;BR /&gt;clr.AddReferenceByPartialName("System.Windows.Forms")&lt;BR /&gt;&lt;BR /&gt;from System.Windows.Forms import *&lt;BR /&gt;from System.Runtime.InteropServices import Marshal&lt;BR /&gt;InventorApp = Marshal.GetActiveObject('Inventor.Application')&lt;BR /&gt;clr.AddReference("Autodesk.Inventor.Interop")&lt;BR /&gt;from Inventor import *&lt;BR /&gt;&lt;BR /&gt;oDoc=InventorApp.ActiveDocument&lt;BR /&gt;doctype = InventorApp.ActiveDocumentType&lt;BR /&gt;print oDoc.DisplayName, doctype&lt;BR /&gt;&lt;BR /&gt;if doctype == DocumentTypeEnum.kPartDocumentObject.value__ :&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oPartDoc = clr.Convert(oDoc, PartDocument)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print oPartDoc.ComponentDefinition.BOMStructure&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oPartDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kReferenceBOMStructure.value__&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oPartDoc.Save()&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Jan 2013 18:25:52 GMT</pubDate>
    <dc:creator>rschader</dc:creator>
    <dc:date>2013-01-17T18:25:52Z</dc:date>
    <item>
      <title>Example of embedding IronPython into a C# addin</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/example-of-embedding-ironpython-into-a-c-addin/m-p/3735998#M133114</link>
      <description>&lt;P&gt;Below is a link to a github repo that has a code example showing how to embed an IronPython engine inside a C# addin.&amp;nbsp; It is the same as the "SimpleAddIn" that comes with the SDK, only with the logic part of the addin factored out into IronPython.&amp;nbsp; I could never find anything on using IronPython with Inventor so I'm posting this for any others that might be interested.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main reason for doing this is to speed up development time.&amp;nbsp; Edits related to the python code do not require the cycle of shutting down Inventor, compiling, restarting etc.&amp;nbsp; More detail is in the readme.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="https://github.com/frankfralick/InventorAddIns"&gt;https://github.com/frankfralick/InventorAddIns&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;@frankfralick&lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2012 17:29:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/example-of-embedding-ironpython-into-a-c-addin/m-p/3735998#M133114</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-12-13T17:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: Example of embedding IronPython into a C# addin</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/example-of-embedding-ironpython-into-a-c-addin/m-p/3736310#M133115</link>
      <description>&lt;P&gt;I don't mean to derail Frank's suggestion of using Iron Python, but there is another method of developing an add-in that doesn't require the shutting down and starting up each time you make a change or learning another language.&amp;nbsp; It's something that I often use.&amp;nbsp; Instead of beginning with an add-in I'll start with an simple Windows Forms Application and will develop and debug the logic portion of my add-in there.&amp;nbsp; Once I have the code working there I can copy it over into my add-in project.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2012 19:42:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/example-of-embedding-ironpython-into-a-c-addin/m-p/3736310#M133115</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2012-12-13T19:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: Example of embedding IronPython into a C# addin</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/example-of-embedding-ironpython-into-a-c-addin/m-p/3755763#M133116</link>
      <description>&lt;P&gt;I have created my own simple addin for Inventor that just brings up a file requester allowing me to choose and and execute python scripts directly from Inventor, but I can just as well edit and execute them using Visual Studio Shell IDE. In either case, they execute just fine. At some point when I have enough python scripts developed, I wouldn't mind trying to expand the addin to allow adding ribbons and buttons that are tied to python scripts, but I find just getting to know how to interact with Inventor using IronPython quite enough for now!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2013 18:10:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/example-of-embedding-ironpython-into-a-c-addin/m-p/3755763#M133116</guid>
      <dc:creator>rschader</dc:creator>
      <dc:date>2013-01-17T18:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Example of embedding IronPython into a C# addin</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/example-of-embedding-ironpython-into-a-c-addin/m-p/3755776#M133117</link>
      <description>&lt;P&gt;This is an IronPython script I just wrote today, I use it to set the active document's BOMStructure to Reference:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Set BOM value of active document to Reference&lt;BR /&gt;# may need differing sections for handling components vs. assemblies?&lt;BR /&gt;import clr&lt;BR /&gt;import System&lt;BR /&gt;clr.AddReferenceByPartialName("System.Windows.Forms")&lt;BR /&gt;&lt;BR /&gt;from System.Windows.Forms import *&lt;BR /&gt;from System.Runtime.InteropServices import Marshal&lt;BR /&gt;InventorApp = Marshal.GetActiveObject('Inventor.Application')&lt;BR /&gt;clr.AddReference("Autodesk.Inventor.Interop")&lt;BR /&gt;from Inventor import *&lt;BR /&gt;&lt;BR /&gt;oDoc=InventorApp.ActiveDocument&lt;BR /&gt;doctype = InventorApp.ActiveDocumentType&lt;BR /&gt;print oDoc.DisplayName, doctype&lt;BR /&gt;&lt;BR /&gt;if doctype == DocumentTypeEnum.kPartDocumentObject.value__ :&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oPartDoc = clr.Convert(oDoc, PartDocument)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print oPartDoc.ComponentDefinition.BOMStructure&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oPartDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kReferenceBOMStructure.value__&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oPartDoc.Save()&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2013 18:25:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/example-of-embedding-ironpython-into-a-c-addin/m-p/3755776#M133117</guid>
      <dc:creator>rschader</dc:creator>
      <dc:date>2013-01-17T18:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Example of embedding IronPython into a C# addin</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/example-of-embedding-ironpython-into-a-c-addin/m-p/3755780#M133118</link>
      <description>&lt;P&gt;One may ask, why write a macro or script for such a minor task, but I do this task alot, and using this script, I only need to click once on my addin button, double click the script, and I am done, even saving the file. Otherwise, I have to select the Tools ribbon, click on Document Proerties, then select the Bill of Materials tab, select the dropdown for setting Reference, then click Close, and then save. So I feel I'm saving myself quite a bit of repetitive strain!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2013 18:32:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/example-of-embedding-ironpython-into-a-c-addin/m-p/3755780#M133118</guid>
      <dc:creator>rschader</dc:creator>
      <dc:date>2013-01-17T18:32:26Z</dc:date>
    </item>
  </channel>
</rss>

