first of al I am very new to prgramming with solidworks.
I want to create a macro that can color lines in a drawingview that are linked to a specific feature.
I already have found a piece of code where i can find the lines linked to my feature.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSelMgr As SldWorks.SelectionMgr
Dim swView As SldWorks.View
Dim swEdge As SldWorks.Edge
Dim faces As Variant
Dim edges As Variant
Dim components As Variant
Dim swFace(2) As SldWorks.Face2
Dim swFeat(2) As SldWorks.Feature
Dim ret As Boolean
Dim i As Long
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swView = swDraw.ActiveDrawingView
Set swSelMgr = swModel.SelectionManager
Set swView = swSelMgr.GetSelectedObject6(1, -1)
' Get all visible components in the
' selected drawing view
components = swView.GetVisibleComponents
' Print name of first visible component in the
' selected drawing view
Debug.Print "First visible component in selected drawing view: " & components(0).Name2
' Get all of the edges on the first visible component
' in the selected drawing view
edges = swView.GetVisibleEntities(components(0), swViewEntityType_Edge)
' Iterate through all of the edges in the first visible component
' in the drawing view
For i = 0 To UBound(edges)
Set swEdge = edges(i)
' Get the faces adjacent to each edge
faces = swEdge.GetTwoAdjacentFaces2
If faces(0) Is Nothing And faces(1) Is Nothing Then
Debug.Print "No adjacent faces found."
' Get the features associated with each edge
Set swFace(0) = faces(0)
Set swFace(1) = faces(1)
Set swFeat(0) = swFace(0).GetFeature
Set swFeat(1) = swFace(1).GetFeature
' Print the file name, model path and file name, drawing view, configuration,
' and feature names associated with each face associated with each edge
Debug.Print "File = " & swModel.GetPathName
Debug.Print " Drawing View = " & swView.GetName2()
Debug.Print " Model = " & swView.GetReferencedModelName & " <" & swView.ReferencedConfiguration & ">"
Debug.Print " Feature 0 = " & swFeat(0).Name & " [" & swFeat(0).GetTypeName & "]"
Debug.Print " Feature 1 = " & swFeat(1).Name & " [" & swFeat(1).GetTypeName & "]"
Dim swName As String
Dim swTest As String
swName = swFeat(0).Name
swTest = swFeat(1).Name
If InStr(swName, "Engraving") > 0 Or InStr(swTest, "Engraving") > 0 Then
now i want to specify the color for the lines i have found.
so i was thinking about swEdge.Color.Modify or something like that.
but i can't find anything in the API guides.
Although i can choose the color for each line whne i do it by hand.
hope you can help