|
|
发表于 2008-6-18 19:44:53
|
显示全部楼层
来自: 中国浙江宁波
首先字段是多行文本对象或单行文本对象(AcadMText、AcadTex),参考二对象的FieldCode方法的帮助或许会得到启发!具体没有试过,猜测应该是按fieldcode方法来区分一个文本对象是否为字段;普通文本对象的fieldcode方法是文本对象的内容,而字段则为通配符,至于下面该怎么做你自己考虑吧!- h6 T" C( ]* C \8 v. a9 Q
下面是ACAD2008的帮助例子3 z! ]1 ?0 w5 I7 d6 p" N
Sub Example_FieldCode()
9 a3 | a" o! A4 w5 t: S ' This example creates a text object in model space.
! `$ c9 o( H E4 f! Z# H% I: U ' It then returns the field code string for the object.8 |, `" n5 Y) E' l6 B
4 i L! n$ b# `3 z0 X1 F Dim textObj As AcadText+ [7 Q1 B9 M! U, {( h
Dim text As String3 @/ ]$ T: O# t+ b7 j5 c- `* E
Dim insertionPoint(0 To 2) As Double! \5 I1 P. q* S; \! a. j, s" L7 r
Dim height As Double* D/ ~/ B% o+ d) p- X6 b
2 F" n6 u; V9 e/ u; }) |: [% ~7 [
' Define the text object
2 A G9 Y4 X4 P5 w text = "%<\AcVar Date \f ""M/d/yyyy""%>%"
" _0 f8 K6 L9 `4 j# R insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0( e1 _+ Z- i% z& a& T
height = 0.5
, X6 b1 w9 R* Q4 B4 R
$ r% m `% ]2 J3 D ' Create the text object in model space/ m @# {7 T5 I1 g& g
Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, height)
7 M8 `: w: @! J0 h ZoomAll: a7 m: ~* z7 i5 y" r4 T- d: {7 z
0 F# _: ^8 l+ i" N6 E: o ' Return the current text string for the object) H0 a, y4 F7 p" ]8 b
text = textObj.FieldCode
0 ~9 K: ?! X) Z# |+ h0 V8 L MsgBox "The FieldCode for the text object equals: " & text, vbInformation, "FieldCode Example"
8 h+ M/ ?$ {8 X2 J6 K1 W* s: L0 h' M5 K' e' L- W
End Sub
6 f! [6 n/ `# _
9 @' \$ z: e& r1 Q- a- V0 o1 u[ 本帖最后由 sealive_leafage 于 2008-6-18 20:04 编辑 ] |
评分
-
查看全部评分
|