|
$ S3 N% V g# N! V2 ^
分享在他網的回覆; g6 S1 d: [! J# X/ U: h0 v. O
`: o: Y) e i% m5 w8 ]2 M
4 i) i, c9 }# e6 B
, s+ U2 _! e. o# y7 t( l
1 q( c! m: ?8 j9 \. R
* X1 W0 @3 A) R- J/ g- ' ************************************************************************************) `& W0 w& X: T: K: {' p( D" u8 y
- ' 依據配置特定屬性之"件號"及"名稱"存檔 - macro recorded on 10/30/18 by scliang0 h( H) S9 q+ e. ^! F
- ' ************************************************************************************
) Q* ?+ K# s4 u: p8 l4 f
" ^, _9 c$ {; s8 c$ M- Dim swApp As SldWorks.SldWorks: e# W p2 C$ f: K. T5 T
- Dim swModel As SldWorks.ModelDoc2
7 Z( i* Y) a! c0 z ^ - Dim swConfigMgr As SldWorks.ConfigurationManager
8 V0 @) t& T4 A) \5 F - Dim swConfig As SldWorks.Configuration% o0 p8 m" l& n% ? o+ M0 r
- Dim swCustPropMgr As SldWorks.CustomPropertyManager
; O, b+ x, o) I3 w7 l7 H - Dim nNbrProps As Long
2 i M, Q! t e7 \" o - Dim Part As Object2 e w& L( R5 g9 w' u! Y5 K
- Dim Code_Name(2) As String
7 i9 E# g' ~/ m - Dim valOut As String
+ a2 E# k, u6 w) P' w1 o6 ^ - Dim resolvedValOut As String, b' G/ m7 `3 a0 [ Y
- Dim longstatus As Long: W* ^. ~' }- {% {( t
- $ o% ~6 |+ B& g$ a% d
* \, h4 Q1 r6 O- B! E% o; o- Sub main()
6 v9 K2 ~+ m( S1 {' i% B* X
$ L0 H' S4 }1 k9 y# J2 Z4 _- Set swApp = Application.SldWorks1 t+ E s' z% k9 ~( S* v* ~
- Set swModel = swApp.ActiveDoc
$ Y% X7 [ a ~) B- o! g - Set swConfigMgr = swModel.ConfigurationManager1 V" ? H* x9 A/ I7 b+ ^
- Set swConfig = swConfigMgr.ActiveConfiguration: |5 [$ j9 q! R& W) c% w; a
- Set swCustPropMgr = swConfig.CustomPropertyManager- I) B8 C# T K" a/ V6 ?' [
- ' Get the number of custom properties for this configuration% W; l+ ?$ C; h0 ~& f: U
- nNbrProps = swCustPropMgr.Count q! L/ z8 S1 ~7 f: b; H
- vPropNames = swCustPropMgr.GetNames4 f( n# k" \7 Y) }
- For j = 0 To nNbrProps - 1: i# v$ |. t+ Q$ R. b+ F! n
- swCustPropMgr.Get2 vPropNames(j), valOut, resolvedValOut
* j2 H. o5 |% K: P1 j' W3 X* z - If vPropNames(j) = "代號" Then Code_Name(0) = valOut* k6 l. m" V" }0 w2 t9 V
- If vPropNames(j) = "名稱" Then Code_Name(1) = valOut
; H* a6 y* X6 Y) [) {& [( I - Next j1 J, C: d: {& Z) M
- 'Debug.Print " Name, type, and resolved value of custom property: " & "代號: " & Code_Name(0) & " ----- " & "名稱:" & Code_Name(1): ^9 k; V7 A( p. D( b* [/ _. a% V
- Path_Name = swApp.ActiveDoc.GetPathName '取得"路徑名稱及擴展名",不管擴展名是否隱藏
0 J5 U @' S' k! z - Path_ = Left(Path_Name, InStrRev(Path_Name, "")) '提出路徑
+ T5 l6 C" o8 ^5 d7 b8 f - Set Part = swApp.ActiveDoc4 y3 z, p# i. Z# X* m7 E E2 o
- longstatus = Part.SaveAs3(Path_ & Code_Name(0) & " " & Code_Name(1) & ".SLDPRT", 0, 2) '依據配置屬性"件號"及"名稱"存檔
; u5 R2 A& c4 ` L, t* _- D" L* F
. t' [* Y1 r2 t- End Sub
5 D$ _- M% v: {/ K8 c
復制代碼
9 e& O& h, b$ I- U4 C8 h1 T$ w& ~
|
本帖子中包含更多資源
您需要 登錄 才可以下載或查看,沒有賬號?注冊會員
×
評分
-
查看全部評分
|