|
|
发表于 2008-6-18 19:44:53
|
显示全部楼层
来自: 中国浙江宁波
首先字段是多行文本对象或单行文本对象(AcadMText、AcadTex),参考二对象的FieldCode方法的帮助或许会得到启发!具体没有试过,猜测应该是按fieldcode方法来区分一个文本对象是否为字段;普通文本对象的fieldcode方法是文本对象的内容,而字段则为通配符,至于下面该怎么做你自己考虑吧!) U4 F9 f* E( n6 ]! Q3 Y
下面是ACAD2008的帮助例子
# Q O6 T3 J5 ]5 c; o V7 W, sSub Example_FieldCode()
* B1 c8 a( `( P9 c) @- j ' This example creates a text object in model space.3 T. S* E( o$ f6 g, O
' It then returns the field code string for the object.) {9 y8 }1 j) @6 q4 W% a" W) c
* b$ [9 H' [- B0 Y$ ~( |3 ]' C9 Y0 R Dim textObj As AcadText1 e4 u) ?+ {/ a1 F; P
Dim text As String
$ B: q# l3 W1 _% O Dim insertionPoint(0 To 2) As Double! J' F) N7 O+ ~& c, e9 y- m
Dim height As Double' b% d+ t' H/ a9 N$ g! E
: H) B, I1 Y3 r6 T/ A* y' y
' Define the text object" D( S: i9 t, b; L K* Q) d
text = "%<\AcVar Date \f ""M/d/yyyy""%>%"
* |, j$ t; w+ \3 A! D3 _8 p insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0: q0 v" e9 @3 W% [: F
height = 0.5
2 f% Y Q! o2 C7 w' I
2 b8 Q9 E9 J0 f4 Z- A ' Create the text object in model space
5 p0 n; N6 O. C6 ?. d- y4 h Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, height)
& Q' y3 N& a- c& l5 R. D( X ZoomAll, Z+ d$ n6 D5 s9 Z; g* @3 t d
5 f: w# Q1 V9 j: s
' Return the current text string for the object
; a% L$ ~9 Y6 Z1 g' ?* ~ text = textObj.FieldCode+ Z9 y1 P) {9 ~: x
MsgBox "The FieldCode for the text object equals: " & text, vbInformation, "FieldCode Example"
8 a& ]. E% D8 C$ f# u, p6 O
4 p9 t6 ` P( _3 W/ s m) P. jEnd Sub
# y* k+ A8 m: e4 B1 m( G7 W+ V* p* x; b( {) p
[ 本帖最后由 sealive_leafage 于 2008-6-18 20:04 编辑 ] |
评分
-
查看全部评分
|