Howdy - I've just started to go thru the Luke MalpassProgramming book and have a general programming question. I noticedthis and have been wondering about this even before I noticed it inthe book. The following is one of the Macros from the book. Icommented out some of the Programming Structure and changed somelines so the macro does the same thing.
'******************************************************************************
' C:\DOCUME~1\sparkstd\LOCALS~1\Temp\swx1544\Macro1.swb - macrorecorded on 12/01/08 by sparkstd
'******************************************************************************
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Sub main()
Set swApp = GetObject("", "SldWorks.Application")
If swApp Is Nothing Then
MsgBox "Error gettings SolidWorks Handle"
Exit Sub
End If
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
MsgBox "Failed to get active document"
Exit Sub
End If
If swModel.GetType() <> swDocumentTypes_e.swDocDRAWING Then
MsgBox "Active document is not a drawing"
Exit Sub
End If
Dim sheetNames As Variant
sheetNames = swModel.GetSheetNames()
Dim saveAsLocation As String
Dim lErrors As Long, lWarnings As Long
lErrors = lWarnings = 0
Dim bRet As Boolean
' ?????????????????????????????????
'Dim eVersion As Integer
'Dim eOptions As Integer
'eVersion = swSaveAsCurrentVersion
'eOptions = swSaveAsOptions_Silent
Dim sheetname As Variant
For Each sheetname In sheetNames
swModel.ActivateSheet sheetname
' ????????????????????????????????
'bRet = swModel.Extension.SaveAs(sheetname & ".dxf", eVersion,eOptions, Nothing, lErrors, lWarnings)
bRet = swModel.Extension.SaveAs(sheetname & ".dxf",swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, lErrors,lWarnings)
If bRet = False Then MsgBox "Failed to save " & sheetname& " as DXF."
Next sheetname
End Sub
' *******************
I've seen this type of structure before but I'm not sure of it'svalue/purpose. Can anyone explain this to me?
ThanksSolidworksApi macros
'******************************************************************************
' C:\DOCUME~1\sparkstd\LOCALS~1\Temp\swx1544\Macro1.swb - macrorecorded on 12/01/08 by sparkstd
'******************************************************************************
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Sub main()
Set swApp = GetObject("", "SldWorks.Application")
If swApp Is Nothing Then
MsgBox "Error gettings SolidWorks Handle"
Exit Sub
End If
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
MsgBox "Failed to get active document"
Exit Sub
End If
If swModel.GetType() <> swDocumentTypes_e.swDocDRAWING Then
MsgBox "Active document is not a drawing"
Exit Sub
End If
Dim sheetNames As Variant
sheetNames = swModel.GetSheetNames()
Dim saveAsLocation As String
Dim lErrors As Long, lWarnings As Long
lErrors = lWarnings = 0
Dim bRet As Boolean
' ?????????????????????????????????
'Dim eVersion As Integer
'Dim eOptions As Integer
'eVersion = swSaveAsCurrentVersion
'eOptions = swSaveAsOptions_Silent
Dim sheetname As Variant
For Each sheetname In sheetNames
swModel.ActivateSheet sheetname
' ????????????????????????????????
'bRet = swModel.Extension.SaveAs(sheetname & ".dxf", eVersion,eOptions, Nothing, lErrors, lWarnings)
bRet = swModel.Extension.SaveAs(sheetname & ".dxf",swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, lErrors,lWarnings)
If bRet = False Then MsgBox "Failed to save " & sheetname& " as DXF."
Next sheetname
End Sub
' *******************
I've seen this type of structure before but I'm not sure of it'svalue/purpose. Can anyone explain this to me?
ThanksSolidworksApi macros