Macro to automatically open drawing
Macro to automatically open drawing
(OP)
Currently when we have a part up and we want to see the drawing, we right click on the file name in the feature tree, then "open drawing".
Some users keep constantly searching for "open drawing". Some times it isn't there and they have to hit that little arrow to show more options, then it appears.
I want to simplify this even more and make it just a click of a button.
Have your part/assembly open. Click the button, and the drawing of it opens up.
I have searched and did not find one already written. I tried writing one yesterday and got close.. but it kept opening the same drawing over and over again and not the drawing of the current part.
Some users keep constantly searching for "open drawing". Some times it isn't there and they have to hit that little arrow to show more options, then it appears.
I want to simplify this even more and make it just a click of a button.
Have your part/assembly open. Click the button, and the drawing of it opens up.
I have searched and did not find one already written. I tried writing one yesterday and got close.. but it kept opening the same drawing over and over again and not the drawing of the current part.






RE: Macro to automatically open drawing
Dim swApp As Object
Dim sFileName As String
Dim Part As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
sFileName = Left$(Part.GetPathName, (Len(Part.GetPathName) - 6)) & "SLDDRW"
Set Part = swApp.OpenDoc(sFileName, swDocDRAWING)
End Sub
RE: Macro to automatically open drawing
-6))& "SLDDRW" and I was using opendoc6.
THANKS!.. star for you :)
RE: Macro to automatically open drawing
Dim swApp As Object
Dim sFileName As String
Dim Part As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set fso = CreateObject("Scripting.FileSystemObject")
sFileName = Left$(Part.GetPathName, (Len(Part.GetPathName) - 6)) & "SLDDRW"
If fso.FileExists(sFileName) Then
Set Part = swApp.OpenDoc(sFileName, swDocDRAWING)
Else: MsgBox ("Drawing does not exist")
End If
End Sub
RE: Macro to automatically open drawing
Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group
RE: Macro to automatically open drawing
RE: Macro to automatically open drawing
On the machines which aren't showing the full menu selections, RMB on a Toolbar area and select Customize > Options then select both Show All buttons. This will force all the available selections in all drop-down menus to be displayed.