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

Where is New Feature Face Name in Inventor 2019 API located

martin_winkler
Advisor

Where is New Feature Face Name in Inventor 2019 API located

martin_winkler
Advisor
Advisor

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?

FaceName.jpg

0 Likes
Reply
Accepted solutions (2)
2,770 Views
12 Replies
Replies (12)

chandra.shekar.g
Autodesk Support
Autodesk Support

@martin_winkler,

 

Hoping that below suggestions in forum discussion may be helpful to read face name.

 

https://forums.autodesk.com/t5/inventor-customization/geometry-labels-inventor-2019/m-p/8350452#M904...

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

clutsa
Collaborator
Collaborator
Accepted solution

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
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes

martin_winkler
Advisor
Advisor
Accepted solution

@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

0 Likes

Anonymous
Not applicable

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.

 

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

@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,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

Anonymous
Not applicable

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.

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

@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,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

MjDeck
Autodesk
Autodesk

@martin_winkler , @Anonymous , @clutsa 
Instead of going to the AttributeSets, you can use the NamedEntities iLogic API.

Dim namedEntities = iLogicVb.Automation.GetNamedEntities(ThisDoc.Document)

Mike Deck
Software Developer
Autodesk, Inc.

liminma8458
Collaborator
Collaborator

Hi, Mike,

Can I use this iLogic API in VB.NET in any way?

Dim namedEntities = iLogicVb.Automation.GetNamedEntities(ThisDoc.Document) 

 Thanks

Thanks
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit
0 Likes

MjDeck
Autodesk
Autodesk

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 Deck
Software Developer
Autodesk, Inc.

0 Likes

liminma8458
Collaborator
Collaborator

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.

Thanks
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit
0 Likes

MjDeck
Autodesk
Autodesk

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 .


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes