<?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: Importing an assembly document into python in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348432#M141124</link>
    <description>&lt;P&gt;I was not aware that it was possible to automate Inventory with python. Usually you would vb.net or C# (or C++). just out of curiosity how did you manage to get the inventor objects in python?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The .Type is a general&amp;nbsp;property that you will find on almost all Inventor object.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The .DocumentType is more specific.&lt;/P&gt;
&lt;P&gt;And if you need to fine more specific information you should look at the Document.&lt;SPAN&gt;SubType. For example if you want to know if you have a sheetmetal part.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://adndevblog.typepad.com/manufacturing/2013/01/inventor-document-sub-types.html" target="_blank"&gt;https://adndevblog.typepad.com/manufacturing/2013/01/inventor-document-sub-types.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Aug 2022 10:19:02 GMT</pubDate>
    <dc:creator>JelteDeJong</dc:creator>
    <dc:date>2022-08-09T10:19:02Z</dc:date>
    <item>
      <title>Importing an assembly document into python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348001#M141118</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having difficulty importing an assembly file into python. There seems to be a conflict between the output when I check Document.Type and Document.DocumentType. The second recognises that the file is an an assembly. But the first returns the ‘Document’ ObjectType which needs to also be an assembly one so that I can manipulate it properly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how I can force the object type to change?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 06:45:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348001#M141118</guid>
      <dc:creator>nj21997</dc:creator>
      <dc:date>2022-08-09T06:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an assembly document into python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348406#M141121</link>
      <description>&lt;P&gt;Are you using python for Inventor or fusion?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 10:03:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348406#M141121</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2022-08-09T10:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an assembly document into python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348411#M141122</link>
      <description>&lt;P&gt;Currently inventor, but it does look like restarting with fusion might save a lot of hassle&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 10:05:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348411#M141122</guid>
      <dc:creator>nj21997</dc:creator>
      <dc:date>2022-08-09T10:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an assembly document into python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348432#M141124</link>
      <description>&lt;P&gt;I was not aware that it was possible to automate Inventory with python. Usually you would vb.net or C# (or C++). just out of curiosity how did you manage to get the inventor objects in python?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The .Type is a general&amp;nbsp;property that you will find on almost all Inventor object.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The .DocumentType is more specific.&lt;/P&gt;
