- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I could not find the new Feature Property Face Name in the API.
Is anyone knowing where i could find it and how the property is named in the API?
Solved! Go to Solution.
I could not find the new Feature Property Face Name in the API.
Is anyone knowing where i could find it and how the property is named in the API?
Solved! Go to Solution.
Hoping that below suggestions in forum discussion may be helpful to read face name.
Thanks and regards,

From what I can tell the feature property face name isn't new to the API it's the same stuff that's been there for years. The "new" part is simply that they added a user interface to make it easier to get to. The face names are stored using attributes and attributeSets.
Here's a rough idea how to get to them.
Dim part1Def As PartComponentDefinition = part1.Definition 'my part1 came from an assembly component occurrence
Dim oFaces As Faces = part1Def.SurfaceBodies(1).Faces
Dim tempFace As Face
For Each oFace In oFaces
AttSets = oFace.AttributeSets
If AttSets.NameIsUsed("iLogicEntityNameSet") Then
AttSet = AttSets.Item("iLogicEntityNameSet")
For Each Att In AttSet
If Att.Value() = "yourNamedFeature" Then 'change name here
tempFace = oFace
Logger.Debug("tempFaceID Set" & tempFace.InternalName)
End If
Next
End If
Next
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
Hi All -
I'm trying to change the appearance (color) of a "named face" using iLogic.
For instance: "Face" = (Autodesk Appearance Library) Bamboo, "Back" = (Autodesk Appearance Library) Cardboard
Is this possible?
Actually, I'd like to be able to change the color of the "named face" by assigning a material to it....
Thanks.
@Anonymous,
Try below iLogic code to change appearance of named face (In this code, "Top" is considered as named face).
Sub Main()
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oAsset As Asset
oAsset = ThisApplication.AssetLibraries.Item(2).AppearanceAssets.Item("Cardboard")
Dim oDocAsset As Asset
Try
oDocAsset = oDoc.AppearanceAssets.Item("Cardboard")
Catch
oAsset.CopyTo(oDoc)
oDocAsset = oDoc.AppearanceAssets.Item("Cardboard")
End Try
Dim oCompDef As ComponentDefinition
oCompDef = oDoc.ComponentDefinition
Dim oFaces As Faces
oFaces = oCompDef.SurfaceBodies(1).Faces
Dim AttSets As AttributeSets
Dim AttSet As AttributeSet
Dim oFace As Face
For Each oface In oFaces
AttSets = oface.AttributeSets
If AttSets.NameIsUsed("iLogicEntityNameSet") Then
AttSet = AttSets.Item("iLogicEntityNameSet")
For Each Att In AttSet
If Att.value = "Top" Then
oFace.Appearance = oDocAsset
End If
Next
End If
Next
End Sub
Thanks and regards,

That's brilliant, thanks.
Let's say that instead of "Cardboard", I need to reference the Appearance from a selected material?
I have a multi-level parameter (Top_Material) which is linked to the (Autodesk Material Library), where the user can select a material/appearance for the "Top".
So if the user selects Plaster, then the appearance for Plaster would be assigned.
@Anonymous ,
Try below iLogic code to select the material from the list.
Sub Main()
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oList As ArrayList = New ArrayList()
Dim oMaterial As Asset
For Each oMaterial In ThisApplication.AssetLibraries.Item(2).AppearanceAssets
oList.Add(oMaterial.DisplayName)
Next
If oDoc.DocumentType = kPartDocumentObject Then
Dim oPartCompDef As PartComponentDefinition
oPartCompDef = oDoc.ComponentDefinition
Dim oParams As Parameters
oParams=oPartCompDef.Parameters
Dim oUserParams As UserParameters
oUserParams=oParams.UserParameters
Dim oAwesomeParameter As Parameter
Try
otester = oUserParams.Item("material")
Catch
oInsulationType=oUserParams.AddByValue("material", oList.Item(1), kTextUnits)
End Try
End If
Parameter.Param("material").ExposedAsProperty = False
Parameter.Param("material").IsKey = True
MultiValue.List("material") = oList
selected_mat = InputListBox("Choose Part material", MultiValue.List("material"),oList.Item(1), Title := "Part material", ListName := "Available Standard materials")
Dim oAsset As Asset
oAsset = ThisApplication.AssetLibraries.Item(2).AppearanceAssets.Item(selected_mat)
Dim oDocAsset As Asset
Try
oDocAsset = oDoc.AppearanceAssets.Item(selected_mat)
Catch
oAsset.CopyTo(oDoc)
oDocAsset = oDoc.AppearanceAssets.Item(selected_mat)
End Try
Dim oCompDef As ComponentDefinition
oCompDef = oDoc.ComponentDefinition
Dim oFaces As Faces
oFaces = oCompDef.SurfaceBodies(1).Faces
Dim AttSets As AttributeSets
Dim AttSet As AttributeSet
Dim oFace As Face
For Each oface In oFaces
AttSets = oface.AttributeSets
If AttSets.NameIsUsed("iLogicEntityNameSet") Then
AttSet = AttSets.Item("iLogicEntityNameSet")
For Each Att In AttSet
If Att.value = "Top" Then
oFace.Appearance = oDocAsset
End If
Next
End If
Next
End Sub
Thanks and regards,

@martin_winkler , @Anonymous , @clutsa
Instead of going to the AttributeSets, you can use the NamedEntities iLogic API.
Dim namedEntities = iLogicVb.Automation.GetNamedEntities(ThisDoc.Document)

Hi, Mike,
Can I use this iLogic API in VB.NET in any way?
Dim namedEntities = iLogicVb.Automation.GetNamedEntities(ThisDoc.Document)
Thanks
Limin,
Yes, you can access this and other iLogic API from VB.NET. Where is your code running?
1) add-in
2) external EXE
3) DLL loaded by iLogic
The best way to access it is different for each.

Mike,
I want to use this iLogic API function directly from an Add-in of VB.NET (of course, I need to put the API as a reference somewhere in the add-in). So I don't need to put this function in an iLogic rule then call the rule first.
Add references to these DLLs (in %ProgramFiles\Autodesk\Inventor 2019\Bin)
Autodesk.iLogic.Core.dll
Autodesk.iLogic.References.dll
Set the reference properties:
Copy Local : False
Specific Version : False
Then in your code:
Imports Autodesk.iLogic.Core Imports Autodesk.iLogic.Interfaces ' ... If (iLogicCentral.Instance IsNot Nothing) Then Dim iLogicAuto As IiLogicAutomation = iLogicCentral.Instance.ExternalApi 'use iLogicAuto ... End If
If the iLogic add-in is loaded, then iLogicCentral.Instance shoudl be available.
Here's the documentation for IiLogicAutomation .
