' 绘边框的VBA程序
Public Sub test()
Dim ss As AcadSelectionSet
Dim i As AcadEntity
Dim pEntity(0) 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) pmax(0) Then pmax(0) = p2(0)
If p2(1) > pmax(1) Then pmax(1) = p2(1)
Next i
ThisDrawing.SendCommand "_.RECTANG " & pmin(0) & "," & pmin(1) & vbCr & pmax(0) & "," & pmax(1) & vbCr
把上面程序中的THISDRAWING替换为ACADDOC(在VB中使用)
为什么在Set ss = acaddoc.ActiveSelectionSet时出错"接口出错"
Dim ssetObj As AcadSelectionSet
For Each ssetObj In ThisDrawing.SelectionSets
If ssetObj.Name = "SS" Then
ssetObj.Clear
ssetObj.Delete
Exit For
End If
Next ssetObj
Set ssetObj = ThisDrawing.SelectionSets.Add("SS")
......
For Each ssetObj In ThisDrawing.SelectionSets
If ssetObj.Name = "SS" Then
ssetObj.Clear
ssetObj.Delete
Exit For
End If
Next ssetObj
Set ssetObj = ThisDrawing.SelectionSets.Add("SS")
ssetObj .Select acSelectionSetAll
ssetObj .GetBoundingBox pmin, pmax
For Each i In ssetObj
i.GetBoundingBox p1, p2
......