文件使用方法
1.新建宏文件并保存
2.复制“solidworks批量转PDF和DWG宏.txt”文件内容(附1中内容)至刚刚保存的空白宏文件内。
3.保存宏文件,运行宏文件。(图中三角)
4.复制所转换格式文件的位置,并粘贴至宏文件运行对话框内,点击确定
5.程序自动运行,如果有多张图纸,或者图纸中有不同比例会停住,点击确定即可继续运行。需注意,一次转换最好不要超过100个文件。
附1:星号下面的为宏文件
' ***************************************************************************
' 本宏文件用于批量将SW的工程图文件(.SLDDRW)转PDF和DWG。
' 需要开始输入SW的工程图文件所在位置。
' 每个工程图如果超过三张图纸可能会有问题。
' 一次最多只能转500个文件
' 制作者:KEN
' ***************************************************************************
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim PathStr As String
Dim FName(500) As String, FNum As Long
Sub main()
Dim i As Long
Dim PathStr0 As String, PathStr1 As String
pdf转html
Dim PathStr2 As String, PathStr3 As String, PathStr4 As String, PahtStr5 As String
Dim L As Long, L1 As Long
PathStr = InputBox("请输入需要转的工程图所在位置")
Call Showfilelist(PathStr)
Set swApp = Application.SldWorks
For i = 0 To FNum - 1
    PathStr0 = PathStr & "\" & FName(i)
    Set Part = swApp.OpenDoc6(PathStr0, 3, 0, "", longstatus, longwarnings)
    L = Len(PathStr0)
    PathStr1 = Left(PathStr0, L - 7) & ".DWG"
    PathStr2 = Left(PathStr0, L - 7) & ".PDF"
    longstatus = Part.SaveAs3(PathStr1, 0, 0)
    longstatus = Part.SaveAs3(PathStr2, 0, 0)
   
    Set Part = Nothing
   
    L1 = Len(FName(i))
    PathStr3 = Left(FName(i), L1 - 7) & " - 图纸1"
    PathStr4 = Left(FName(i), L1 - 7) & " - 图纸2"
    PathStr5 = Left(FName(i), L1 - 7) & " - 图纸3"
   
    swApp.CloseDoc PathStr3
    swApp.CloseDoc PathStr4
    swApp.CloseDoc PathStr5
Next i
End Sub
Private Sub Showfilelist(folderspec As String)
    Dim fs, f, f1, fc, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(folderspec)
    Set fc = f.Files
    FNum = 0 '清零
    For Each f1 In fc
        If InStr(f1.Name, "SLDDRW") > 0 Then
            FName(FNum) = f1.Name
            FNum = FNum + 1
        End If
    Next
End Sub