Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get component's face with python

1 REPLY 1
Reply
Message 1 of 2
oscar_dls
184 Views, 1 Reply

Get component's face with python

Hello everyone,

 

I'm currently working on a Python code to automate a mechanical assembly in Inventor, and I'm facing an issue getting a component's face in my code.

To get the necessary planes, I'm using this method:

 

# def planes
masAPi_wp_YZ = comp.Definition.WorkPlanes.Item(1)
masAPi_Face_impl = comp.SurfaceBodies.Item(1).Faces.Item(2) # Problème ici
masAPi_wp_XY = comp.Definition.WorkPlanes.Item(3)

# proxys
masAPiYZ = comp.CreateGeometryProxy(masAPi_wp_YZ)
masAPiImpl = comp.CreateGeometryProxy(masAPi_Face_impl)
masAPiXY = comp.CreateGeometryProxy(masAPi_wp_XY)

This method works well with work planes, but the issue is that I get the face I need with the entity number (2) and not its name ('Face_impl').

I haven't found a solution, I tried writing it like this: 'comp.SurfaceBodies.Item(1).Faces.Item("Face_impl")', but it doesn't find the face.

 

I also attempted to create a construction plane, but that doesn't work either

 

odelouis_0-1704450371740.png

 

 

If you have any ideas, feel free to answer.

thanks ! 🙂

 

 

 

1 REPLY 1
Message 2 of 2
yuzeaa
in reply to: oscar_dls

you can also use ilogic automation in python

from win32com import client as wc
ThisApplication = wc.Dispatch('Inventor.Application')
iLogicAuto = ThisApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}").Automation
oface = iLogicAuto.GetNamedEntities(ThisApplication.ActiveDocument).FindEntity("myface")
ThisApplication.CommandManager.DoSelect(oface)

Furthermore,you can also use .NET's LINQ methods to search for objects, while also improving performance by pylinq 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report