|
发表于 2008-6-18 19:44:53
|
显示全部楼层
来自: 中国浙江宁波
首先字段是多行文本对象或单行文本对象(AcadMText、AcadTex),参考二对象的FieldCode方法的帮助或许会得到启发!具体没有试过,猜测应该是按fieldcode方法来区分一个文本对象是否为字段;普通文本对象的fieldcode方法是文本对象的内容,而字段则为通配符,至于下面该怎么做你自己考虑吧!# v% ~" i3 {/ ~) }8 K
下面是ACAD2008的帮助例子
. u. H; Q) a5 u' X$ r+ |Sub Example_FieldCode(), l u! J+ t' u7 e9 B* c
' This example creates a text object in model space.
; K5 p" f+ r2 m7 K6 k ' It then returns the field code string for the object.- N+ T. u! T* q0 K* c% I4 ?
8 R* S0 v. {& ?4 ~0 j [
Dim textObj As AcadText
; B- c* F% {8 d8 l- g1 a Dim text As String- j( S9 w1 F9 d
Dim insertionPoint(0 To 2) As Double
/ V+ L+ S7 g; x! \8 D& M) @5 t4 ?: g Dim height As Double9 w5 e1 C4 k" T. X2 ]
1 z Q4 L' V4 B5 h. H ' Define the text object8 G& j1 I& Y% |+ B; V7 u3 h. t# Q
text = "%<\AcVar Date \f ""M/d/yyyy""%>%"
# h" J; ~2 p9 F8 [ F d, D insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0
9 u$ ^9 p+ `' i% R) F8 T$ `/ _7 k height = 0.5
( ?: `, V# g t9 ] h k " v: P5 c5 \' D3 r) O
' Create the text object in model space
' ~) e$ W4 s2 r6 J- E t# G5 I+ S Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, height)
2 p, R! S5 r% r1 d* [ ZoomAll
- ~+ x+ a& W: G8 l* j
" m" r$ a3 ]8 u0 O& t& p ' Return the current text string for the object
" D9 {& A% ]- ^% I text = textObj.FieldCode
( j6 ~0 K5 q' K9 F5 A: J" k MsgBox "The FieldCode for the text object equals: " & text, vbInformation, "FieldCode Example" X/ \6 y. k+ r o I5 s
% r0 Z4 a+ F4 c# s! j; w! {
End Sub9 ^* }; E! }0 j3 k" l- q) ^8 `: q
1 ]& `2 y3 J) G: }& N- q[ 本帖最后由 sealive_leafage 于 2008-6-18 20:04 编辑 ] |
评分
-
查看全部评分
|