' Start of iLogic code *********************************************************** mydoc = ThisDoc.Document If mydoc.DocumentType <> kPartDocumentObject Then MessageBox.Show("This rule can only be run in a part file!", "Cadline iLogic", _ MessageBoxButtons.Ok,MessageBoxIcon.Exclamation, _ MessageBoxDefaultButton.Button1) Return End If ' Define stuff... Dim oDef As ComponentDefinition = mydoc.ComponentDefinition Dim oFeature As PartFeature Dim oFeatures As PartFeatures = oDef.Features ' Define new dictionary to hold colours required for each feature name Dim oColourDict As New Dictionary(Of String, String) ' Add all your colour combinations in here, by copying existing lines oColourDict.Add("SLOT", "Flaked Satin - Blue") oColourDict.Add("POCKET", "Canary") oColourDict.Add("Hole", "Red") ' Loop through all features in part For Each oFeature In oFeatures For Each Combo As KeyValuePair(Of String, String) In oColourDict ' Check dictionary entry to see if it matches name of feature (e.g. does feature name contain HOLE) ' Note that this is CASE INSENSITIVE If oFeature.Name.IndexOf((Combo.Key), 0, StringComparison.CurrentCultureIgnoreCase) > -1 Then ' Set feature colour Try Feature.Color(oFeature.Name) = Combo.Value Catch MsgBox("You are trying to set feature '" & oFeature.Name & "' to colour '" & Combo.Value & "'." & vbLf & vbLf & _ "This colour does not exist in the current appearance library. Please correct this...", 64, "Cadline iLogic") Exit Sub End Try End If Next Next ' End of iLogic code ***********************************************************