|
|
发表于 2008-10-17 20:10:11
|
显示全部楼层
来自: 中国浙江宁波
楼主的问题acad的帮助中就有例程:% W8 r# y, G5 m! R& b$ w
Sub Example_ActiveLayer() " J8 _8 T( E3 i, Q- o
' This example returns the current layer
4 E) Z f: h+ j! S7 ~' and then adds a new layer. $ T9 l3 Z/ h% G9 |& \% v
' Finally, it returns the layer to the previous setting.
8 N% l7 o g; wDim currLayer As AcadLayer
5 \0 [: U/ L& Y2 |. Z( y( aDim newLayer As AcadLayer ' Return the current layer of the active document
" ^, i5 b6 I4 J6 p3 Y8 |Set currLayer = ThisDrawing.ActiveLayer
& f$ r7 A# k7 Z. {9 m6 C! d( DMsgBox "The current layer is " & currLayer.name, vbInformation, "ActiveLayer Example"
- f, [: b B$ _4 e% o1 T7 M6 h5 N2 H' Create a Layer and make it the active layer
% V# u2 b5 d- g! ESet newLayer = ThisDrawing.Layers.Add("TestLayer")
, t2 ~% t: C1 [- }" n+ FThisDrawing.ActiveLayer = newLayer * n5 k% `+ I5 o+ ^" G$ f5 u: \
MsgBox "The new layer is " & newLayer.name, vbInformation, "ActiveLayer Example" 9 N9 o( `2 d$ X' ~" ]' k$ v
' Reset the layer to its previous setting
! E" r# K' [+ g- [6 GThisDrawing.ActiveLayer = currLayer 7 K+ O2 P; x* L' L
MsgBox "The active layer is reset to " & currLayer.name, vbInformation, "ActiveLayer Example"
, c- ?( D% L$ a) g, {8 H2 hEnd Sub4 f. o9 }7 [3 S: u& I! I- b9 t. T: `
第二个问题建议使用acadText对象,而不是mtext对象,具体参考alignment属性;
9 V+ I) K- s4 S7 H2 u( ^
" u1 H& q$ \! D[ 本帖最后由 sealive_leafage 于 2008-10-17 20:14 编辑 ] |
评分
-
查看全部评分
|