CAD VBA程序问题请教,请高手指导下。 (程序不知道在哪儿存在问题,选择集内是空的)
Subwww()'创建在实例中使用的对象Dimpt1(0To2)AsDoubleDimpt2(0To2)AsDoublept1(0)=-5:pt1(1)=-5:pt1(2...
Sub www()
'创建在实例中使用的对象
Dim pt1(0 To 2) As Double
Dim pt2(0 To 2) As Double
pt1(0) = -5: pt1(1) = -5: pt1(2) = 0
pt2(0) = 30000: pt2(1) = 1005: pt2(2) = 0
On Error Resume Next
Dim SSet As AcadSelectionSet
If Not IsNull(ThisDrawing.SelectionSets.Item("Example")) Then
Set SSet = ThisDrawing.SelectionSets.Item("Example")
SSet.Delete '及时删除不用的选择集非常重要
End If
Set SSet = ThisDrawing.SelectionSets.Add("Example")
'(2)向选择集中添加对象
'设置选择过滤器
Dim FilterType(0 to 4) As Integer, FilterData(0 to 4) As Variant
FilterType(0) = -4
FilterData(0) = "<or" '逻辑运算符的开始,表示一个或多个运算对象
'先选择OUTSIDE-4图层上的对象到选择集
FilterType(1) = 8
FilterData(1) = "OUTSIDE-4"
'再选择SP_OUTSIDE-4图层上的对象到选择集
FilterType(2) = 8
FilterData(2) = "SP_OUTSIDE-4"
'最后选择Stock图层上的对象到选择集
FilterType(3) = 8
FilterData(3) = "Stock"
FilterType(4) = -4
FilterData(4) = "or>" '逻辑运算符的结束
'使用Crossing的选择模式
SSet.Select acSelectionSetCrossing, pt1, pt2, FilterType, FilterData
MsgBox "选中对象上" & sset.Count & "个对象"
'(4)删除选择集
'SSet.Erase '删除选择集中所有对象,保留选择集对象
'SSet.Delete '删除选择集,保留其中对象
'删除选择集和其中所有对象
For Each element In SSet
element.Delete
Next
SSet.Delete
End Sub 展开
'创建在实例中使用的对象
Dim pt1(0 To 2) As Double
Dim pt2(0 To 2) As Double
pt1(0) = -5: pt1(1) = -5: pt1(2) = 0
pt2(0) = 30000: pt2(1) = 1005: pt2(2) = 0
On Error Resume Next
Dim SSet As AcadSelectionSet
If Not IsNull(ThisDrawing.SelectionSets.Item("Example")) Then
Set SSet = ThisDrawing.SelectionSets.Item("Example")
SSet.Delete '及时删除不用的选择集非常重要
End If
Set SSet = ThisDrawing.SelectionSets.Add("Example")
'(2)向选择集中添加对象
'设置选择过滤器
Dim FilterType(0 to 4) As Integer, FilterData(0 to 4) As Variant
FilterType(0) = -4
FilterData(0) = "<or" '逻辑运算符的开始,表示一个或多个运算对象
'先选择OUTSIDE-4图层上的对象到选择集
FilterType(1) = 8
FilterData(1) = "OUTSIDE-4"
'再选择SP_OUTSIDE-4图层上的对象到选择集
FilterType(2) = 8
FilterData(2) = "SP_OUTSIDE-4"
'最后选择Stock图层上的对象到选择集
FilterType(3) = 8
FilterData(3) = "Stock"
FilterType(4) = -4
FilterData(4) = "or>" '逻辑运算符的结束
'使用Crossing的选择模式
SSet.Select acSelectionSetCrossing, pt1, pt2, FilterType, FilterData
MsgBox "选中对象上" & sset.Count & "个对象"
'(4)删除选择集
'SSet.Erase '删除选择集中所有对象,保留选择集对象
'SSet.Delete '删除选择集,保留其中对象
'删除选择集和其中所有对象
For Each element In SSet
element.Delete
Next
SSet.Delete
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询