-
Re: Open Drawing
Rolando Garza May 18, 2015 11:08 AM (in response to David Brissenden)I'm assuming you are having trouble with your code where you can't reopen a part that is already loaded in session.
If that is the case, take a look at the code here:
instance a file (that is already in session) into an assembly
-
Re: Open Drawing
Deepak Gupta May 18, 2015 11:11 AM (in response to David Brissenden)OpenDoc6 but this would work if file is in same folder.
Option Explicit
Dim SwApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim FileName As String
Dim nErrors As Long
Dim nWarnings As Long
Sub main()
Set SwApp = Application.SldWorks
Set swModel = SwApp.ActiveDoc
FileName = Left(swModel.GetPathName, InStrRev(swModel.GetPathName, "."))
FileName = FilePath & "slddrw"
Set Part = SwApp.OpenDoc6(FileName, swDocDRAWING, swOpenDocOptions_Silent, "", nErrors, nWarnings)
End Sub
-
Re: Open Drawing
David Brissenden May 18, 2015 11:20 AM (in response to Deepak Gupta)Unfortunately the drawing is not in the same folder as the part or assembly
I am programmatically opening parts and assemblies so am looking for a way to open the drawing at the same time.
-
Re: Open Drawing
Deepak Gupta May 18, 2015 12:05 PM (in response to David Brissenden)Then try using this:
Option Explicit
Dim SwApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim FileName As String
Dim nErrors As Long
Dim nWarnings As Long
Const Path As String = "C:\Test File" 'Change path here
Sub main()
Set SwApp = Application.SldWorks
Set swModel = SwApp.ActiveDoc
FileName = Mid(swModel.GetPathName, InStrRev(swModel.GetPathName, "\") + 1)
FileName = Left(FileName, InStr(FileName, "."))
FileName = Path & "\" & FileName & "slddrw"
Set Part = SwApp.OpenDoc6(FileName, swDocDRAWING, swOpenDocOptions_Silent, "", nErrors, nWarnings)
End Sub
-
-