|
|
发表于 2014-9-17 15:18:14
|
显示全部楼层
来自: 中国台湾
嵌合代碼的方式在2013以後不能再使用了…悶大已經說明過可用其他方式。+ m8 Z1 b1 F: A6 b, b a
提取部份文件名稱寫入「指定配置」的方法如下,做參考了… D' [; Z/ N9 ?" |5 h h
至於要提取前幾碼、後幾碼、分開提取寫入"代號""名稱"等不同的要求…容後討論…
% z2 R9 ~# m6 L以下為:提取文件名稱前七碼寫入當前配置的"partno"屬性欄- E) q% A$ l4 \: J) r
Dim swApp As Object
2 @2 |0 q$ B* N3 q8 Q6 f& O
$ }; @% u: J; ]/ f5 k5 EDim ActivationConfig As String! ~6 J" X: I1 `; ?7 H5 D3 K1 M
Dim retval As String$ ?& G8 c% g# `6 a3 a0 P
Dim Part As Object+ X6 U G2 e) o! x, X* I, M
Dim boolstatus As Boolean
+ k5 x: F K- J2 H' YDim longstatus As Long, longwarnings As Long
7 d7 }+ V5 V4 O- e2 v7 [# o; L% U% C- B# m7 P: y: F! q/ ~
Sub main()
& W! H2 m5 z' e. s% e: r. h+ _
7 y4 h5 C6 K. z8 ]Set swApp = Application.SldWorks% p5 ]8 C/ Z. A6 _, r
% e* d/ c+ |% b4 ?- h6 KSet Part = swApp.ActiveDoc
9 n% f/ G% J3 c: o! a5 ^" rSet SelMgr = Part.SelectionManager
7 K" W0 {6 c/ k. n ISet swConfigMgr = Part.ConfigurationManager$ Y* v% X7 `" }# h- \% Y
Set swConfig = swConfigMgr.ActiveConfiguration
! n' h3 G8 A8 i; NActivationConfig = swConfig.Name
" j4 l2 I& Z( T; I; Y7 C2 V( R c! h8 c
retval = swApp.ActiveDoc.DeleteCustomInfo2(ActivationConfig, "PartNo")$ x5 a3 m# v; ?( @2 j& ?" m, V
retval = swApp.ActiveDoc.AddCustomInfo3(ActivationConfig, "PartNo", swCustomInfoText, Left(Part.GetTitle, 7))3 a7 l/ E( C# s4 j3 A I
' y; O2 a2 j. J$ x6 P
End Sub % r: N+ v: {. J3 Z
5 b; ~" W) s( ]" g' N# ~, l0 Z' b
/ l7 o8 K' z' G' R8 K7 W3 i
- i) H" X7 }! N |
评分
-
查看全部评分
|