《SolidWorks宏-批量转换pdf和dwg.ppt》由会员分享,可在线阅读,更多相关《SolidWorks宏-批量转换pdf和dwg.ppt(9页珍藏版)》请在三一办公上搜索。
1、新建,文件名为“PLZH”,在跳出的窗口里粘贴记最后一页中的内容,保存,运行,找到PLZH.swp文件,在跳出的窗口中输入要转换的工程图路径,软件将会自动转换,期间SW窗口会自动开启和关闭转换的文件转换结束后恢复宏运行前的的状态转换好的PDF和DWG文件都将会在工程图所在文件夹保存,Dim swApp As ObjectDim Part As ObjectDim boolstatus As BooleanDim longstatus As Long,longwarnings As LongDim PathStr As StringDim FName(500)As String,FNum As
2、LongSub main()Dim i As LongDim PathStr0 As String,PathStr1 As StringDim PathStr2 As String,PathStr3 As String,PathStr4 As String,PahtStr5 As StringDim L As Long,L1 As LongPathStr=InputBox(请输入需要转的工程图所在文件夹的完整路径)Call Showfilelist(PathStr)Set swApp=Application.SldWorksFor i=0 To FNum-1PathStr0=PathStr&F
3、Name(i)Set Part=swApp.OpenDoc6(PathStr0,3,0,longstatus,longwarnings)L=Len(PathStr0)PathStr1=Left(PathStr0,L-7)&.DWGPathStr2=Left(PathStr0,L-7)&.PDFlongstatus=Part.SaveAs3(PathStr1,0,0)longstatus=Part.SaveAs3(PathStr2,0,0)Set Part=NothingL1=Len(FName(i)PathStr3=Left(FName(i),L1-7)&-图纸1PathStr4=Left(F
4、Name(i),L1-7)&-图纸2PathStr5=Left(FName(i),L1-7)&-图纸3swApp.CloseDoc PathStr3swApp.CloseDoc PathStr4swApp.CloseDoc PathStr5Next iEnd SubPrivate Sub Showfilelist(folderspec As String)Dim fs,f,f1,fc,sSet fs=CreateObject(Scripting.FileSystemObject)Set f=fs.GetFolder(folderspec)Set fc=f.FilesFNum=0 清零For Each f1 In fcIf InStr(f1.Name,SLDDRW)0 ThenFName(FNum)=f1.NameFNum=FNum+1End IfNextEnd Sub,