- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @claudio.ibarra. Here is an example iLogic rule you can test with and modify as needed for the task you mentioned in the last part of Message 6 above. You will need to edit the names of the two appearances (lines 16 & 17), to the real names of those appearances. Also, if there are no local (within the part itself, not just an external library) copies those two special appearances, then local copies will need to be created, either manually, or by adding additional code to the rule to copy them from a specific external library to the part, before you will be able to assign those appearances to faces in the part.
Sub Main
'make sure this is a Part (not an assembly, drawing, or other)
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then Return
Dim oPDoc As PartDocument = ThisDoc.Document
'get the Named Entities (if any)
Dim oNEs As NamedEntities = iLogicVb.Automation.GetNamedEntities(oPDoc)
If oNEs Is Nothing OrElse oNEs.Entities.Count = 0 Then
Logger.Info("No NamedEntities found in this part, so exiting routine.")
Return
End If
Dim oNVM As NameValueMap = oNEs.Entities
'define the appearances you want to use
Dim oAppearances As AssetsEnumerator = oPDoc.AppearanceAssets
Dim oActiveAppearance As Asset = oPDoc.ActiveAppearance
'<<<< EDIT FOLLOWING APPEARANCE NAMES AS NEEDED >>>>
Dim oPaintedAppearance As Asset = oAppearances.Item("Painted")
Dim oMachinedAppearance As Asset = oAppearances.Item("Machined")
'iterate though the NameValueMap of named entities by Index #
For i As Integer = 1 To oNVM.Count
Dim sName As String = oNVM.Name(i) 'the name assigned to the entity
Dim oEntity As Object = oNVM.Value(sName) 'the named entity
If TypeOf oEntity Is Face Then 'check Type of entity (could be Face, Edge, or Vertex)
Dim oFace As Face = oEntity 'make Face Type vairable, and set it as its value
'check name for keywords, then set appropriate appearance
If sName.Contains("paint") Then
oFace.Appearance = oPaintedAppearance
ElseIf sName.Contains("machined") Then
oFace.Appearance = oMachinedAppearance
Else
oFace.Appearance = oActiveAppearance
End If
End If
Next 'i
oPDoc.Update2(True)
'If oPDoc.Dirty Then oPDoc.Save
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS)
.
Wesley Crihfield
(Not an Autodesk Employee)