|
发表于 2008-6-18 19:44:53
|
显示全部楼层
来自: 中国浙江宁波
首先字段是多行文本对象或单行文本对象(AcadMText、AcadTex),参考二对象的FieldCode方法的帮助或许会得到启发!具体没有试过,猜测应该是按fieldcode方法来区分一个文本对象是否为字段;普通文本对象的fieldcode方法是文本对象的内容,而字段则为通配符,至于下面该怎么做你自己考虑吧!
6 k0 W8 y$ j l3 L% M1 ?* s下面是ACAD2008的帮助例子
7 d* s/ B& \1 t7 }" \- ISub Example_FieldCode()
3 A$ \. e3 A* V E6 a ' This example creates a text object in model space.' o( G) ~7 |9 q; v/ b* _ R( @
' It then returns the field code string for the object.
% |- W5 m7 R0 \# C
7 O# c1 [( Q5 w+ p' P4 R0 Q3 z$ }; T Dim textObj As AcadText" q$ t, |' M& g5 a! }5 p/ C
Dim text As String9 P4 w# W9 d6 e, d6 B- G5 c& v. }
Dim insertionPoint(0 To 2) As Double8 X" u( ?1 F0 E2 u$ N3 G, O$ k
Dim height As Double7 c* {4 j. a- P5 l6 D5 V
' ?2 j }6 @+ z
' Define the text object
9 N$ g7 d. [- E text = "%<\AcVar Date \f ""M/d/yyyy""%>%"
# ]0 Y$ v8 B) b insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0+ B* } s1 ?3 y1 K) a
height = 0.5, k6 P; H- Q3 n z( X; k( z" P
' a' E$ Q7 w& A7 l; `# t6 [ ` ' Create the text object in model space
( C3 v) q3 N4 T Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, height)
$ |) ~1 O3 n4 I# A1 U5 _ ZoomAll6 l# w% ?5 p- U0 A3 R3 [
9 s, | Y) f0 }; k
' Return the current text string for the object$ f) d/ I: w! ?# w6 H9 V
text = textObj.FieldCode
3 ~4 P+ X" }, Y MsgBox "The FieldCode for the text object equals: " & text, vbInformation, "FieldCode Example"
7 j3 t* s) k5 h, g1 s' m
2 @7 k5 W7 w5 R; N$ k+ S! ^End Sub
3 l6 T& M5 u, c" \9 x* L0 X2 I o" b; W
[ 本帖最后由 sealive_leafage 于 2008-6-18 20:04 编辑 ] |
评分
-
查看全部评分
|