<?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: Is Python and scripting allowed in Inventor? in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/is-python-and-scripting-allowed-in-inventor/m-p/13029335#M6190</link>
    <description>&lt;P&gt;I created this proof of concept script. It worked but I found it not very useful.&lt;/P&gt;
&lt;PRE class="lia-code-sample line-numbers language-python" tabindex="0"&gt;&lt;CODE&gt;# https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/importing-an-assembly-document-into-python/m-p/11348656#M141139
# https://stackoverflow.com/questions/47443621/extracting-parameters-from-autodesk-inventor-with-python

import win32com.client
from win32com.client import gencache, Dispatch, constants, DispatchEx

ThisApplication = win32com.client.Dispatch('Inventor.Application')
ThisApplication.Visible = True
CastTo = gencache.EnsureModule('{D98A091D-3A0F-4C3E-B36E-61F62068D488}', 0, 1, 0)
ThisApplication = CastTo.Application(ThisApplication)

# oApp.SilentOperation = True
oDoc = ThisApplication.ActiveDocument
oDoc = CastTo.PartDocument(oDoc)
#in case of an assembly use the following line instead
#oDoc = mod.AssemblyDocument(oDoc)
prop = ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties")

# getting description and designer from iproperties
Descrip = prop('Description').Value
Designer = prop('Designer').Value
print("Description: ",Descrip)
print("Designer: ",Designer)

# getting mass and area
MassProps = oDoc.ComponentDefinition.MassProperties
#area of part
dArea = MassProps.Area
print("area: ",dArea)
#mass
mass = MassProps.Mass
print("mass: ",mass)

#getting  parameters
oParams = oDoc.ComponentDefinition.Parameters
lNum = oParams.Count
print("number of Parameters: ",lNum)
# make sure the parameter names exist in the Inventor model
param_d0 = oParams.Item("d0").Value
print("Parameter d0: ",param_d0)
param_d1 = oParams.Item("d1").Value
print("Parameter d1: ",param_d1)
param_d2 = oParams.Item("d2").Value
print("Parameter d2: ",param_d2)
param_d0_exp = oParams.Item("d0").Expression
print("Parameter d0_exp: ",param_d0_exp)
param_d1_exp = oParams.Item("d1").Expression
print("Parameter d1_exp: ",param_d1_exp)
param_d2_exp = oParams.Item("d2").Expression
print("Parameter d2_exp: ",param_d2_exp)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Sep 2024 20:11:14 GMT</pubDate>
    <dc:creator>JelteDeJong</dc:creator>
    <dc:date>2024-09-18T20:11:14Z</dc:date>
    <item>
      <title>Is Python and scripting allowed in Inventor?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/is-python-and-scripting-allowed-in-inventor/m-p/13024651#M6188</link>
      <description>&lt;P&gt;I've recently watched several videos of python scripting inside of Fusion 360, just wondering if IV allows this along with iLogic, vb and API?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 21:49:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/is-python-and-scripting-allowed-in-inventor/m-p/13024651#M6188</guid>
      <dc:creator>chris</dc:creator>
      <dc:date>2024-09-16T21:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: Is Python and scripting allowed in Inventor?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/is-python-and-scripting-allowed-in-inventor/m-p/13025063#M6189</link>
      <description>&lt;P&gt;Python scripting in Inventor is not officially supported. But because Inventor API is based on &lt;A href="https://en.wikipedia.org/wiki/Component_Object_Model" target="_blank" rel="noopener"&gt;COM&lt;/A&gt;, you can communicate with API from any environment which supports COM. Include Python. Because the communication between Python and Inventor is out-of-process I expect the API calls&amp;nbsp; will be much slower then in-process call (like add-ins).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 06:05:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/is-python-and-scripting-allowed-in-inventor/m-p/13025063#M6189</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2024-09-17T06:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Is Python and scripting allowed in Inventor?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/is-python-and-scripting-allowed-in-inventor/m-p/13029335#M6190</link>
      <description>&lt;P&gt;I created this proof of concept script. It worked but I found it not very useful.&lt;/P&gt;
&lt;PRE class="lia-code-sample line-numbers language-python" tabindex="0"&gt;&lt;CODE&gt;# https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/importing-an-assembly-document-into-python/m-p/11348656#M141139
# https://stackoverflow.com/questions/47443621/extracting-parameters-from-autodesk-inventor-with-python

import win32com.client
from win32com.client import gencache, Dispatch, constants, DispatchEx

ThisApplication = win32com.client.Dispatch('Inventor.Application')
ThisApplication.Visible = True
CastTo = gencache.EnsureModule('{D98A091D-3A0F-4C3E-B36E-61F62068D488}', 0, 1, 0)
ThisApplication = CastTo.Application(ThisApplication)

# oApp.SilentOperation = True
oDoc = ThisApplication.ActiveDocument
oDoc = CastTo.PartDocument(oDoc)
#in case of an assembly use the following line instead
#oDoc = mod.AssemblyDocument(oDoc)
prop = ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties")

# getting description and designer from iproperties
Descrip = prop('Description').Value
Designer = prop('Designer').Value
print("Description: ",Descrip)
print("Designer: ",Designer)

# getting mass and area
MassProps = oDoc.ComponentDefinition.MassProperties
#area of part
dArea = MassProps.Area
print("area: ",dArea)
#mass
mass = MassProps.Mass
print("mass: ",mass)

#getting  parameters
oParams = oDoc.ComponentDefinition.Parameters
lNum = oParams.Count
print("number of Parameters: ",lNum)
# make sure the parameter names exist in the Inventor model
param_d0 = oParams.Item("d0").Value
print("Parameter d0: ",param_d0)
param_d1 = oParams.Item("d1").Value
print("Parameter d1: ",param_d1)
param_d2 = oParams.Item("d2").Value
print("Parameter d2: ",param_d2)
param_d0_exp = oParams.Item("d0").Expression
print("Parameter d0_exp: ",param_d0_exp)
param_d1_exp = oParams.Item("d1").Expression
print("Parameter d1_exp: ",param_d1_exp)
param_d2_exp = oParams.Item("d2").Expression
print("Parameter d2_exp: ",param_d2_exp)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 20:11:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/is-python-and-scripting-allowed-in-inventor/m-p/13029335#M6190</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2024-09-18T20:11:14Z</dc:date>
    </item>
  </channel>
</rss>

