没有单独做过相同程序,从其它程序中摘录出一小段,比较凌乱,请参考!
-
- ’部分声明
- Public Type EntSse
- EntTem As AcadEntity
- X As Double
- Y As Double
- End Type
- Public tempObj() As EntSse
- Sub 块过滤()
- IsOpen = False
- For Each acaddoc In acadapp.Documents
- If StrComp(acaddoc.Name, MyFileName, vbTextCompare) = 0 Then
- IsOpen = True
- acaddoc.Activate
- Exit For
- End If
- Next
- If IsOpen = False Then acadapp.Documents.Open MyPath & MyFileName
- acadapp.ZoomExtents
- Set Sset = acadapp.ActiveDocument.SelectionSets.Add(Now & Timer)
- CreateSSetFilter FilterType, FilterDate, 0, "insert",2,“块名称”
- Sset.Select acSelectionSetAll, , , FilterType, FilterDate
- End Sub
- '快速创建选择集
- Public Sub CreateSSetFilter(ByRef FilterType As Variant, ByRef filterData As Variant, ParamArray filter())
- If UBound(filter) Mod 2 = 0 Then
- MsgBox "filter 参数无效!"
- Exit Sub
- End If
- Dim fType() As Integer '过滤器规则
- Dim fData() As Variant '过滤器参数
- Dim Count As Integer
- Count = (UBound(filter) + 1) / 2
- ReDim fType(Count - 1)
- ReDim fData(Count - 1)
- Dim i As Integer
- For i = 0 To Count - 1
- fType(i) = filter(2 * i)
- fData(i) = filter(2 * i + 1)
- Next i
- FilterType = fType
- filterData = fData
- End Sub
- '选择集排序
- Sub X坐标排序(ss As AcadSelectionSet)
- Dim i As Integer
- Dim j As Integer
- If ss.Count = 0 Then Exit Sub
- ReDim tempObj(ss.Count - 1)
- For i = LBound(tempObj) To UBound(tempObj)
- ss(i).GetBoundingBox pMin, pMax
- Set tempObj(i).EntTem = ss(i)
- tempObj(i).X = pMin(0)
- tempObj(i).Y = pMin(1)
- Next
- For i = 0 To UBound(tempObj) - 1
- For j = 1 To UBound(tempObj) - i
- If tempObj(j - 1).X > tempObj(j).X Then
- temp = tempObj(j - 1)
- tempObj(j - 1) = tempObj(j)
- tempObj(j) = temp
- End If
- Next
- Next
- End Sub
|