|
发表于 2008-6-18 19:44:53
|
显示全部楼层
来自: 中国浙江宁波
首先字段是多行文本对象或单行文本对象(AcadMText、AcadTex),参考二对象的FieldCode方法的帮助或许会得到启发!具体没有试过,猜测应该是按fieldcode方法来区分一个文本对象是否为字段;普通文本对象的fieldcode方法是文本对象的内容,而字段则为通配符,至于下面该怎么做你自己考虑吧!3 b% k: z) A, X& {
下面是ACAD2008的帮助例子8 L1 l. `6 f0 V/ O. ?; I
Sub Example_FieldCode()
% G7 x" y, N6 H4 g0 C! k ' This example creates a text object in model space.
# ~8 l( H5 L! @ J) ? ' It then returns the field code string for the object.9 c& M7 q! [9 ?
! Z, R( @& b9 T8 i; P Dim textObj As AcadText
( J& C) s6 M+ m: [+ D- _* b5 O Dim text As String
) {( z) {) ]* c7 Q5 k6 D. o Dim insertionPoint(0 To 2) As Double
' {( P9 P! ]) @) i7 d1 ]. K) t/ \ Dim height As Double+ C3 V0 ?! c8 G( U# q! Q O; W
6 G5 [' C+ y$ _ @. e3 I ' Define the text object
" Q- _& `& h7 D- s, l1 Z text = "%<\AcVar Date \f ""M/d/yyyy""%>%"3 Z" O7 W. A" t7 p0 V
insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0: j2 u/ ^) ]0 J ~
height = 0.5
$ b9 ~6 E, p' c J
: R% M; j# p* a* g) z5 J2 \) Z; K# { ' Create the text object in model space2 x' D& X. w) A* i, @9 D
Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, height)7 }$ ^ [ n! P+ a; {0 E8 {+ S C
ZoomAll" K0 }* }( t1 n! q6 u' o
) e5 A( l0 m- O; B/ |: h) B4 p
' Return the current text string for the object/ L% |, j' J9 y% j
text = textObj.FieldCode
4 R( n' ~- _8 C) M* d MsgBox "The FieldCode for the text object equals: " & text, vbInformation, "FieldCode Example"
2 M3 L' G# R& L6 n$ D+ b
& \0 [4 \8 U s9 d% W5 ^+ IEnd Sub% N, r! W$ R2 V2 Y' A% z& S0 B
8 I6 y. ?* I8 o9 E5 A[ 本帖最后由 sealive_leafage 于 2008-6-18 20:04 编辑 ] |
评分
-
查看全部评分
|