|
发表于 2008-6-18 19:44:53
|
显示全部楼层
来自: 中国浙江宁波
首先字段是多行文本对象或单行文本对象(AcadMText、AcadTex),参考二对象的FieldCode方法的帮助或许会得到启发!具体没有试过,猜测应该是按fieldcode方法来区分一个文本对象是否为字段;普通文本对象的fieldcode方法是文本对象的内容,而字段则为通配符,至于下面该怎么做你自己考虑吧!' _* v% }3 v6 k+ D" d
下面是ACAD2008的帮助例子" a" S1 Q, r9 X5 y. F" P' c
Sub Example_FieldCode()# ?4 |$ Q- |. `5 e- w
' This example creates a text object in model space.$ ?+ }- @% I. \3 }- A
' It then returns the field code string for the object.$ ^& B1 S/ S) i9 W" S
( a1 s1 c! w* H* J# g6 a Dim textObj As AcadText& L U4 A0 l; i9 Q2 d" W9 p
Dim text As String
+ \& m, T& L4 a0 `/ R+ w Dim insertionPoint(0 To 2) As Double5 v9 A/ A0 e) L- |1 @* U
Dim height As Double
% ?2 ^# `; |# d( ^! _: f0 e6 o# @0 O
' Define the text object
8 _0 {5 A) D3 m) Y) b3 ]. t text = "%<\AcVar Date \f ""M/d/yyyy""%>%"! p) U! h) E8 i! o7 D1 C6 D; J
insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0* `4 Z' H W9 q8 p. C& Y
height = 0.5
0 P7 _! @1 ]0 p! r! O: p+ v& a1 x . i5 Y* T1 H; {) i6 P6 F$ R U
' Create the text object in model space4 N) c9 Q) [9 L+ W! X& s
Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, height). Y# }# w' p! | Q- j* U5 f
ZoomAll; d) `6 Q" I5 u) e* R. ?* V
) v6 D" L/ H/ D9 X4 A _: ]4 g ' Return the current text string for the object i4 u/ u2 j, x/ f) h! J6 i
text = textObj.FieldCode: B7 w9 K' c7 g% Q c
MsgBox "The FieldCode for the text object equals: " & text, vbInformation, "FieldCode Example": G) K/ I j. H/ L; D; Z
/ Q7 e4 B* W$ x7 E) O
End Sub
8 O2 C' ~* s9 ~" q% U
: ^2 U9 a; \4 c[ 本帖最后由 sealive_leafage 于 2008-6-18 20:04 编辑 ] |
评分
-
查看全部评分
|