|
|
9 b9 O9 t7 O$ q3 ~! x; w" S9 s分享在他網的回覆. I# v2 | T! H& M
4 Q3 P! I* P: ]7 ]
- B, E) J7 U, E) Q
0 _7 s6 S, W( V, T0 A" i8 Q4 W# y( H) ~% [& \' k! C( k
; U* v9 h. N+ e+ M* s4 A
- ' ************************************************************************************
! [: J# L# u( c3 q4 ~# `2 F P - ' 依據配置特定屬性之"件號"及"名稱"存檔 - macro recorded on 10/30/18 by scliang
" W' X- [ q, T - ' ************************************************************************************
8 E" {& Z- ]5 ]# D# G& ~; s - 3 U: p5 u( M) H) ~1 o
- Dim swApp As SldWorks.SldWorks
2 P) d' Y% Z' d6 p - Dim swModel As SldWorks.ModelDoc25 _' |* X' [: u/ F0 ~- T
- Dim swConfigMgr As SldWorks.ConfigurationManager
- F5 f1 V c# `. Z$ O0 R* a X - Dim swConfig As SldWorks.Configuration+ X* [5 P$ _2 Y! w
- Dim swCustPropMgr As SldWorks.CustomPropertyManager
% [$ Z4 i. d# M! S4 @ - Dim nNbrProps As Long1 f& P2 ?0 w( }5 n1 W7 D5 X
- Dim Part As Object) s& M: c, W5 X
- Dim Code_Name(2) As String9 E3 h! u6 W! Q- v; D0 L, J
- Dim valOut As String# [* x, ?! S9 T! p" B: J# w
- Dim resolvedValOut As String% ^- U% p# _4 e
- Dim longstatus As Long
{! t8 P O j. D
0 o% U* E2 o/ } m5 ^
. R* [$ W( N& |- Sub main()3 Q! P! W1 S) J0 T9 u( p3 ~& B' @
- p3 |& k4 S; C/ N$ L" l
- Set swApp = Application.SldWorks
& _# v1 t; s6 E2 S; T" I7 c - Set swModel = swApp.ActiveDoc
/ k4 I) ]0 d, W" m' }) }5 v - Set swConfigMgr = swModel.ConfigurationManager
# c# I* o% ^. h) \" C% D - Set swConfig = swConfigMgr.ActiveConfiguration- L% h0 r: ~. h# z D
- Set swCustPropMgr = swConfig.CustomPropertyManager
( Z0 L1 f% Y5 y L$ G - ' Get the number of custom properties for this configuration* n7 J) r$ ^$ b* q
- nNbrProps = swCustPropMgr.Count
7 ~# o5 S; J9 z- `2 F, } - vPropNames = swCustPropMgr.GetNames1 t" D% h! [$ P* `
- For j = 0 To nNbrProps - 1
" O6 ?) W7 C' y1 Z0 f - swCustPropMgr.Get2 vPropNames(j), valOut, resolvedValOut, q5 q6 q" k/ P( n- h
- If vPropNames(j) = "代號" Then Code_Name(0) = valOut7 |" ^1 x/ R0 W+ b) g$ v! O7 M s- ^
- If vPropNames(j) = "名稱" Then Code_Name(1) = valOut
0 A- J# n2 P+ L4 } I - Next j0 ~6 S6 x# E/ _- j) n6 x
- 'Debug.Print " Name, type, and resolved value of custom property: " & "代號: " & Code_Name(0) & " ----- " & "名稱:" & Code_Name(1)5 w2 l: [, U5 Z% K2 o" Q; }
- Path_Name = swApp.ActiveDoc.GetPathName '取得"路徑名稱及擴展名",不管擴展名是否隱藏
* t, m/ F5 @; [0 _ - Path_ = Left(Path_Name, InStrRev(Path_Name, "")) '提出路徑! M: S6 c8 t7 p& a. l7 V# |, M
- Set Part = swApp.ActiveDoc0 Y5 g6 U, L- d7 J9 R0 ^
- longstatus = Part.SaveAs3(Path_ & Code_Name(0) & " " & Code_Name(1) & ".SLDPRT", 0, 2) '依據配置屬性"件號"及"名稱"存檔: K- V+ u, m: U* W# g/ K$ s4 C
6 A2 B0 p3 B; J, k% Q9 j2 h- End Sub
3 I$ N+ Q t6 Q$ `" {, R5 m, I3 v& z
复制代码
/ s) b) r. ~$ W3 I P7 ^+ ?' ?5 B7 I: [4 {# J
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
评分
-
查看全部评分
|