After looking at the code I posted above, I realized that it would handle views created from an Assembly (EdgeProxy) but not views created from a single part file (Edge). I reworked the code slightly to handle both situations. This was an interesting exercise
This executed fast on an assembly I tried it on with several hundred edges. I used the OverrideColor Property rather than changing the Layer but you could easily incorporate the layer code into the macro.
This macro does not take into consideration the fact that an Edge can border on several Faces that have different colors. It simply gets the
color of the last Face processed for that edge.
Code:
Private Sub ChangeViewEdgeColorToFaceColor()
Dim invAllSheets As Sheets
Dim invSHEET As Sheet
Dim invAllViews As DrawingViews
Dim invCurrView As DrawingView
Dim invDrawDOC As DrawingDocument
Dim invAllCurves As DrawingCurvesEnumerator
Dim invCURVE As DrawingCurve
Dim invAllSegs As DrawingCurveSegments
Dim invSEG As DrawingCurveSegment
Dim objGEN As Object
Dim invCOLOR As Color
Dim invTO As TransientObjects
Dim invEdgePRX As EdgeProxy
Dim invEDGE As Edge
Dim invAllFACES As Faces
Set invDrawDOC = ThisApplication.ActiveDocument
Set invTO = ThisApplication.TransientObjects
Set invCOLOR = invTO.CreateColor(255, 0, 0)
Set invAllSheets = invDrawDOC.Sheets
For Each invSHEET In invAllSheets
Set invAllViews = invSHEET.DrawingViews
For Each invCurrView In invAllViews
Set invAllCurves = invCurrView.DrawingCurves
For Each invCURVE In invAllCurves
Set invAllSegs = invCURVE.Segments
For Each invSEG In invAllSegs
Set objGEN = invSEG.Parent.ModelGeometry
If TypeOf objGEN Is EdgeProxy Then
Set invEdgePRX = objGEN
Set invAllFACES = invEdgePRX.Faces
ChangeColor invAllFACES, invCOLOR, invCURVE
ElseIf TypeOf objGEN Is Edge Then
Set invEDGE = objGEN
Set invAllFACES = invEDGE.Faces
ChangeColor invAllFACES, invCOLOR, invCURVE
End If
Next invSEG
Next invCURVE
Next invCurrView
Next invSHEET
End Sub
Private Sub ChangeColor(ByRef invFACES As Faces, _
ByRef invCOLOR As Color, _
ByRef invCURVE As DrawingCurve)
Dim invFace As Face
Dim bytRED As Byte
Dim bytGREEN As Byte
Dim bytBLUE As Byte
Dim invRenderST As RenderStyle
For Each invFace In invFACES
Set invRenderST = invFace.GetRenderStyle(kOverrideRenderStyle)
If Not invRenderST Is Nothing Then
invRenderST.GetAmbientColor bytRED, bytGREEN, bytBLUE
invCOLOR.SetColor bytRED, bytGREEN, bytBLUE
invCURVE.OverrideColor = invCOLOR
End If
Next invFace
End Sub
_________________
Robert A. Williams
http://www.leacar.com
"Gentlemen...you can't fight here. This is the War Room!"