這個雙引號顯示的是“配置說明”,并非是前面幾個大俠說的圖號分離。從SW原則來說,零件名跟工程圖文件名肯定是同樣的。細看樓主的的截圖就知道前面幾位高手沒說到點上。
% ?* |* L% y5 ^+ p+ [$ Q關于圖號分離問題,是很贊同樓上幾位的。下面是圖號分離宏(分離到自定義,備注:中間間隔符是空格號。可以根據自己需求改動): L& n" z% ~7 v# W
'定義solidwork
0 R2 @& D+ C& i* k2 Z5 fDim swApp As Object
) ^4 |4 R0 F0 w O/ G5 b& @, BDim Part As Object5 {, }, U! l8 V6 j
Dim SelMgr As Object' ^2 `+ j* C' D/ T p# w
Dim boolstatus As Boolean
$ ~5 w O3 S1 [# ZDim longstatus As Long, longwarnings As Long9 U# g) E$ s4 J o. v0 ]: h9 N+ e
Dim Feature As Object
' p# u7 L$ k a+ @+ t8 u2 i# dDim a As Integer
, Q4 _ ]. b: H) yDim b As String3 q% }. n8 y0 Y7 _- _
Dim m As String5 Y. u8 e# {; q' _4 I) v1 I* l0 p
Dim e As String6 L; z: z' N5 V1 g
Dim k As String# I, r) ^2 H5 a+ e3 @' G
Dim t As String
9 ]+ H; u m* j; w- A/ v1 _Dim c As String
" Y3 V$ d5 s7 R/ q! S9 fDim j As Integer
& u% _& Q, F1 k3 x0 B$ ODim strmat As String
* Z* J, @3 U& w! S# LDim tempvalue As String
3 ]& E+ T* f+ lSub main()
2 A4 q, U: c& q( E1 N" {'link solidworks
l2 Q2 p2 K0 U, ~Set swApp = Application.SldWorks6 P+ T& G7 n8 E8 S9 {* t( |. |
Set Part = swApp.ActiveDoc
, x2 R" _& t: X+ USet SelMgr = Part.SelectionManager# y& H9 E0 g1 l" \; [% F3 S0 a9 @# C
swApp.ActiveDoc.ActiveView.FrameState = 13 G, E. E+ E* w. i0 j/ R
'設定變量- B/ q) K" F1 q$ S0 w; T
c = swApp.ActiveDoc.GetTitle() '零件名$ P7 y% o6 E, I- n+ j. ]! K( p
strmat = Chr(34) + Trim("SW-Material" + "@") + c + Chr(34)
( b: q% @$ L( `6 @1 |1 fblnretval = Part.DeleteCustomInfo2("", "代號")
{+ B- G% V+ y) i: n5 `8 o& T( l4 @blnretval = Part.DeleteCustomInfo2("", "名稱")
8 t3 E" e5 W3 @% @/ X/ M3 u" wblnretval = Part.DeleteCustomInfo2("", "材料")
3 H3 `/ l. f4 W2 i1 T3 J" t+ ha = InStr(c, " ") - 1 '重點:分隔標識符,這里是一個空格
% |' \6 S' C4 h# i% V0 YIf a > 0 Then
0 g0 R: c8 V% Q k = Left(c, a)4 s0 @- ?6 y, h* w4 K
t = Left(LTrim(e), 3); P+ a) U& t& A2 @$ }9 c& ^
If t = "GBT" Then4 F4 w" Q2 ^' P. r4 O/ e0 s4 }9 W
e = "GB/T" + Mid(k, 4)8 p/ g. M0 u; b2 J7 t
Else* Y" u. q+ Z3 Z! W3 v
e = k
$ B9 v% f ?6 ~; k- g End If* p) Q, t$ v, v. Y* C) m
b = Mid(c, a + 2)
, r+ o1 [1 X: Y7 A @: Y t = Right(c, 7)) v& G* }. t- m" c
If t = ".SLDPRT" Or t = ".SLDASM" Then
5 [! T& x3 P' [0 U8 ]. _ j = Len(b) - 7+ `: j% a5 k! K
Else
2 |7 O2 t5 i! I4 m- e j = Len(b)
. J3 f D% Z1 r& b# ]# I4 w, G End If
7 s0 z4 H; L# s9 A, F m = Left(b, j)3 M' l: d* Y+ w! ]5 O
End If8 A2 o9 ?2 O& W- m9 Z" |
blnretval = Part.AddCustomInfo3("", "代號", swCustomInfoText, e) '代號( L) _) ]; n$ P6 F- b2 L1 Y
blnretval = Part.AddCustomInfo3("", "名稱", swCustomInfoText, m) '名稱
, m/ q" E8 ? W( kblnretval = Part.AddCustomInfo3("", "作者", swCustomInfoText, " 劉騰qq420221716")* T, K' O. Y- X5 o4 ^, x
End Sub
8 U' }( ]# [2 ]; P% C. m |