Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
martin_winkler
in reply to: clutsa

@clutsa

Thanks, that was the hint I needed. I have written two examples in VBA how to get the names of all surfaces and how to get the names of selected surfaces. I need this in order to name a sketch according to the area from which it is originated.

 

Sub Get_AllNames_from_Faces()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oCompDef As ComponentDefinition
Set oCompDef = oDoc.ComponentDefinition
Dim oFaces As Faces
Set oFaces = oCompDef.SurfaceBodies(1).Faces
Dim AttSets As AttributeSets
Dim AttSet As AttributeSet

For Each oface In oFaces
 Set AttSets = oface.AttributeSets
 If AttSets.NameIsUsed("iLogicEntityNameSet") Then
  Set AttSet = AttSets.item("iLogicEntityNameSet")
  For Each Att In AttSet
    Debug.Print ("Face Value: " & Att.Value)
  Next
 End If
Next
End Sub

Sub Get_SelectedNames_from_Faces()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument

Dim CompDef As ComponentDefinition
Set CompDef = oDoc.ComponentDefinition
Dim oSelect As SelectSet
Set oSelect = oDoc.SelectSet
Dim oFaces As Faces
Set oFaces = CompDef.SurfaceBodies(1).Faces
Dim AttSets As AttributeSets
Dim AttSet As AttributeSet

For Each item In oSelect
 Set AttSets = item.AttributeSets
 If AttSets.NameIsUsed("iLogicEntityNameSet") Then
  Set AttSet = AttSets.item("iLogicEntityNameSet")
  For Each Att In AttSet
   If Att.Name = "iLogicEntityName" Then
    'Get only the displayed Name of the Face
    Debug.Print ("Face Value: " & Att.Value)
   End If
  Next
 End If
Next
End Sub

Best Regards Martin