这个双引号显示的是“配置说明”,并非是前面几个大侠说的图号分离。从SW原则来说,零件名跟工程图文件名肯定是同样的。细看楼主的的截图就知道前面几位高手没说到点上。
5 l. `- H. B! e6 i$ B" Y6 I关于图号分离问题,是很赞同楼上几位的。下面是图号分离宏(分离到自定义,备注:中间间隔符是空格号。可以根据自己需求改动)8 y4 t6 R6 @$ M! ~+ s
'定义solidwork U$ s% l) d2 }4 V2 k, F: \/ {5 E' @
Dim swApp As Object! K: U9 ?2 c( @- C
Dim Part As Object) V" F, c! T3 V$ F0 _7 n3 c; {
Dim SelMgr As Object
6 l$ y' D* R" }8 SDim boolstatus As Boolean
5 p3 B* t+ W+ D7 ?4 G: mDim longstatus As Long, longwarnings As Long
/ T1 k" w: d) |# SDim Feature As Object
& p. J6 C z. T' u- B u( H$ xDim a As Integer, [' B: V5 Z0 u0 s) `; b3 u
Dim b As String4 ~2 V# Z; j* O& M
Dim m As String
" |9 Z/ S" ~1 i4 {8 y4 F( RDim e As String
1 |* V) y2 T" FDim k As String
* d) x+ {2 y2 M1 S, |8 P. D: XDim t As String
% t) G4 l0 |% z8 T* @- KDim c As String; f, ^ z6 H6 z" E+ G U
Dim j As Integer
; S, V3 g* b1 ]9 J) iDim strmat As String
1 ]1 S5 Y+ c+ y* k7 l1 W1 d1 bDim tempvalue As String3 `- w# o u$ K7 z$ [$ @
Sub main(), E# ^% }( e2 r+ }$ H
'link solidworks$ b5 C. Z( G% i3 q
Set swApp = Application.SldWorks2 z `0 t6 t; y$ g, i
Set Part = swApp.ActiveDoc
" c! r% M: A9 u- m2 w& xSet SelMgr = Part.SelectionManager
, p( s, ^7 I5 P: K, ~swApp.ActiveDoc.ActiveView.FrameState = 1
3 g. t2 Y4 [* Z8 Y0 d2 \9 _( y'设定变量
9 U* p9 w$ K6 d! jc = swApp.ActiveDoc.GetTitle() '零件名
1 u; D! u7 a, dstrmat = Chr(34) + Trim("SW-Material" + "@") + c + Chr(34), `, i2 _: w. P0 E+ B: T) q) Z
blnretval = Part.DeleteCustomInfo2("", "代号")' i, o2 ~/ f$ T5 z, f
blnretval = Part.DeleteCustomInfo2("", "名称"), q+ V2 U3 R* ]' F+ _9 }
blnretval = Part.DeleteCustomInfo2("", "材料")0 [2 v: n, v. O9 v1 [
a = InStr(c, " ") - 1 '重点:分隔标识符,这里是一个空格
, r, E/ \% G5 G0 o. W+ jIf a > 0 Then9 v8 t$ W1 I- h; |
k = Left(c, a)2 W7 t2 U# L2 y* v
t = Left(LTrim(e), 3)8 O6 r: q' s' ?) n; S
If t = "GBT" Then
5 R: Z! \' C' |! ~/ s# w( T) ~ e = "GB/T" + Mid(k, 4)
/ \* c, ^: e9 z& k/ n8 O& v Else
. I" o8 {( z8 c; a e = k0 P9 C' z$ a4 _ Z0 i& `6 J
End If
% I' Z7 s, W/ t b = Mid(c, a + 2)
7 T: `9 L* V' k9 ? t = Right(c, 7)
1 M$ H. h) b, O2 _ If t = ".SLDPRT" Or t = ".SLDASM" Then1 W, ~- O7 z" l% e7 Y7 m
j = Len(b) - 75 P. n( `$ R8 L$ J3 O) E+ |. p
Else
. ^' \+ I' A' ~& k8 v j = Len(b). p4 E. O- Q0 P0 \
End If- ?" o5 B% @: M- G
m = Left(b, j)5 {5 y# d$ \# r# E: P9 ^# Y& D6 G
End If
3 j7 \$ {$ H5 R* `" q- S$ l" ?blnretval = Part.AddCustomInfo3("", "代号", swCustomInfoText, e) '代号0 F/ V# }7 G4 ]7 l) ^8 ^
blnretval = Part.AddCustomInfo3("", "名称", swCustomInfoText, m) '名称
3 ~3 S" h# Y! m- t% zblnretval = Part.AddCustomInfo3("", "作者", swCustomInfoText, " 刘腾qq420221716")
2 i8 ~6 r2 Y! V6 Q$ O/ WEnd Sub
4 _1 x* g0 l+ X |