江湖救急
最近做capp开发 第一次接触vba 有个需求是需要根据autocad的实体 改变绘图窗口大小代码如下:
Public Sub test()
Dim ss As AcadSelectionSet
Dim i As AcadEntity
Set ss = ThisDrawing.ActiveSelectionSet
ss.Select acSelectionSetAll
ss(0).GetBoundingBox pmin, pmax
For Each i In ss
i.GetBoundingBox p1, p2
If p1(0) < pmin(0) Then pmin(0) = p1(0)
If p1(1) < pmin(1) Then pmin(1) = p1(1)
If p2(0) > pmax(0) Then pmax(0) = p2(0)
If p2(1) > pmax(1) Then pmax(1) = p2(1)
Next i
'MsgBox pmin(0)
'MsgBox pmin(1)
'MsgBox pmax(0)
'MsgBox pmax(1)
ThisDrawing.Width = pmax(0) - pmin(0)
ThisDrawing.Height = pmax(1) - pmin(1)
Application.ZoomExtents
End Sub
但是出现了个问题第一次运行的时候cad绘图窗体大小是改变了,图形并没有缩放.有部分图是窗口以外
需要再运行一次 才能实现
望各位哪位大侠出手点播下