|
- S5 F* ^! ^: q' }分享在他網的回覆$ b: P! g( Y/ n* a
! m; k5 ~0 w* J5 o/ f( R. {& G( L7 d. R; k @. H
" l; V: S& _2 g" x( W
- C/ X" d2 Y! S/ a
7 S9 Q/ z& n8 N, k% J6 t% g9 K
- ' ************************************************************************************
8 W l& F/ U/ t5 l - ' 依據配置特定屬性之"件號"及"名稱"存檔 - macro recorded on 10/30/18 by scliang- `6 R9 U$ ~& Z8 P; O
- ' ************************************************************************************
( _ j1 n/ C" j# O
8 Y; \$ _6 Q7 Z' c I' }- Dim swApp As SldWorks.SldWorks: Y) t7 f% B' T. x' f
- Dim swModel As SldWorks.ModelDoc2' O. k- T( s) _3 {6 E4 V1 A; S
- Dim swConfigMgr As SldWorks.ConfigurationManager( b; d* X8 T1 Z2 y9 k; {* a
- Dim swConfig As SldWorks.Configuration
8 e. ?/ @3 v: G4 b' B - Dim swCustPropMgr As SldWorks.CustomPropertyManager4 z# U A( r1 n/ X: f
- Dim nNbrProps As Long
! `& l# s) P% ^# ]" p. [2 h: n - Dim Part As Object+ h H$ I) a/ U# Y% s. ]5 f
- Dim Code_Name(2) As String+ S5 N; m; f, i9 Z$ H0 p2 V+ M
- Dim valOut As String! o) E5 A4 d& Q) }& p9 `
- Dim resolvedValOut As String5 c) V2 i! D* N5 j G" x1 c
- Dim longstatus As Long
3 N. m0 t+ r/ M/ _
C5 L* ^1 r; B$ y- ! G2 p0 g; S4 F2 y* Y. ~4 m2 G
- Sub main()
* Q# E4 o9 H" O0 r - * r& S( D, f+ o; Z; _: t
- Set swApp = Application.SldWorks9 j0 i' C) l7 Y7 Y8 q6 J: K% a
- Set swModel = swApp.ActiveDoc
! q+ A' F3 r+ j! w - Set swConfigMgr = swModel.ConfigurationManager
6 t; q! {; G2 C2 J - Set swConfig = swConfigMgr.ActiveConfiguration
; ]1 ~0 b5 _3 Y# V! B - Set swCustPropMgr = swConfig.CustomPropertyManager$ a, Q( t- q2 l" L
- ' Get the number of custom properties for this configuration
2 u, D5 O- j/ }! Z - nNbrProps = swCustPropMgr.Count
2 H/ Y- Y8 o& F. s# Y: B( D3 F - vPropNames = swCustPropMgr.GetNames: U, Y; r: V) b- O0 h$ O
- For j = 0 To nNbrProps - 1
+ }# p1 @% u K - swCustPropMgr.Get2 vPropNames(j), valOut, resolvedValOut! ^; |7 l4 N' A, @ Z4 j
- If vPropNames(j) = "代號" Then Code_Name(0) = valOut
4 T4 _$ {) h6 X# ` - If vPropNames(j) = "名稱" Then Code_Name(1) = valOut
: j) D" x& N' B/ V" @ - Next j
+ g, L, |4 a9 z$ I8 s, G - 'Debug.Print " Name, type, and resolved value of custom property: " & "代號: " & Code_Name(0) & " ----- " & "名稱:" & Code_Name(1)3 ~6 s2 Y% y# u8 J
- Path_Name = swApp.ActiveDoc.GetPathName '取得"路徑名稱及擴展名",不管擴展名是否隱藏0 Q. G3 m9 e* \( T
- Path_ = Left(Path_Name, InStrRev(Path_Name, "")) '提出路徑
+ @6 W( A, t+ U% s - Set Part = swApp.ActiveDoc
& l# l- X3 g4 C- g! l - longstatus = Part.SaveAs3(Path_ & Code_Name(0) & " " & Code_Name(1) & ".SLDPRT", 0, 2) '依據配置屬性"件號"及"名稱"存檔; u+ P7 D7 _2 h
4 Q7 ?4 _4 A5 Q& C4 p- End Sub7 W1 y( S4 ^$ U
复制代码 9 p3 p" x9 c& L: A) n+ }4 K$ ]
3 D- W$ c& a, T
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
评分
-
查看全部评分
|