|
|
发表于 2008-6-18 19:44:53
|
显示全部楼层
来自: 中国浙江宁波
首先字段是多行文本对象或单行文本对象(AcadMText、AcadTex),参考二对象的FieldCode方法的帮助或许会得到启发!具体没有试过,猜测应该是按fieldcode方法来区分一个文本对象是否为字段;普通文本对象的fieldcode方法是文本对象的内容,而字段则为通配符,至于下面该怎么做你自己考虑吧!
0 ~0 C/ U/ T4 ~4 d& [下面是ACAD2008的帮助例子: F2 s! q$ @0 h, Z3 S8 N) ]2 L
Sub Example_FieldCode(). h( ]* ` i' ^3 r' A" G- q
' This example creates a text object in model space.
' p" C% F# I6 r5 ~2 _ ' It then returns the field code string for the object.
6 T# A% P8 g, v- x6 o+ F
, w0 Z p$ f2 j: f2 ^ Dim textObj As AcadText' Q9 |% E3 ^' j6 D* O# V
Dim text As String$ s/ [- m/ p. s+ q/ H; R8 u) W
Dim insertionPoint(0 To 2) As Double! V5 h% f6 |9 ]5 F4 h d
Dim height As Double6 Z. a2 |2 R0 G( R
8 Q3 Z0 a% R) S7 f ' Define the text object9 y P+ c3 F$ y1 { v; k; A* D
text = "%<\AcVar Date \f ""M/d/yyyy""%>%"
& P* X5 q5 P3 n% @! @ insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0& Q$ M4 d O9 V; ~# u
height = 0.5; h# j, N* a4 [! ` m
: b, r3 |8 y/ C1 V; C) ?
' Create the text object in model space
5 R/ A8 E, F4 w2 S5 ]' I3 w Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, height): n/ h' ?+ K% P$ ^" t, X- [
ZoomAll- v2 ?& K! x% z: s( t" s5 q
1 p+ i( }3 O: F+ _; A6 j
' Return the current text string for the object
. v, r; z8 X* B! V. w text = textObj.FieldCode4 S6 U2 j6 n4 @+ w/ q4 i* c
MsgBox "The FieldCode for the text object equals: " & text, vbInformation, "FieldCode Example"
# f( Y t+ e% @
. e/ E; K5 |" W3 ]( Y) g8 I7 ~End Sub
2 {5 r, [0 N. I- p p( h1 w+ n% e3 L% p
[ 本帖最后由 sealive_leafage 于 2008-6-18 20:04 编辑 ] |
评分
-
查看全部评分
|