|
|
发表于 2008-6-18 19:44:53
|
显示全部楼层
来自: 中国浙江宁波
首先字段是多行文本对象或单行文本对象(AcadMText、AcadTex),参考二对象的FieldCode方法的帮助或许会得到启发!具体没有试过,猜测应该是按fieldcode方法来区分一个文本对象是否为字段;普通文本对象的fieldcode方法是文本对象的内容,而字段则为通配符,至于下面该怎么做你自己考虑吧!1 i" b1 A- X" R' @; \
下面是ACAD2008的帮助例子7 W/ c) ~' O7 O
Sub Example_FieldCode()
7 p" @3 H6 p# r$ r9 o% v8 _1 u ' This example creates a text object in model space., B3 G. V7 `5 t4 R& c6 A
' It then returns the field code string for the object.5 B" v, b: d1 W) A
3 ~; f! l' Y1 Y' H% B
Dim textObj As AcadText
/ @5 B* f: l+ b" z2 Y4 m; L Dim text As String
. A$ X N- U! L9 o" p8 }9 m% } Dim insertionPoint(0 To 2) As Double3 [) ]# w2 `2 I0 v
Dim height As Double7 a' b. x9 W! |9 E& X
/ Q$ u+ X" A. _. p$ I
' Define the text object
p3 v/ P) { r text = "%<\AcVar Date \f ""M/d/yyyy""%>%". V/ k6 ^0 g* x& D% r
insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 03 d: P7 {/ {: j7 l
height = 0.5/ G9 F l/ O3 d0 q# E, q
* w7 W& N4 ^9 e" s
' Create the text object in model space
* J! O; O0 D! U! w Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, height)' z( p# v; x1 m- s6 L+ d
ZoomAll9 E6 M4 E+ A8 B# O
0 F1 f( K( a; y ' Return the current text string for the object
: W/ y& a! w. H% @4 ~ text = textObj.FieldCode
# Q; a* ]5 Z( W+ K' j MsgBox "The FieldCode for the text object equals: " & text, vbInformation, "FieldCode Example"2 Y; _2 ^2 _0 X5 @/ q
, P+ E7 V( ]9 m- x! x% vEnd Sub. m# l8 n! s) t2 C' L9 C
, l7 K/ |' \1 ^: L$ U+ [; Y[ 本帖最后由 sealive_leafage 于 2008-6-18 20:04 编辑 ] |
评分
-
查看全部评分
|