Mate Using Face Names

Mate Using Face Names

Anonymous
Not applicable
1,418 Views
5 Replies
Message 1 of 6

Mate Using Face Names

Anonymous
Not applicable

Hello,

 

I am trying to recreate some iLogic functionality through the Inventor API. My goal is too add constraints to parts in an assembly using the names faces of the part. In iLogic, I can simply run something like: 

Constraints.AddMate("Mate1", "Pipe:1", "TopEdgeFace", "Pipe:2", "UpperExternalHangingFace", offset:=0.0, e1InferredType:=InferredTypeEnum.kNoInference, e2InferredType:=InferredTypeEnum.kNoInference, solutionType:=MateConstraintSolutionTypeEnum.kNoSolutionType, biasPoint1:=Nothing, biasPoint2:=Nothing)

 where "TopEdgeFace" and "UpperExternalHangingFace" are both faces that I manually named on the base "Pipe" ipt file. I can't figure out how to recreate this in the Inventor API. How do I access the named faces and pass them in a way that makes sense? 

 

Thank you in advance! 

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

WCrihfield
Mentor
Mentor

Do you mean that you want to do this within the VBA Editor, and not in the iLogic Rule Editor? (Both can access the API.)

Are you talking about naming the faces by selecting them in the model window, then right clicking and selecting "Assign Name..."? Then accessing them by using something like this:

 

Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oNE As Autodesk.iLogic.Interfaces.NamedEntities = iLogicVb.Automation.GetNamedEntities(oDoc)

 

If so, what this basically does is add an Attribute to the face with the name you've supplied.

So you could find those named faces by their [ AttributeSets.Item(1).Item(1).Value ], for the name (or similar, in the unlikely event it has multiple attributes).

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi @WCrihfield ,

 

Thank you for the response. My understanding is the following: 

  1. I can create automation either using the Inventor API or through iLogic
  2. iLogic essentially provides access to the Inventor API through one level higher of abstraction
  3. If I access the Inventor API directly through VB.Net, I can create programs that can be run outside of the Inventor VBA editor or iLogic Editor. 

I am trying to create code that can be run as a standalone program by utilizing VB.NET and the Inventor API. From what I understand, coding in the iLogic editor is great, but it requires the code to be run in the editor. 

 

Here is my problem: 

  1. In the iLogic editor, I can mate two components in an assembly very easily using the "Named Geometry" of the parts and the names of the components in the Assembly. (Constraints.AddMate("Mate11", "a:1", "TopEdgeFace", "a:2", "UpperExternalHangingFace"...)
  2. I am trying to figure out how to recreate this utilizing VB.NET so that I can run this code as a standalone program and not in the iLogic editor. 
  3.  It appears that in the Inventor API, I add mate constraint via AssemblyComponentDefinition.Constraints.AddMateConstraint(...) where the key parameters for AddMateConstraint are EntityOne and EntityTwo. My hope is that I can find a way to pass the two faces that I want to mate on the two occurrences of the components by way of the "Named Geometry" I gave them. 

I very much appreciate your support, but based on my current status, I am somewhat confused by: 

  1. What is iLogicVB referencing?
  2. How would I get the proper objects to pass to AddMateConstraint? For what it's worth, I am able to access the ComponentOccurenence object of the objects I'm interested in. 

Thank you very much in advance. Any documents or support you can provide would be greatly appreciated. Thanks again!

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor
Accepted solution

I see now.

The "iLogicVb" and "InventorVb" are used within the iLogic Addin to access its Automation.

Here's the pop-up info for them: (ThisRule.iLogicVb As ILowLevelSupport    "Provides general functions")

Anyways, since you're not going to be using the iLogic addin, that doesn't matter.

But the iLogic environment uses vb.net as its basis, and you can run "Straight VB Code" within it, so it's fairly easy to mock something up within the iLogic rule editor, if needed, that can then be used elsewhere, if done right.

So, most non-transient, Inventor based objects within Inventor have AttributeSets that can be accessed as a ReadOnly Property, even if there aren't actually any attributes within them yet.  When you use the "Assign Name" manual process within the model window, that action creates an Attribute attached to that base object (face, edge, vertex, etc).  The iLogicVb.Automation.GetNamedEntities() is a function built into the iLogic addin, that searches the attributes of all entities within the model for the ones that have been created that way.

Another way to do this is through the document's AttributeManager, which is also a ReadOnly Property of the inventor document object.

See here.

https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-8617237F-E598-45E9-8D76-06D8134879FA 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 6

Anonymous
Not applicable

Thank you very much @WCrihfield . I accepted the solution. 

0 Likes
Message 6 of 6

Anonymous
Not applicable

Can you please convert the code in I-logic, I am having problem to convert this in i-logic.

0 Likes