iLogic - Get NamedEntity of Part from Assembly level

iLogic - Get NamedEntity of Part from Assembly level

Binary12
Contributor Contributor
1,055 Views
1 Reply
Message 1 of 2

iLogic - Get NamedEntity of Part from Assembly level

Binary12
Contributor
Contributor

Hi,

 

I'm trying to make a rule, running from an assembly, that checks if the selected face is a named entity and if so, return the name of that face. So far I've got it to work on the part itself, looking like this:

 

Sub SelectFace()

Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim CompDef As ComponentDefinition
Set CompDef = oDoc.ComponentDefinition
Dim AttSets As AttributeSets
Dim AttSet As AttributeSet

Dim oFace As Face
Set oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPlanarEntities, "Select the face")

If Not oFace Is Nothing Then
    Set AttSets = oFace.AttributeSets
    If AttSets.NameIsUsed("iLogicEntityNameSet") Then
        Set AttSet = AttSets.Item("iLogicEntityNameSet")
            For Each Att In AttSet
             If Att.name = "iLogicEntityName" Then
              'Get the name of the Face
              MsgBox ("Face name: " & Att.Value)
              
             End If
            Next
    Else
        MsgBox ("No valid face selected")
    End If

End If

End Sub

 

Happy for any advice!

 

0 Likes
1,056 Views
1 Reply
Reply (1)
Message 2 of 2

NSBowser
Advocate
Advocate

Binary12,

 

This isn't working at the assembly level because the faces in the assembly are face proxies, you'll need to work back down into the part itself to extract the original face before checking if it is a named entity.

 

http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-6A540540-CA8A-40AD-8EBF-C4BB1F3E7288

 

""...An example is a face of a part within an assembly. When this face is queried through the API, what do the results mean - are coordinates returned in the context of the assembly, or the native part? What if the part is inserted into the assembly multiple times; how is a particular instance of the face identified? A key purpose of proxies is to provide answers to these questions. In this case, the proxy of the face object performs the necessary transformations to provide point data in the required context, and also provides information about which occurrence the face is associated with.""


Best of Luck

---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.
0 Likes