Is it possible to modify the example macro Resolve All Lightweight Components Example (VBA) work on a drawing. I've been trying to get it working and I can't seem to figure it out.
Is it possible to modify the example macro Resolve All Lightweight Components Example (VBA) work on a drawing. I've been trying to get it working and I can't seem to figure it out.
Although, I couldnt find way to resolve whole drawing document, there is a way to resolve individual view
swview.SetLightweightToResolved
You can put this into loop
I already had a macro with the loop, I just added the if statement and did zero testing. Hopefully this works:
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim swDraw As DrawingDoc
Dim swView As View
Dim allSheetViewArrays As Variant
Dim sheetViews As Variant
Dim Msg As String
Dim Style As String
Dim Title As String
Dim i As Integer
Dim j As Integer
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel.GetType <> swDocDRAWING Then
Msg = "Only Allowed on Drawings" ' Define message
Style = vbOKOnly ' OK Button only
Title = "Error" ' Define title
Call MsgBox(Msg, Style, Title) ' Display error message
Exit Sub ' Exit this program
End If
Set swDraw = swModel
allSheetViewArrays = swDraw.GetViews
For i = 0 To UBound(allSheetViewArrays)
sheetViews = allSheetViewArrays(i)
For j = 0 To UBound(sheetViews)
Set swView = sheetViews(j)
If swView.IsLightweight Then
Debug.Print "View: " & swView.Name & " is Lightweight, resolving"
swView.SetLightweightToResolved
End If
Next j
Next i
End Sub
Matt Peneguy wrote:
I think John Stoltzfus has a macro that does this. Let us know John.
Not that one, I think that is the last one I need then I have them all
I already had a macro with the loop, I just added the if statement and did zero testing. Hopefully this works:
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim swDraw As DrawingDoc
Dim swView As View
Dim allSheetViewArrays As Variant
Dim sheetViews As Variant
Dim Msg As String
Dim Style As String
Dim Title As String
Dim i As Integer
Dim j As Integer
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel.GetType <> swDocDRAWING Then
Msg = "Only Allowed on Drawings" ' Define message
Style = vbOKOnly ' OK Button only
Title = "Error" ' Define title
Call MsgBox(Msg, Style, Title) ' Display error message
Exit Sub ' Exit this program
End If
Set swDraw = swModel
allSheetViewArrays = swDraw.GetViews
For i = 0 To UBound(allSheetViewArrays)
sheetViews = allSheetViewArrays(i)
For j = 0 To UBound(sheetViews)
Set swView = sheetViews(j)
If swView.IsLightweight Then
Debug.Print "View: " & swView.Name & " is Lightweight, resolving"
swView.SetLightweightToResolved
End If
Next j
Next i
End Sub