|
7 U) _# d; b6 @7 R分享在他網的回覆1 x1 B, f* ^$ z5 A1 A y
' m+ W9 i; `5 P6 H" \1 _1 C; n: q8 H- X1 E- P: y' v: Z, V
! q3 c( P, X0 |( r/ ]
* ^# g; }% c7 I1 s. {, g% q
/ o9 v0 A# U0 @
- ' ************************************************************************************9 F# H9 O% E+ l+ N3 F
- ' 依據配置特定屬性之"件號"及"名稱"存檔 - macro recorded on 10/30/18 by scliang
5 }! B9 i- G2 @ - ' ************************************************************************************5 J* N" m$ \5 j! x
- - T4 Z/ h& B8 K$ w4 S. y7 _
- Dim swApp As SldWorks.SldWorks
& H: P" S, m6 x2 k+ c" P/ R - Dim swModel As SldWorks.ModelDoc2
. p) X( H. s1 G2 t2 M+ B* p# w - Dim swConfigMgr As SldWorks.ConfigurationManager
- T/ }3 i' m# ^5 d& ` - Dim swConfig As SldWorks.Configuration2 n, W9 ^, u6 Y; w6 k- i& `3 O
- Dim swCustPropMgr As SldWorks.CustomPropertyManager
5 t8 X# B& i2 Y - Dim nNbrProps As Long7 t- i" o0 c" Q. m3 S
- Dim Part As Object
: a5 Q5 A# ~( H0 `4 W8 F% v - Dim Code_Name(2) As String! M3 b/ L! m ]; |" X) P0 j
- Dim valOut As String* a8 _: q" R1 [( c, c: R
- Dim resolvedValOut As String( o9 b9 U4 `: O! Y4 F! H& G
- Dim longstatus As Long
2 S8 r& t( u9 X* Q4 i - 1 }8 O. ?5 V+ S3 H
' E' k: }& M. T$ _0 H- Sub main()6 j% ], L0 [6 e2 [9 D
- : |1 f* I6 @2 n2 c1 o9 m, W) P
- Set swApp = Application.SldWorks# f4 X5 M2 h2 v1 _/ Z$ r
- Set swModel = swApp.ActiveDoc g+ b, ^, _9 e; M6 l
- Set swConfigMgr = swModel.ConfigurationManager
$ ?; n8 c! W7 Z% [# e - Set swConfig = swConfigMgr.ActiveConfiguration
1 }" V- A/ B, B$ ?' j - Set swCustPropMgr = swConfig.CustomPropertyManager
8 B) m5 q9 W! e+ G: r - ' Get the number of custom properties for this configuration
8 P/ F7 k5 G) a' O, i/ F$ w - nNbrProps = swCustPropMgr.Count
5 i% ]1 l" |) @ - vPropNames = swCustPropMgr.GetNames
4 \1 N5 M- r* x" B4 p6 } - For j = 0 To nNbrProps - 1* }) p0 B, U4 G
- swCustPropMgr.Get2 vPropNames(j), valOut, resolvedValOut8 z |7 ^1 d! V! x; ~
- If vPropNames(j) = "代號" Then Code_Name(0) = valOut
2 S! n" K3 B; p: B! }1 ~: b - If vPropNames(j) = "名稱" Then Code_Name(1) = valOut0 O p4 |1 \1 J O. p
- Next j: l4 {1 h( {4 J$ p
- 'Debug.Print " Name, type, and resolved value of custom property: " & "代號: " & Code_Name(0) & " ----- " & "名稱:" & Code_Name(1)
* ~2 b+ Y! C; K) ?7 X: U: l - Path_Name = swApp.ActiveDoc.GetPathName '取得"路徑名稱及擴展名",不管擴展名是否隱藏8 C2 H& X1 F w2 ?: `+ `
- Path_ = Left(Path_Name, InStrRev(Path_Name, "")) '提出路徑/ }) _. \1 g5 F
- Set Part = swApp.ActiveDoc
1 q# H1 T0 Z) E& T3 m4 e; { - longstatus = Part.SaveAs3(Path_ & Code_Name(0) & " " & Code_Name(1) & ".SLDPRT", 0, 2) '依據配置屬性"件號"及"名稱"存檔6 c5 p& z f! ~- x* p' P
" ^& a s- L9 ]$ f& d: q- End Sub: n3 R7 s( C: E" J. t# _9 O3 B
复制代码 + O$ I( A- V% T
, J* J, I; H. _ x8 e
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
评分
-
查看全部评分
|