|
% Q6 ~: D" o, Y* w7 d9 [分享在他網的回覆. @0 ]" S" r5 d
" E4 F2 U" V9 R# N4 m G6 m* I% l
; K/ L8 {2 V, p6 I* e: F i
% l' F; Y, D8 V5 t
2 o5 b& v2 Y( Y" ]; h
% P) [" T4 g0 A2 M4 L' ~- Q4 \- ' ************************************************************************************
9 n: U1 O, e. r4 j" C: I - ' 依據配置特定屬性之"件號"及"名稱"存檔 - macro recorded on 10/30/18 by scliang
& h" L3 H4 @& \ - ' ************************************************************************************- y0 ^1 L4 B! f& K9 A
- 7 r+ T, W" `$ i# w6 c
- Dim swApp As SldWorks.SldWorks4 } O6 x; U- k( O+ E
- Dim swModel As SldWorks.ModelDoc2
3 _( K6 S4 U7 {& L Q - Dim swConfigMgr As SldWorks.ConfigurationManager
, n. H% ~8 b+ {; b' p. M - Dim swConfig As SldWorks.Configuration3 |+ ^( I9 ?- v7 T
- Dim swCustPropMgr As SldWorks.CustomPropertyManager) \5 a# c+ Q2 V
- Dim nNbrProps As Long
1 T5 ~3 i- A6 R% g' K - Dim Part As Object
) s- @' q& Y! |5 x! d+ T - Dim Code_Name(2) As String
, D! N) _4 v u4 L) S/ T - Dim valOut As String
3 L8 [9 O# m$ W. U* e - Dim resolvedValOut As String
; ?6 u% v6 T: [; ^8 q3 L0 ` - Dim longstatus As Long, q5 b) ^- ^ Y1 p3 @
% Y7 P z& J5 D1 t- / R/ s, I# _4 T, K! m# X3 | d& \
- Sub main()! M( B; V# t1 a+ l* P# R$ q' [
7 A6 G8 d. D9 \2 X8 ?2 m: N" i- Q- Set swApp = Application.SldWorks8 V, h5 y4 R* Z1 \ j/ p. U
- Set swModel = swApp.ActiveDoc
" l+ L5 h" B4 b: g" I - Set swConfigMgr = swModel.ConfigurationManager
. ?& k; d% G& c3 l. M0 K2 L - Set swConfig = swConfigMgr.ActiveConfiguration
* K: R2 z, V7 C* f - Set swCustPropMgr = swConfig.CustomPropertyManager; E* \$ k- _) \
- ' Get the number of custom properties for this configuration
+ L( P5 y$ D% c7 B& `! U - nNbrProps = swCustPropMgr.Count+ T& f: v9 w0 C" @
- vPropNames = swCustPropMgr.GetNames- G' D+ O) l! \/ A0 V" Y' Y0 ?" ]4 P' d8 Z
- For j = 0 To nNbrProps - 1, M# c$ H% p* w; L U# K" D
- swCustPropMgr.Get2 vPropNames(j), valOut, resolvedValOut; y9 c4 D' W7 e# P* p; n& |
- If vPropNames(j) = "代號" Then Code_Name(0) = valOut
o6 t3 o2 ?2 P1 p+ q$ `6 n: W - If vPropNames(j) = "名稱" Then Code_Name(1) = valOut
/ k0 }9 q* w% J5 L$ R8 f) R - Next j! Y0 C. a/ f' m, E
- 'Debug.Print " Name, type, and resolved value of custom property: " & "代號: " & Code_Name(0) & " ----- " & "名稱:" & Code_Name(1)& ^0 I0 m: q' y$ a
- Path_Name = swApp.ActiveDoc.GetPathName '取得"路徑名稱及擴展名",不管擴展名是否隱藏9 d' g' W* T2 g. B) K
- Path_ = Left(Path_Name, InStrRev(Path_Name, "")) '提出路徑5 e9 ~8 `1 S- U: u: r4 z( `
- Set Part = swApp.ActiveDoc. l3 m$ Z- W2 ` S
- longstatus = Part.SaveAs3(Path_ & Code_Name(0) & " " & Code_Name(1) & ".SLDPRT", 0, 2) '依據配置屬性"件號"及"名稱"存檔& V8 G0 ]4 f' n0 n5 \
$ {0 O& I: l% X- End Sub
$ u p+ s0 K6 [0 {1 p
复制代码 ! r/ e+ `9 p6 f6 y& t
/ k, w. G9 @9 ] |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
评分
-
查看全部评分
|