|
N4 W- S( u/ k; y5 D) a
分享在他網的回覆
% c% g5 ~. w1 _! c1 M; u* y' U4 G) H9 f8 X4 ?) h
: D, l0 j8 x& R% H4 j Y y* |* n; u- P0 j' J, h
: O5 B" a4 O9 q! }" b, \3 k9 E8 F0 u2 i# Q* P; b/ z! b" g8 Z
- ' ************************************************************************************
$ ]5 h- B/ h3 s; [3 x4 i8 k - ' 依據配置特定屬性之"件號"及"名稱"存檔 - macro recorded on 10/30/18 by scliang. i8 P- E5 o7 U
- ' ************************************************************************************
4 H! ^2 q2 L" t% C
( [6 Z/ k" Z% L V- x- Dim swApp As SldWorks.SldWorks h, F* @, Z2 J0 u; Q
- Dim swModel As SldWorks.ModelDoc2- k; t: E _# U! |" p
- Dim swConfigMgr As SldWorks.ConfigurationManager
, `$ X* A" a2 z - Dim swConfig As SldWorks.Configuration; t8 D _' |( [7 k4 p
- Dim swCustPropMgr As SldWorks.CustomPropertyManager
" J& K3 {/ n9 z+ P6 o1 l4 T - Dim nNbrProps As Long
) ~" j5 }+ I- t - Dim Part As Object
( v! m: u% `! V2 m0 E' q$ B# t - Dim Code_Name(2) As String+ e3 j/ _7 ]. I
- Dim valOut As String
; K8 B! t) j$ C" ^8 g0 Y8 ^ - Dim resolvedValOut As String
5 y6 K0 f7 h: R3 x% v' A5 s) h - Dim longstatus As Long1 E" B4 L0 O/ L6 x
- x; N+ C# g; m% C! q- 9 p, K8 ~1 X' S1 `: U1 L5 S6 h' p
- Sub main()+ @' s) [! }$ {8 {( t. ?" @
+ `! C, P/ R: E# `- Set swApp = Application.SldWorks4 s. L8 r7 p- F% H
- Set swModel = swApp.ActiveDoc E6 Z& U) i* B3 ~9 j% t$ }* q9 F8 j
- Set swConfigMgr = swModel.ConfigurationManager& T' I' V( z0 r9 z. `# G" V8 p
- Set swConfig = swConfigMgr.ActiveConfiguration6 Y5 q3 H. m# P v
- Set swCustPropMgr = swConfig.CustomPropertyManager9 D7 M: w5 N& H, }) p
- ' Get the number of custom properties for this configuration4 u; j1 l' U% I& Q' w( L
- nNbrProps = swCustPropMgr.Count9 V0 L. c! a$ q' c, m% Z. ^
- vPropNames = swCustPropMgr.GetNames1 @8 w5 f6 n' x: B2 n
- For j = 0 To nNbrProps - 1
2 O$ L+ N& d1 r7 ]7 @' n# u - swCustPropMgr.Get2 vPropNames(j), valOut, resolvedValOut
( W: Z& c5 ~# Y1 E! Q. w3 I - If vPropNames(j) = "代號" Then Code_Name(0) = valOut0 D" W6 l# g* }% y) }
- If vPropNames(j) = "名稱" Then Code_Name(1) = valOut
% a5 \5 _/ h- @# a% C# i7 J - Next j9 Z/ m# M3 T, q) @; [# q% m
- 'Debug.Print " Name, type, and resolved value of custom property: " & "代號: " & Code_Name(0) & " ----- " & "名稱:" & Code_Name(1)
. H' \" }5 g6 Y; a- }" M3 u" V - Path_Name = swApp.ActiveDoc.GetPathName '取得"路徑名稱及擴展名",不管擴展名是否隱藏4 J% R# y8 J! U' h
- Path_ = Left(Path_Name, InStrRev(Path_Name, "")) '提出路徑: P; I- H$ @5 ^! a: G
- Set Part = swApp.ActiveDoc
7 Z f: k0 b% T$ j4 g - longstatus = Part.SaveAs3(Path_ & Code_Name(0) & " " & Code_Name(1) & ".SLDPRT", 0, 2) '依據配置屬性"件號"及"名稱"存檔$ F) v4 q) u) T; z
- " K$ V; n$ `% N, ~8 l4 p
- End Sub9 J7 k- N1 l' N+ r; M
复制代码
0 \) F' G, c% z. u
! ~0 X3 e' V4 P/ @% p7 K |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
评分
-
查看全部评分
|