|
" k0 x3 }3 j6 a3 }, P: ^分享在他網的回覆
) N* Y' h$ y& Y: j3 U( ^1 W3 ]: ]4 Y) u3 \
- N* b- d' }9 o! t2 u
( c2 Y9 H: W [ E& b" R
/ b- q0 b( T6 D! }# n
& V4 c% V _: ]5 e- ' ************************************************************************************
r) G9 Z+ W$ F) q - ' 依據配置特定屬性之"件號"及"名稱"存檔 - macro recorded on 10/30/18 by scliang2 Q6 Z o5 n2 \# p; h- T- C9 C
- ' ************************************************************************************# m3 q4 i g% o) Y6 U
9 D7 O4 L7 H e8 y" v8 @- Dim swApp As SldWorks.SldWorks
0 A' F9 o. L* N - Dim swModel As SldWorks.ModelDoc2
6 k. C/ D B& i% Y7 G - Dim swConfigMgr As SldWorks.ConfigurationManager3 y6 V. q& r/ ]+ ^
- Dim swConfig As SldWorks.Configuration
. t/ O" ^% [3 k! I) x7 `) Y - Dim swCustPropMgr As SldWorks.CustomPropertyManager
6 _+ V4 l k9 x0 y; h8 W$ N - Dim nNbrProps As Long
3 `+ r" Q! L) Q h2 s8 `" j - Dim Part As Object; K9 b( m& b! J/ F. ^, A* ?
- Dim Code_Name(2) As String8 G0 N) [& Q9 X/ W9 x
- Dim valOut As String
4 P6 v) i5 ^1 r* z' h+ G/ n - Dim resolvedValOut As String/ b! g6 B, E0 l2 J
- Dim longstatus As Long
" `5 N; V+ j9 E9 i \
$ ?, e8 y, z* y0 y
" a i' |& t. p8 \1 a- Sub main()+ W# Z( u$ V2 d+ ]0 n/ _" b6 P4 p
7 A5 u: W7 ~1 T. [% T7 z* \- Set swApp = Application.SldWorks
2 U: D5 ?% s9 C8 q' V3 t$ C - Set swModel = swApp.ActiveDoc- t# i' w% q1 I/ i9 e
- Set swConfigMgr = swModel.ConfigurationManager
+ @7 {; O. u6 _, M - Set swConfig = swConfigMgr.ActiveConfiguration
9 M- Q+ K% ?! h/ T) f - Set swCustPropMgr = swConfig.CustomPropertyManager* O% X' }4 v: ~
- ' Get the number of custom properties for this configuration6 d8 H0 Z4 Y3 r. U! W, q
- nNbrProps = swCustPropMgr.Count9 @1 p! w m$ x) z, Z
- vPropNames = swCustPropMgr.GetNames% X# y5 h i8 ^( O7 j' F) D2 z$ L
- For j = 0 To nNbrProps - 1
1 j! h* _5 L8 q/ c; p; w - swCustPropMgr.Get2 vPropNames(j), valOut, resolvedValOut
- B# J! w b3 ^% D, ^ - If vPropNames(j) = "代號" Then Code_Name(0) = valOut% L6 x7 ]* L+ c: x7 [
- If vPropNames(j) = "名稱" Then Code_Name(1) = valOut
7 K- M8 \& H" S( b4 L - Next j
1 X, M5 S$ W/ R" c# @" \% W - 'Debug.Print " Name, type, and resolved value of custom property: " & "代號: " & Code_Name(0) & " ----- " & "名稱:" & Code_Name(1)
. Y `, d* t: ^ - Path_Name = swApp.ActiveDoc.GetPathName '取得"路徑名稱及擴展名",不管擴展名是否隱藏
0 X8 k% J* r3 v- W) z4 L# _ - Path_ = Left(Path_Name, InStrRev(Path_Name, "")) '提出路徑
, c4 z; j8 Z' t6 D) U - Set Part = swApp.ActiveDoc
" J- E9 ]5 ^2 Z - longstatus = Part.SaveAs3(Path_ & Code_Name(0) & " " & Code_Name(1) & ".SLDPRT", 0, 2) '依據配置屬性"件號"及"名稱"存檔( f- L' V( p% ?' i
! J7 \" Y! D" U& H- End Sub
) {3 M9 }2 Q L8 N* Y5 k
复制代码
4 j; ^9 [/ p$ ?) L
) M9 x, c6 r7 r7 r( A6 Z8 W( H+ R) x |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
评分
-
查看全部评分
|