這個雙引號顯示的是“配置說明”,并非是前面幾個大俠說的圖號分離。從SW原則來說,零件名跟工程圖文件名肯定是同樣的。細看樓主的的截圖就知道前面幾位高手沒說到點上。4 g$ F& \3 [2 @/ Y- G$ b5 a
關于圖號分離問題,是很贊同樓上幾位的。下面是圖號分離宏(分離到自定義,備注:中間間隔符是空格號。可以根據自己需求改動)# C! x" e! c$ u' P
'定義solidwork( B0 W2 [4 H, L4 w1 {
Dim swApp As Object! b- U: }8 G3 K& |, z. R4 P
Dim Part As Object
4 D5 Q$ k9 u. c. uDim SelMgr As Object
( H- U' T l( Q7 g. A+ aDim boolstatus As Boolean
/ S. o& ]1 r8 ?& W, VDim longstatus As Long, longwarnings As Long5 R1 O5 O/ k( C! }0 b, u
Dim Feature As Object; k7 ~% n) M! R' }# \
Dim a As Integer# d, L: j; _3 \
Dim b As String
% O7 G; o" Y5 X2 y* LDim m As String
% ^" c$ e9 g% t6 J1 n' XDim e As String) }; U+ B; {9 U' W T8 l
Dim k As String( n3 C+ y0 s; W1 j; e
Dim t As String2 {9 g7 H! l" R# K- i8 @
Dim c As String% K5 U1 _* w9 \& O% ?, s0 `/ h
Dim j As Integer5 ^7 G% [* p3 H" G9 U9 X0 ?) M
Dim strmat As String
/ i, X) Z% P% t6 b7 u3 ]0 f& D2 MDim tempvalue As String
" g9 o9 t y2 N5 ISub main()
$ `8 \$ n* s" d: N; e'link solidworks
9 t( |- q! }+ p5 B7 R: U4 p9 LSet swApp = Application.SldWorks5 l; ]8 ?. Z% V% C# b$ b1 A7 B
Set Part = swApp.ActiveDoc5 P v4 M& C7 ~- o- b r' F% l
Set SelMgr = Part.SelectionManager
* l8 O2 ^, a6 b3 eswApp.ActiveDoc.ActiveView.FrameState = 1" Q8 r9 ]% H. F+ y) s0 U0 m
'設定變量) `% g1 C" C) t9 \
c = swApp.ActiveDoc.GetTitle() '零件名: d& S; s; t; [5 I6 v
strmat = Chr(34) + Trim("SW-Material" + "@") + c + Chr(34)
( R5 O- a' f, p4 Iblnretval = Part.DeleteCustomInfo2("", "代號")
5 O- x( H h2 G% J5 }, p: Wblnretval = Part.DeleteCustomInfo2("", "名稱")+ m5 G1 T2 ^& `5 B! O" W3 g
blnretval = Part.DeleteCustomInfo2("", "材料")
+ [" w* h( | Ea = InStr(c, " ") - 1 '重點:分隔標識符,這里是一個空格( Q; B* G' ^/ L/ Z! e2 B" y4 ?
If a > 0 Then
( i+ X% ]' X2 q; [) g7 T% e5 ~ k = Left(c, a) l/ Y4 P$ @5 r" F$ g- p* p! g4 w
t = Left(LTrim(e), 3)1 i0 @. B* O6 c6 {' V5 @, @
If t = "GBT" Then
7 d( E/ |$ r( u8 c8 E- r e = "GB/T" + Mid(k, 4)
+ ~9 [8 ^" ~- ^/ }% }$ k4 L Else0 I2 x) G, B& ?3 }
e = k
2 |! X w" v; |0 b2 U! C End If8 t" D: U$ a* b3 h4 k, l. B- z1 n
b = Mid(c, a + 2)
9 t5 r2 {- O% N' H" s; D t = Right(c, 7). [8 M4 F' j6 b. |" Q7 K# @9 y( N
If t = ".SLDPRT" Or t = ".SLDASM" Then1 [1 m! d" t8 r) g5 y
j = Len(b) - 7
1 U, z' \+ j& V6 n- c" V+ i- h Else
B6 F+ q' i' J" n- W# ? j = Len(b)8 E" E" ]! c x* g( Y0 n
End If# @! ~' R9 O% M- `8 R% u
m = Left(b, j)
( F3 x1 t$ o, x! l* a) f- ~End If2 p' L% b. h7 O3 i5 V3 V, z0 {9 w
blnretval = Part.AddCustomInfo3("", "代號", swCustomInfoText, e) '代號# Q( S2 V( y# M& X. ^; }
blnretval = Part.AddCustomInfo3("", "名稱", swCustomInfoText, m) '名稱
! N' N5 P' j/ g6 ^9 h' r( dblnretval = Part.AddCustomInfo3("", "作者", swCustomInfoText, " 劉騰qq420221716")5 R. H$ B" s3 k1 K" P: W4 Z- Q
End Sub
, |, ^7 W$ u2 ?' h. w f |