|
发表于 2008-6-18 19:44:53
|
显示全部楼层
来自: 中国浙江宁波
首先字段是多行文本对象或单行文本对象(AcadMText、AcadTex),参考二对象的FieldCode方法的帮助或许会得到启发!具体没有试过,猜测应该是按fieldcode方法来区分一个文本对象是否为字段;普通文本对象的fieldcode方法是文本对象的内容,而字段则为通配符,至于下面该怎么做你自己考虑吧!
5 J4 M$ l) @3 x! G9 S下面是ACAD2008的帮助例子) Z* ?. {* ]( Z" H$ m& Q: j. p
Sub Example_FieldCode()
% E; u) W! J( N) V ' This example creates a text object in model space.8 L1 y" k; B: J W
' It then returns the field code string for the object.
' h2 t; ?4 F8 h- [) z! Q1 y( w3 d5 z3 q" z
Dim textObj As AcadText
) y# s1 X- R% G% c0 X' p' O Dim text As String
) c4 c3 p( L& p/ v Dim insertionPoint(0 To 2) As Double$ k: i8 ^. r4 d% |- V" g7 D! p
Dim height As Double& E0 e ^ ~: ^$ `" n
5 a/ a+ l( i' Z1 ~! [9 q3 Q0 x ' Define the text object" ]2 w! y) g& G5 k
text = "%<\AcVar Date \f ""M/d/yyyy""%>%"; p, \# f! O ~4 z+ K
insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0
' U7 |5 I$ R6 N3 m+ R: X5 x height = 0.5" Q8 p8 p F4 i# P
6 O' N9 f0 v. h/ }$ w5 w- {+ M ' Create the text object in model space
7 J3 _! B; J8 ]) f Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, height)) m% [8 G7 l) I5 J3 e1 L
ZoomAll
4 b$ I$ h/ l+ N7 ~7 @4 l 4 q' U' v5 c+ A! G n
' Return the current text string for the object+ e& ` `" f' ^9 c+ |
text = textObj.FieldCode
2 n" p$ L# v6 w+ s: K( B, J MsgBox "The FieldCode for the text object equals: " & text, vbInformation, "FieldCode Example"
2 R5 J1 j C9 v/ c- Y' ?
0 B0 z: p0 n! c( X- @# XEnd Sub
3 U! T4 R7 R+ I+ l' J6 l9 l" J% U8 ` f% O2 Q- e, Q! s" c4 Q' ]( M
[ 本帖最后由 sealive_leafage 于 2008-6-18 20:04 编辑 ] |
评分
-
查看全部评分
|