Selecting a named face with ilogic

Selecting a named face with ilogic

jake_pietrzak
Contributor Contributor
1,487 Views
5 Replies
Message 1 of 6

Selecting a named face with ilogic

jake_pietrzak
Contributor
Contributor

Hi Everyone, its been a while.

Recently I encountered a problem with my dxf exporter.

Can anyone help with selecting a named face in part or assembly with ilogic?

 

0 Likes
Accepted solutions (3)
1,488 Views
5 Replies
Replies (5)
Message 2 of 6

jake_pietrzak
Contributor
Contributor

To Give you more context, this a bit of code I found (thanks @ClintBrown3D)

 

Dim doc = ThisApplication.ActiveDocument
Dim entity = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a Face to Export as DXF")

doc.SelectSet.Select(entity)

 

 But in here instead of typing the name of the face in part i need to click on it.

Does anyone has any idea how to pick face by name, not by clicking on it?

Thanks!

0 Likes
Message 3 of 6

FINET_Laurent
Advisor
Advisor
Accepted solution

Hi,

 

Here is a quick code as an exemple :

 

Dim Doc As Inventor.Document = ThisApplication.ActiveDocument
Dim o As ObjectCollection = Doc.AttributeManager.FindObjects("*", "*", "Face2")

Dim obj As Object = o(1)

Dim f As Inventor.Face 
f = DirectCast(obj, Face)	

 Kind regards,

FINET L. 

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 4 of 6

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @jake_pietrzak 

 

Assuming you've assigned the face a name as shown, you can select the face by it's name using something like this example.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oNamedEntities = iLogicVb.Automation.GetNamedEntities( ThisDoc.Document)
oFace = oNamedEntities.FindEntity("My Face")
ThisDoc.Document.SelectSet.Select(oFace)

 

Curtis_Waguespack_0-1688395610412.png

 

Curtis_Waguespack_1-1688395631286.png

 

Curtis_Waguespack_2-1688395656621.png

 

 

EESignature

0 Likes
Message 5 of 6

jake_pietrzak
Contributor
Contributor

Thanks @Curtis_Waguespack  & @FINET_Laurent ,

This is very helpful and easy solution for my problem.

Exactly what I need.

Thanks again!

 

Ok, it works great, but I have another challenge for you 😉

Lets say I have Assembly called: Assembly 01 😉

In this assembly I have 3 parts called: Part 01, Part 02 & Part 03.

Parts: Part 01 & Part 02 have a face called: Face 01.

How can I  select Face 01 in each part from assembly level?

 

Message 6 of 6

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @jake_pietrzak ,

 

Here is a quick example for selecting the named faces in parts ( if the named face exists) from an assembly.

 

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oOcc As ComponentOccurrence
Dim oFaceProxy As FaceProxy
fname = "Face 01"

For Each oOcc In oDoc.ComponentDefinition.Occurrences
	Dim oNamedEntities = iLogicVb.Automation.GetNamedEntities(oOcc.Definition.Document)
	If oNamedEntities.NameExists(fname) = False Then Continue For
	oFace = oNamedEntities.FindEntity(fname)
	oOcc.CreateGeometryProxy(oFace, oFaceProxy)
	ThisDoc.Document.SelectSet.Select(oFaceProxy)
Next

 I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes