Hi Luis.
If there are sub assemblies you must find a better way.
This is for all levels of parts - only.
Sub PickDrawingViewToPaintParts()
Dim oDocActive As Document
Set oDocActive = ThisApplication.ActiveDocument
If oDocActive.DocumentType = kDrawingDocumentObject Then
Dim oDrgDoc As DrawingDocument
Set oDrgDoc = oDocActive
Dim drawView As DrawingView
Set drawView = ThisApplication.CommandManager.Pick( _
kDrawingViewFilter, "Pick DrawingView to paint..")
If drawView Is Nothing Then Exit Sub
PaintPartsInDrawingView drawView
Else
MsgBox "This macro works in IDW"
End If
End Sub
Sub PaintPartsInDrawingView(oDrawingView As DrawingView)
Dim paintColor As color
Dim oDrawingCurve As DrawingCurve
Dim descriptionString As String
Dim bDoNotPaint As Boolean
On Error Resume Next
For Each oDrawingCurve In oDrawingView.DrawingCurves
bDoNotPaint = False
descriptionString = Get_DocDescription(oDrawingCurve.ModelGeometry.ContainingOccurrence.Definition.Document)
If Err.Number = 0 Then
Select Case descriptionString
Case "Blue", "blue", "BLUE"
Set paintColor = ThisApplication.TransientObjects.CreateColor(0, 0, 255)
Case "Red", "red", "RED"
Set paintColor = ThisApplication.TransientObjects.CreateColor(255, 0, 0)
Case "Yellow", "yellow", "YELLOW"
Set paintColor = ThisApplication.TransientObjects.CreateColor(255, 255, 0)
Case "Green", "green", "GREEN"
Set paintColor = ThisApplication.TransientObjects.CreateColor(0, 255, 0)
Case Else
bDoNotPaint = True
''Set paintColor = ThisApplication.TransientObjects.CreateColor(0, 0, 0)
End Select
If Not bDoNotPaint Then oDrawingCurve.color = paintColor
Else
''oDrawingCurve.color = don't paint this curve
Err.Clear
End If
Next oDrawingCurve
MsgBox "Complete"
End Sub
Function Get_DocDescription(oDoc As Document) As String
Dim oDocPropSets As PropertySets
Dim oDocPropDescription As Property
Dim oDocDescription As String
Set oDocPropSets = oDoc.PropertySets
Set oDocPropDescription = oDocPropSets.item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}") _
.ItemByPropId(kDescriptionDesignTrackingProperties)
oDocDescription = oDocPropDescription.Value
Get_DocDescription = oDocDescription
End Function
My poor codes.