|
|
发表于 2008-6-18 19:44:53
|
显示全部楼层
来自: 中国浙江宁波
首先字段是多行文本对象或单行文本对象(AcadMText、AcadTex),参考二对象的FieldCode方法的帮助或许会得到启发!具体没有试过,猜测应该是按fieldcode方法来区分一个文本对象是否为字段;普通文本对象的fieldcode方法是文本对象的内容,而字段则为通配符,至于下面该怎么做你自己考虑吧!
! K9 g4 |1 D9 T7 W下面是ACAD2008的帮助例子8 y0 M) n3 t1 u) W* r
Sub Example_FieldCode()
5 k8 |& s d# Q, c7 Y$ H9 q2 w ' This example creates a text object in model space.1 |( z3 v$ T4 P! b% r
' It then returns the field code string for the object.
! C+ A' F- F0 t* a! R! C) U
7 t, E u. |: y- s; ~8 ]$ T Dim textObj As AcadText: D) C9 N# u' m: r
Dim text As String7 I! v8 \2 ?- l* I, g7 D# z- E
Dim insertionPoint(0 To 2) As Double
/ g# Y1 V' ~! K( x Dim height As Double
6 ~- |( z* b9 e9 e' X# V: O1 W- J
' Define the text object4 f1 l- ?/ q$ z& c# s$ `
text = "%<\AcVar Date \f ""M/d/yyyy""%>%"5 Y1 M4 h3 ?- W, o, G# U
insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0
# k6 r6 @4 N; L4 ?* A$ M" B" X: w height = 0.57 K6 r0 Y" e# C3 p) ~$ G% J% B
. o0 T/ F. c9 \/ ~& |
' Create the text object in model space
2 @% A% t% ]' u, t, T% X- Q. n* J Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, height): B' Q) D5 a' _7 l
ZoomAll5 K0 ?" ~% }& _ {$ U5 G$ k4 L
7 E' q" h/ [: s3 S1 b } ' Return the current text string for the object
y& c3 G% n, s) E w text = textObj.FieldCode Z7 C5 q- H2 [/ @) o4 s
MsgBox "The FieldCode for the text object equals: " & text, vbInformation, "FieldCode Example") i8 j* D$ p; f( }: ?/ A
; C4 }' T; P; j; @5 k/ Z9 Y/ N
End Sub
* [, ]# i% e( P' r) R+ I: z$ B
u- z! S" Q2 h; S[ 本帖最后由 sealive_leafage 于 2008-6-18 20:04 编辑 ] |
评分
-
查看全部评分
|