|
发表于 2018-9-8 14:50:33
|
显示全部楼层
宏處理/ E+ _' d, S% x
: y y1 W# @9 q) D9 w) _- Dim swApp As Object
- j v! W: N# [' L) \& ?* h - Dim Part As Object( c1 [; F1 G5 Q' |& t9 W
- Dim SymbolPlace As Integer) Y% v. d/ `6 C3 f/ p R
- Dim Number_Name As String( h8 m' ]8 h& _) |& O1 W Y+ r
- Dim Number_ As String
5 l; K* b* `: x: U( N: M0 y - Dim Name_ As String& r& z3 K2 r7 o" O
8 a! a. x/ e- a& b1 e. H" ~$ Q- Sub main()7 ], I$ b& L \/ G& q5 V5 S% V
- Set swApp = Application.SldWorks2 ]3 Q1 @( t% [' h
- Set Part = swApp.ActiveDoc
' ?$ ~4 U# I w& j8 }. G. @" N' | - Number_Name = swApp.ActiveDoc.GetTitle() '取得零件的 編號-名稱(本例編號名稱是用 " - " 符號分離)
% y* Z$ Q, y) x# b4 a, B - SymbolPlace = InStr(Number_Name, "-") '取得 " - " 符號的位置數1 k, u- i* p5 O# U& s
- Number_ = Left(Number_Name, SymbolPlace - 1) '取得 零件編號
/ g: x/ }' a% @, ]& ~ - Name_ = Mid(Number_Name, SymbolPlace + 1, Len(Number_Name) - SymbolPlace - 7) '取得 零件名稱
+ p `0 C7 G& L) @1 Q+ ~7 w) m - blnretval = Part.DeleteCustomInfo2("", "PartNumber")( b! x, P3 ]- ?* D1 C; ]
- blnretval = Part.DeleteCustomInfo2("", "PartName"); ^7 N& W3 x* @1 f4 N. b9 {& _7 [" S
- blnretval = Part.AddCustomInfo3("", "PartNumber", swCustomInfoText, Number_)
( s+ y3 x2 ]6 I$ a( e - blnretval = Part.AddCustomInfo3("", "PartName", swCustomInfoText, Name_)
' M+ h7 ]# D) n0 R - End Sub
复制代码
$ S1 v H$ e ]0 z7 Z, I0 h7 f) {' _. v1 q' C* E
: B( J5 r3 t' Q a, v" k3 `' b9 J& c
0 |6 ?: @) n' n; `6 z! @5 j9 h) k! K. h, n$ p( N- ]
/ ^7 @' I& w; r6 Y, I. i; M
2 B- H2 W2 h7 X3 L |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
|