SOLIDWORKS Task Schedular我试了,根本动不了,自己也倒腾了个宏,功能是工程图转换成PDF和DWG文件,操作是,工具---》宏----》新建----》把下面的代码复制进去----》存到硬盘某个位置----》,调用的时候是,工具----》宏---》运行,当然也可以自定义到SW的工具栏上,宏文件源代码如下需要的拿去,:/ O9 S7 H" [% ~. Z, F3 R! A
Dim swApp As Object8 r! Y o4 d3 ?0 A8 d
Dim Part As Object$ {# Q# h- T' M( Z1 I3 ^
Dim boolstatus As Boolean
- y$ g* q# L$ n2 Y. C1 CDim longstatus As Long, longwarnings As Long
9 c! t3 f7 R3 P) a# uDim PathStr As String
5 \+ C" j4 t+ X3 }Dim FName(500) As String, FNum As Long
6 e+ C5 g/ l2 [: M: t, T; R6 g; n& j9 ~& {: ]
Sub main()
) C+ ^! p8 v* p& x- d. KDim i As Long
* Z5 T3 R p! {$ @Dim PathStr0 As String, PathStr1 As String+ k ?! H* N1 D: x8 H& V. P4 f+ v$ r
Dim PathStr2 As String, PathStr3 As String, PathStr4 As String, PahtStr5 As String
2 W4 z/ {9 ?! _Dim L As Long, L1 As Long
' B' H/ O. L4 x; _8 W! M4 e7 K9 `PathStr = InputBox("请输入需要转的工程图所在位置")# z0 c% a9 o2 A3 _
Call Showfilelist(PathStr)7 x3 t7 c' t- C2 z$ ]. F
Set swApp = Application.SldWorks
& g& x$ Q! K: V- e$ ]* ^4 _
" ~% x5 I A, {6 IFor i = 0 To FNum - 1* h( B/ l+ x& X* c2 {4 L3 i, C4 F) V
PathStr0 = PathStr & "\" & FName(i)
" c) Y6 ~( ^" v* Y1 E Set Part = swApp.OpenDoc6(PathStr0, 3, 0, "", longstatus, longwarnings). ^ P+ A# d9 M1 H2 P
L = Len(PathStr0)4 K9 m& ?+ e8 O) P2 u" \$ N
PathStr1 = Left(PathStr0, L - 7) & ".DWG"
: Z @2 A n/ j3 h" F PathStr2 = Left(PathStr0, L - 7) & ".PDF"
g/ o0 D9 f [0 U% ?( U' U/ |3 v3 g longstatus = Part.SaveAs3(PathStr1, 0, 0)
% p% b- l. Y$ c4 E @- F1 j longstatus = Part.SaveAs3(PathStr2, 0, 0)+ n% }9 ~( C6 x! U/ @
8 Z* }3 n2 Z/ Y: i4 }/ [7 V) { Set Part = Nothing
9 p9 E9 O+ \+ D8 v( ^' C # }4 v$ U6 B* S! S. u" H$ g
L1 = Len(FName(i))- z! W8 D n+ ? f& a6 R
PathStr3 = Left(FName(i), L1 - 7) & " - 图纸1"0 l4 Q( q3 q/ q
PathStr4 = Left(FName(i), L1 - 7) & " - 图纸2"% e$ ]9 \. B r1 g: Z
PathStr5 = Left(FName(i), L1 - 7) & " - 图纸3"
6 n3 o) t2 n5 O % a# C, `2 E% z
swApp.CloseDoc PathStr3
3 J2 s- V( K. M8 W- v8 z. b7 a+ C swApp.CloseDoc PathStr4
! a, _8 W3 X. @. V. k' `1 o5 i# v* L swApp.CloseDoc PathStr5
% s% |3 _: A) [- y
1 G. c8 Z5 o* w+ rNext i
# D& ]. w$ f1 ?& W
$ w: n4 @, [5 V# \# K( HEnd Sub
$ z7 t" I8 p) a8 Q: W$ h5 B9 c) t7 L1 U& p: E( {$ s
Private Sub Showfilelist(folderspec As String)+ ~7 r- ?" e- @+ U
Dim fs, f, f1, fc, s3 F0 b6 o; s: N1 c, V$ L& ^
Set fs = CreateObject("Scripting.FileSystemObject"): W+ s5 X& b9 ?
Set f = fs.GetFolder(folderspec)
+ r$ H6 x, n& C5 w L3 e) |% z Set fc = f.Files
% H- w* v, k7 C }, } FNum = 0 '清零
% g$ |% ]" ]) s9 w, z1 T For Each f1 In fc
* G5 v M% q& V, u0 @4 ? If InStr(f1.Name, "SLDDRW") > 0 Then; K! Y1 Z0 S p
FName(FNum) = f1.Name* i( B8 ?0 g5 Y+ I1 n7 ^
FNum = FNum + 1
2 t. q8 `* S$ ^( n End If
o7 m2 ]$ I+ c% g( D$ k. ~; | Next
) @3 @( f. G: o& ^8 q3 s6 UEnd Sub
. V& M- d T$ ~; p# p; m |