Get the Entity ID of a Face/Edge/Vert

Get the Entity ID of a Face/Edge/Vert

Anonymous
Not applicable
1,660 Views
7 Replies
Message 1 of 8

Get the Entity ID of a Face/Edge/Vert

Anonymous
Not applicable

Hi,

 

I need to get the Entity ID of a Face, Edge or Vertex and store it for later use. 

I've made an Add-In program in Visual Studio that let the user pick an edge from the model and I want the program to create a Fixed constraint at the given entity. The constraint is created with iLogic and it need the entity ID as an input. 

The code I made is shown below:

------------------------------------------------------------------------------------------------------------------------

Imports Autodesk.iLogic.Interfaces
Imports Inventor

Private Sub Pick_Faces()

 

' Dim Varibles etc
Dim oEdge As Edge
Dim strCmdForConstraint As String
Dim ID As Integer

 

MsgBox("Select Edges for Fixed-Constraints, Press ESC to Continue")


Do
' Let the User select an Edge
oEdge = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeCircularFilter, "Pick a Edge") 'kAllEntitiesFilter kPartEdgeCircularFilter

 

' Get the ID of the Edge
ID = THE EDGE ID

 

' Define a Constraint at the given Edge ID
If Not oEdge Is Nothing Then
strCmdForConstraint = "<Constraint Name=""Fixed Constraint"" " &
"ID = ""1"" Type=""0"" " &
"CoordinateSystemID=""0"" " &
"Tx=""1"" Ty=""1"" Tz=""1"" Rx=""1"" Ry=""1"" Rz=""1"" " &
"EntitiesCount=""5"" " &
"ArrowLength=""50"" ArrowColor=""14803200"" " &
"DisplayDensity=""4"" " &
"SubcaseCount=""1"" Subcases=""1""> " &
"<Entity1 GeometryType=""1"" GeometryID=""" & ID & """ ComponentName=""""/></Constraint>"

 

'Create Constraint
Nastran_AddinObj.Run(strCmdForConstraint)

 

End If

 

Loop While Not oEdge Is Nothing

 

End Sub

------------------------------------------------------------------------------------------------------------------------

 

Is there a way to get the ID from the selected edge of the user? (The orange line above in the code)

 

Regards 

Perra

 

0 Likes
1,661 Views
7 Replies
Replies (7)
Message 2 of 8

BrianEkins
Mentor
Mentor

Faces, Edges, and Vertices don't have a simple ID.  I don't know what Nastran is expecting for that input.  Is there some documentation that describes what's expected.  Maybe you need to somehow name the entity first?

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 8

Anonymous
Not applicable

Hi, thanks for responding!

 

Nastran expects an answer as an integer (in my case around 1 to 5).

 

Here are some documentation:

https://knowledge.autodesk.com/support/nastran-cad/getting-started/caas/CloudHelp/cloudhelp/2019/ENU...

and 

http://help.autodesk.com/view/NINCAD/2019/ENU/?guid=GUID-1B3F560D-C41A-4A13-8379-4035B97A7A37

 

I will try your suggestion and name the edge first and then implement it in the code! 

 

/ Perra

 

0 Likes
Message 4 of 8

Anonymous
Not applicable

Unfortunately it seems that Nastran In-CAD only accepts integers  as Entity ID.
I couldn't name the entity and refer to it in the code. 

 

Thank You for your interest!

0 Likes
Message 5 of 8

BrianEkins
Mentor
Mentor

Their documentation for this is also worthless.  My guess is that they're using the index within the array of whatever type of entity it is.  Since one of the arguments specifies if it's a face, edge, vertex or sketch, if you say you have a Face of ID 6 then maybe they're iterating through the collection of faces on the body and using the 6th one.  That's just a guess and you'll have to experiment a bit to see if that is what they're doing but since there's not a real ID for those entities, that's all I can think of.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 6 of 8

Anonymous
Not applicable

I found a video were a guy named Chris have done it the same way I want it! 

Now I just need to figure it out how the code works.

 

https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/screencast/Main/Details/...

 

Will try to contact him!

Message 7 of 8

JaneFan
Autodesk
Autodesk

Hey @Anonymous , 

 

Not sure whether this is what you need. From Inventor 2019, iLogic provided a function to assign name to b-rep entities. After being assigned name, the name of the entity is stored in AttributeSet itself which can be used to find it. 




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 8 of 8

Anonymous
Not applicable

Hi Anonymous,

 

I do have the same issue to get a linear simulation automated running. 

 

Did you already solved the problem or got an answer from Chris Atherton regarding the faceID?

 

Best regards

Tobias

0 Likes