Where is New Feature Face Name in Inventor 2019 API located

Where is New Feature Face Name in Inventor 2019 API located

Martin-Winkler-Consulting
Advisor Advisor
2,964 Views
12 Replies
Message 1 of 13

Where is New Feature Face Name in Inventor 2019 API located

Martin-Winkler-Consulting
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

Martin Winkler
CAD Developer
Did you find this post helpful? Feel free to like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature

0 Likes
Accepted solutions (2)
2,965 Views
12 Replies
Replies (12)
Message 2 of 13

chandra.shekar.g
Autodesk Support
Autodesk Support

@Martin-Winkler-Consulting,

 

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
Message 3 of 13

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
Message 4 of 13

Martin-Winkler-Consulting
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

Martin Winkler
CAD Developer
Did you find this post helpful? Feel free to like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature

0 Likes
Message 5 of 13

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
Message 6 of 13

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
Message 7 of 13

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
Message 8 of 13

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
Message 9 of 13

MjDeck
Autodesk
Autodesk

@Martin-Winkler-Consulting , @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.

Message 10 of 13

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 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Message 11 of 13

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
Message 12 of 13

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 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Message 13 of 13

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