|
发表于 2012-4-4 08:29:21
|
显示全部楼层
方法一:按照楼主的思路使用选择集- Private Sub cmdInsert_Click()/ a, g, w# s' e! ] d/ h' ]9 J7 u8 W5 V
- Dim ptInsert(2) As Double
5 J5 Y% E/ }2 o - Dim lastSel As AcadSelectionSet1 L' h2 D4 L0 |, }# x: F
- Dim lastBlock As Variant' J& @, D' d4 R) \' A
- ptInsert(0) = 0 h+ d) g4 N0 t) D
- ptInsert(1) = 0
1 q D) B+ Z7 ?1 V) I8 W% Y0 K; D4 J - ptInsert(2) = 0
8 D* U8 ^$ Z/ F j. m* ~, Q+ e - ThisDrawing.ModelSpace.InsertBlock ptInsert, blkAName.Text, 1, 1, 1, 0* H7 ^- S/ q7 u9 ^
- $ l2 r! w: [- Q2 H* w0 D0 g
) g9 `( W) C; Z; B8 D- . `/ X0 Y* @, R# H4 f
- Set lastSel = ThisDrawing.SelectionSets.Add("SSet3") '4 u; ~' y! ~: _% n
- lastSel.Select acSelectionSetLast
$ s" R& v9 O& Q1 T. p8 ~ - 7 U& d1 E: \7 N; p: y
- Dim B As AcadBlockReference '声明一个块参照变量
, w9 B0 q7 g8 M7 A) i - Dim P As Variant '声明一个变体变量用于接收三维点坐标
6 @# ^+ a. e, E - Set B = lastSel(0) '把选择集中的第一个(也是唯一一个)元素(最后创建的对象,即上一步在图形中插入的块参照)赋值给变量' l% p5 u1 N2 [
- P = B.InsertionPoint '提取上一步插入的块参照的插入点坐标,返回值是三元素双精度数组
% w3 ^6 n, {+ p: G5 b' U# D
$ e/ Z" O8 f, _+ i% M6 Y- lastSel.Delete '删除选择集
4 L& `( Y; K% t) [7 \# F- | - & e( _% e( j7 q
- 2 X: I4 n& R: k. z( j. S' a
- ThisDrawing.Regen acActiveViewport2 n' s, M5 g; H) B
- 0 L4 A0 E! a4 C- X$ e) D
- 6 ]& Z! G& E: j0 E7 a8 K( w3 b
- End Sub
复制代码 不过,对于本例,完全可以不用选择集,直接使用前一个对象的返回值.如方法二:- Private Sub cmdInsert_Click()
m/ G" O8 ]% L3 i* E( m - Dim ptInsert(2) As Double* f( z" m/ u/ G0 T8 V
- 'Dim lastSel As AcadSelectionSet
) D& d/ U+ A0 L% O( y, \ - Dim lastBlock As Variant
' Z6 P; d3 b t( W+ Q - ptInsert(0) = 0
# i& [8 r8 W( [ G+ w - ptInsert(1) = 08 g7 p: {& [7 ~* {1 p
- ptInsert(2) = 0
# z8 X# ]5 N; Y* h, H% Y
3 c$ S5 U1 k3 M( @- & @2 Z" Y& R( S/ D3 H
- . W4 h' y$ a+ O- z& O( Z% o9 N
- 'Set lastSel = ThisDrawing.SelectionSets.Add("SSet3") '
/ M" y5 g2 J5 s! Z w - 'lastSel.Select acSelectionSetLast! A* u. I3 K3 j* Y
, r- E; |1 q: l/ a- Dim B As AcadBlockReference '声明一个块参照变量
J/ B n$ N. ? - Dim P As Variant '声明一个变体变量用于接收三维点坐标
7 k7 Y# A8 b$ C1 z - Set B = ThisDrawing.ModelSpace.InsertBlock(ptInsert, blkAName.Text, 1, 1, 1, 0)& |# B0 x- B4 k; b2 j+ D
- P = B.InsertionPoint '提取上一步插入的块参照的插入点坐标,返回值是三元素双精度数组
1 V- B2 ~* t2 ~5 V- s+ T% L - ; I* y9 `5 o `1 Y2 Z1 B' M
- 'lastSel.Delete '删除选择集6 t9 n! o! V( s) @$ W
" G+ ^- {4 t+ ?6 d; B% l0 g. Q
4 w9 q9 U8 R* L# ]1 S- ThisDrawing.Regen acActiveViewport
2 l$ s! @( C# R" r( N
+ Z+ h% f% p3 ^$ l- 7 ~* S- b) ?; T, d
- End Sub
复制代码 |
评分
-
查看全部评分
|