Use Python to open .ipt

Use Python to open .ipt

Anonymous
Not applicable
3,800 Views
6 Replies
Message 1 of 7

Use Python to open .ipt

Anonymous
Not applicable

Hi,

 

I'm looking to write a python code that opens an inventor part and prints the author and mass properties similar to this: https://stackoverflow.com/questions/47443621/extracting-parameters-from-autodesk-inventor-with-pytho...

 

Is there a simple line I can add into this code, to open a pre-saved part? I'm thinking it might be something like this:

oDoc = oApp.Documents.Open('MYPART.ipt',True)

 

Thank you in advance!

 

P.S. are there any centralized api style resources for python/inventor? Willing to purchase a book or something if there are any good suggestions.

0 Likes
3,801 Views
6 Replies
Replies (6)
Message 2 of 7

CCarreiras
Mentor
Mentor

Hi!

Why dont you use iLogic, the native code language of inventor?

CCarreiras

EESignature

Message 3 of 7

rossano_praderi
Collaborator
Collaborator

and also VB.NET within the iLogics editor and VBA (Visual Basic for Applications).....

 

You can develop an add-in with C++, C#, VB.NET, Delphi, etc.

You can develop a compiled application with C++, C#, VB.NET, Java, Delphi, IronPython, Python, etc.

You can develop a script with VBScript, PowerShell, Cscript, Python, IronPython, Javascript, AutoKey, etc.

 

There are so many solutions to explore.

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes
Message 4 of 7

Anonymous
Not applicable

Autodesk Inventor API documentation mentions you can control Inventor with Python, so that's a valid question, VB should not be required.

 

Are there any resources online at all ? I only seem to find small snippets and nothing to go on from there...

0 Likes
Message 5 of 7

rossano_praderi
Collaborator
Collaborator

Hi,
maybe using Python with Inventor API is not so much popular.

 

If most of the Inventor users have good knowledges within some programming languages (part in the application) such as VB (VB.Net or VBA), ILogics or C#, is natural to suppose that you will have more documetation and examples about these languages.

 

I don't know your level of expertise as a python developer, but I'm not having so much troubles readying examples written in other programming languages, most of the job is done understanding the API documentation.

 

If you know how take control/communicate with a "com" application using python, almost all the job is done, you know what I mean.

 

So, if you think there isn't much resources about python and Inventor....then start to share your experience and find people like you which would like to share their experience.

 

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes
Message 6 of 7

Anonymous
Not applicable

For sure I get that, language per-se is not the difficult part, it's actually knowing what to search for in this massive tree object model.

 

One thing I've been rather disappointed in Python scripting for Inventor is the fact that introspection (using dir(..)) is at most time not returning anything valuable, while for other COM-enabled applications such as Excel you can practically navigate the tree and figure things out as you go without leaving your console.

 

For any beginner on this topic, I would recommend to:

 

- Grab the PDF version of Inventor Object Model, available at this page randomly discovered and not (AFAIK) particularly mentionned in the API docs:

 

https://knowledge.autodesk.com/search-result/caas/simplecontent/content/autodesk-C2-AE-inventor-C2-A...

 

The API docs seems to reference a screenshot of that PDF, that's unreadable due to the huge size of the tree.

 

- Check the Ketiv tutorials available on YouTube (I'm not affiliated with neither of them in any way ). This one is particularly useful for getting started with the API, getting the philosophy, and most importantly knowing where to search for info:

 

https://www.youtube.com/watch?v=MFU_QaGdIDA

 

IMO, the most valuable trick is to launch a live tree object during debugging sessions in Inventor's VBA Environment, even if your goal is to script things in Python. Check the tutorial if you don't see how that would help.

 

If you have some more valuable tricks and advices, I'm interested.

 

 

0 Likes
Message 7 of 7

rossano_praderi
Collaborator
Collaborator

Thank you for sharing these informations.

 

As an addition to your explaination, within Inventor's VBA Environment you can use the objects browser to see of all referenced libraries without having to be into a debugging session.

 

Right now I doesn't have additional informations.

I would like to suggest you to have a look on IronPython and Visual Studio Community edition, you will get the same tools used for examples/tutorials in C# & VB.NET, but using Python as programming language.

 

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes