1.VBA可否象(ssget "x" '((0. "MTEXT")))这样不用鼠标选就选择当前图纸中所有同一类别(比如MTEXT)的图元,怎么实现?
2.编一个自动生成3个图纸空间(Layout1 Layout2 Layout3),并修改其视口大小为420,297的程序
代码如下:
Sub AddLayout()
Dim LayoutObj As AcadLayout Dim I As Integer Dim LayoutName As String Dim Viewports As AcadPViewport Dim ViewCenPoint(0 To 2) As Double Dim acPaperSpace As Integer
ViewCenPoint(0) = 210 ViewCenPoint(1) = 148.5 ViewCenPoint(2) = 0 For I = 1 To 3
LayoutName = "Layout" + Mid(Str(I), 2, Int(I / 10 + 1))
On Error Resume Next Set LayoutObj = ThisDrawing.Layouts.Item(LayoutName) If Err.Number = -2145386476 Then Err.Clear Set LayoutObj = ThisDrawing.Layouts.Add(LayoutName) Else LayoutObj.Delete Set LayoutObj = ThisDrawing.Layouts.Add(LayoutName) End If
ThisDrawing.ActiveSpace = acPaperSpace ThisDrawing.MSpace = True ThisDrawing.ActivePViewport.Width = 420 ThisDrawing.ActivePViewport.Height = 297 Next End Sub
结果图纸空间如愿生成但是仅修改了Layout1 的Pviewport其它的视口没变,是不是因为acPaperSpace仅仅默认转换到第一个图层空间呢?那通过什么办法实现自动更改所有视口的属性呢,望释疑,非常感谢 |