为什么我求快参考的范围的时候出错
我通过老大教的方法求到某个块参考的时, 用getboundingbox 求块参考的范围总出错为什么?谢谢 代码在哪?拿出来看一下才知道哪出错。
代码如下],请老大指教,谢谢
Dim caddoc As AcadDocument<BR>Private Sub Command1_Click()<BR>Dim cadobj As AcadApplicationDim cadplot As AcadPlot<BR>Dim papersize As String<BR>Dim count As Integer<BR>Dim i As Integer<BR>Dim max As Variant<BR>Dim min As Variant<BR>Dim cadlayout As AcadLayout<BR>Dim Name As String<BR> Dim point1(0 To 2) As Double<BR> Dim point2(0 To 2) As Double<BR> point1(0) = 0: point1(1) = 1000: point1(2) = 0<BR> point2(0) = 2800: point2(1) = 0: point2(2) = 0
Set cadobj = CreateObject("AutoCAD.Application")<BR>'Set caddoc = cadobj.ActiveDocument<BR>cadobj.Visible = True
Set caddoc = cadobj.Documents.Open("D:\111111111b6p114-0142.dwg", False)<BR>'cadobj.ZoomWindow point1, point2<BR> <BR> <BR>GetBlkRef<BR> <BR>
<BR>End Sub<BR>Sub GetBlkRef()<BR> Dim ss As AcadSelectionSet<BR> Set ss = CreateSelectionSet<BR> Dim tFilter As Variant<BR> Dim dFilter As Variant<BR> Dim count As Integer<BR> Dim i As Integer<BR> Dim j As Integer<BR> Dim z As Integer<BR> Dim minvalue, maxvalue As Variant<BR> Dim point1(3) As Double<BR> Dim point2(3) As Double<BR> <BR> BuildFilter tFilter, dFilter, 0, "Insert"<BR> ss.Select acSelectionSetAll, , , tFilter, dFilter<BR> count = ss.count<BR> Dim ref As AcadBlockReference<BR> ReDim obj(count) As AcadEntity<BR> For i = 0 To 1<BR> Set obj(i) = ss.Item(i)<BR> Set ref = ss.Item(i)<BR> ref.GetBoundingBox maxvalue, minvalue<BR> For j = LBound(max) To UBound(max)<BR> point1(j) = max(j)<BR> <BR> Next<BR> For z = LBound(min) To UBound(min)<BR> point2(z) = min(z)<BR> Next<BR> MsgBox point2(0) - point1(0)<BR> MsgBox point2(1) - point1(1)<BR> <BR> Next<BR>End Sub
Public Function CreateSelectionSet(Optional ssName As String = "ss") As AcadSelectionSet
Dim ss As AcadSelectionSet<BR> <BR> On Error Resume Next<BR> Set ss = caddoc.SelectionSets(ssName)<BR> If Err Then Set ss = caddoc.SelectionSets.Add(ssName)<BR> ss.Clear<BR> Set CreateSelectionSet = ss
End Function
Public Sub BuildFilter(typeArray, dataArray, ParamArray gCodes())<BR> Dim fType() As Integer, fData()<BR> Dim index As Long, i As Long<BR> <BR> index = LBound(gCodes) - 1<BR> <BR> For i = LBound(gCodes) To UBound(gCodes) Step 2<BR> index = index + 1<BR> ReDim Preserve fType(0 To index)<BR> ReDim Preserve fData(0 To index)<BR> fType(index) = CInt(gCodes(i))<BR> fData(index) = gCodes(i + 1)<BR> Next<BR> typeArray = fType: dataArray = fData<BR>End Sub getboundingbox不可求射线、构造线的范围,因为它们本身就没有范围。<BR>你的程序中max和min是怎样得到的,与getboundingbox的返回值不一致的变量名称。
页:
[1]