- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I often get step files that have all parts grey. I have written an iLogic Rule that loops through my selected parts and applies predefined appearances to those parts. I would like to expand this to include applying materials and use the default material appearance as a base to apply a color to.
Here's how I do it manually.
Start with a part:
Apply Material:
Change Appearance Color:
The specific colors will either come from a predefined list or read from Excel. Other materials (Steel) will need an image to be removed from their default appearance (Plate) and for others (Steel, Galvinized) I would like to move the image to be a bump instead.
For reference, this is the iLogic rule I currently have:
'Make a ref to active doc
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
'selected components collection
Dim oSelected As ObjectCollection
oSelected = ThisApplication.TransientObjects.CreateObjectCollection
Dim oCount As Integer
oCount = oDoc.SelectSet.Count
'Check that at least 1 is selected
If oCount = 0 Then
MessageBox.Show("Please select a component.", "iLogic")
Exit Sub 'bail out
End If
Dim oList As New List(Of String)
oList.Add("MyColor")
oList.Add("Do Not Use")
myAppearance = InputListBox("Prompt", oList, "", Title:= "Select Appearnce Type", ListName := "Appearances")
Dim i As Integer
'add to Object Collection
For i = 1 To oCount
If oDoc.SelectSet.Item(i).Type = ObjectTypeEnum.kComponentOccurrenceObject Then
oSelected.Add(oDoc.SelectSet.Item(i))
End If
Next
Dim k As Integer = 1
' If there are selected components we can do something
For Each comp In oSelected
Dim oDef As PartDocument
oDef = comp.Definition.Document
oDef.ComponentDefinition.ClearAppearanceOverrides
Dim oRenderStyle As RenderStyle
Try
oRenderStyle = oDef.RenderStyles.Item(myAppearance & "(" & k & ")")
Catch
k = 1
oRenderStyle = oDef.RenderStyles.Item(myAppearance & "(" & k & ")")
End Try
oDef.ActiveRenderStyle = oRenderStyle
k = k + 1
' There can be references between assets,
' so keep doing it until only used things remain
Dim foundUnused As Boolean
Do
foundUnused = False
Dim a As Asset
For Each a In oDef.Assets
ThisApplication.StatusBarText = "Working with...... " & a.DisplayName & "......" & oDoc.FullFileName
If Not a.IsUsed Then
a.Delete
foundUnused = True
End If
Next
Loop While foundUnused
iLogicVb.UpdateWhenDone = True
Next
Solved! Go to Solution.