|
8#
楼主 |
发表于 2021-1-5 14:38:45
|
只看该作者
加了条语句,已经搞定了。谢谢大家的帮助。
, m0 s" q8 ~8 w'设定变量
# ^3 m9 ^) Z' p0 p% ]9 f6 Vc = swApp.ActiveDoc.GetTitle() '零件名
2 P/ N. g @- H- KIf Asc(c) > 0 Then+ G" G( C2 D. a( ^* d% S
0 ~4 H$ b1 Q3 I0 g9 S9 Y
strmat = Chr(34) + Trim("SW-Material" + "@") + c + Chr(34)/ Y3 Q: M7 J8 X; D9 n
blnretval = Part.DeleteCustomInfo2("", "代号")
4 M1 V( u3 I0 Z$ W6 r# m: mblnretval = Part.DeleteCustomInfo2("", "名称")
8 M! V5 M; s; p, Na = InStr(c, " ") - 1 '重点:分隔标识符,这里是一个空格0 j/ x- H o' k
If a > 0 Then8 h* H: P; q# Z" G8 `, j3 C" C
k = Left(c, a)
' Y* ~) ]9 q) X5 i; b2 v a7 |# u. T t = Left(LTrim(e), 3)
3 k: y. M/ ~8 Y; o If t = "GBT" Then
/ }% @* B ^" _( B2 L& P e = "GB/T" + Mid(k, 4)
* b5 I: X' e% O: O* n3 T: @ Else5 K2 x. Y6 v( q: j( V
e = k
6 n6 ^' c, O2 @5 I0 q End If
8 r# \3 |% u; T ?1 l b = Mid(c, a + 2)
7 V: h/ [7 \; s# p) W9 R t = Right(c, 7)5 y9 e* Z% B1 j3 I7 [9 m3 p
If t = ".SLDPRT" Or t = ".SLDASM" Or t = ".sldprt" Or t = ".sldasm" Then3 o2 E, p b0 Y7 f* D
j = Len(b) - 7 '消除后缀(区分大小写共4种)
9 @( i% m1 K$ H0 O; F8 M Else
" f" S3 u H* Q7 l' Y$ ] j = Len(b)) ]* B% r- D6 t7 p: F$ [5 }
End If- u( E' r$ W5 p1 T9 |: W
m = Left(b, j)" o% Q9 p$ G/ w- [! @0 [& ^
End If
$ K# v* m0 L* o, B5 Cblnretval = Part.AddCustomInfo3("", "代号", swCustomInfoText, e) '代号
8 N, k+ W/ y8 _0 f/ ~6 T% w% ?blnretval = Part.AddCustomInfo3("", "名称", swCustomInfoText, m) '名称
8 T' H5 ]9 D+ y+ p/ ?9 n2 s'blnretval = Part.AddCustomInfo3("", "图号", swCustomInfoText, e) '图号
8 m, Q/ t) H5 e8 i7 x0 |End If A5 l6 M2 G: o9 l& B) L5 m
|
|