&lt;P&gt;And if you need to fine more specific information you should look at the Document.&lt;SPAN&gt;SubType. For example if you want to know if you have a sheetmetal part.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://adndevblog.typepad.com/manufacturing/2013/01/inventor-document-sub-types.html" target="_blank"&gt;https://adndevblog.typepad.com/manufacturing/2013/01/inventor-document-sub-types.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 10:19:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348432#M141124</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2022-08-09T10:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an assembly document into python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348450#M141125</link>
      <description>&lt;P&gt;It works to some extent. I think the issue must be that you cannot define the variable type before setting its type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I have:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;win32com.client&lt;BR /&gt;&lt;SPAN&gt;from &lt;/SPAN&gt;win32com.client &lt;SPAN&gt;import &lt;/SPAN&gt;gencache&lt;SPAN&gt;, &lt;/SPAN&gt;Dispatch&lt;SPAN&gt;, &lt;/SPAN&gt;constants&lt;SPAN&gt;, &lt;/SPAN&gt;DispatchEx&lt;SPAN&gt;, &lt;/SPAN&gt;GetActiveObject&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# tries to open inventor or creates a new instance&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;:&lt;BR /&gt;    invApp = GetActiveObject(&lt;SPAN&gt;'Inventor.Application'&lt;/SPAN&gt;)&lt;BR /&gt;&lt;SPAN&gt;except&lt;/SPAN&gt;:&lt;BR /&gt;    invApp = Dispatch(&lt;SPAN&gt;'Inventor.Application'&lt;/SPAN&gt;)&lt;BR /&gt;    invApp.Visible = &lt;SPAN&gt;True&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;# No idea what this does but was recommended by the guy who wrote it originally&lt;BR /&gt;&lt;/SPAN&gt;mod = gencache.EnsureModule(&lt;SPAN&gt;'{D98A091D-3A0F-4C3E-B36E-61F62068D488}'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;)&lt;BR /&gt;invApp = mod.Application(invApp)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Defines the active doc as a variable&lt;BR /&gt;&lt;/SPAN&gt;oPartDoc = invApp.ActiveDocument&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(oPartDoc.Type)&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(oPartDoc.DocumentType)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both the type and document type return different values. Being:&lt;/P&gt;&lt;P&gt;oPartDoc.Type - 50332160 which is the ObjectTypeEnum for Document&lt;/P&gt;&lt;P&gt;oPartDoc.DocumentType - 12291 which measn Assembly Document&lt;/P&gt;&lt;PRE&gt;oParts = oPartDoc.ComponentDefinition.BOM&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;When I try to return the BOM I get an error stating:&lt;/P&gt;&lt;P&gt;'&amp;lt;win32com.gen_py.Autodesk Inventor Object Library.Document instance at 0x2791884160736&amp;gt;' object has no attribute 'ComponentDefinition'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this clarifies where the issue comes from. I hope I'm just doing something simple wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 10:31:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348450#M141125</guid>
      <dc:creator>nj21997</dc:creator>
      <dc:date>2022-08-09T10:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an assembly document into python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348479#M141126</link>
      <description>&lt;P&gt;the property "invApp.ActiveDocument" will always return a object of the type "Document". the "Document" type does not have a property "ComponentDefinition". The type "PartDocument" has this property. Therefore you need to tell the compilere that it is save to treat the "invApp.ActiveDocument"as a "PartDocument". In VB.net you would do it like this:&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Dim oPartDoc As PartDocument = invApp.ActiveDocument&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;or in C# (which is a bit more strict)&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;PartDocument oPartDoc = (PartDocument)invApp.ActiveDocument&lt;/LI-CODE&gt;
&lt;P&gt;But I dont know how you would cast in Python.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 10:47:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348479#M141126</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2022-08-09T10:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an assembly document into python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348498#M141127</link>
      <description>&lt;P&gt;You hero, I found the casting thing.&lt;/P&gt;&lt;P&gt;For reference that is what the mod thing is for:&lt;/P&gt;&lt;PRE&gt;oAssemblyPartDoc = mod.AssemblyDocument(oPartDoc)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This turns the regular document:&lt;/P&gt;&lt;P&gt;Autodesk Inventor Object Library.Document instance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Into an assembly document:&lt;/P&gt;&lt;P&gt;Autodesk Inventor Object Library.AssemblyDocument instance&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 10:58:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348498#M141127</guid>
      <dc:creator>nj21997</dc:creator>
      <dc:date>2022-08-09T10:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an assembly document into python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348566#M141135</link>
      <description>&lt;P&gt;The variable 'mod' contains reference to&amp;nbsp; "Autodesk Inventor Object Library" which describes the Inventor API objects.&lt;/P&gt;&lt;P&gt;In my opinion you can rename this variable to something like "inventorApi".&amp;nbsp;&lt;/P&gt;&lt;P&gt;see registry for more info&lt;/P&gt;&lt;P&gt;HKEY_CLASSES_ROOT\TypeLib\{D98A091D-3A0F-4C3E-B36E-61F62068D488}\1.0&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 11:38:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348566#M141135</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2022-08-09T11:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Importing an assembly document into python</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348656#M141139</link>
      <description>&lt;P&gt;After some googling I found this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/47443621/extracting-parameters-from-autodesk-inventor-with-python" target="_blank"&gt;https://stackoverflow.com/questions/47443621/extracting-parameters-from-autodesk-inventor-with-python&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like a nice example&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 12:19:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/importing-an-assembly-document-into-python/m-p/11348656#M141139</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2022-08-09T12:19:03Z</dc:date>
    </item>
  </channel>
</rss>

