关于按照颜色值筛选对象的问题
我想实现,通过点选一个实体,然后根据它的颜色,全部选中途中相同颜色的实体对象。我是通过读取TrueColor的ColorIndex属性来获取颜色索引值。但是有个问题了。当颜色值为256,既为bylayer类型时,就搞不定了。这种情况应该怎么做呢。谢谢'************************************************************************************
'按颜色选择相同颜色的实体对象:************************************
'************************************************************************************
Sub PublicSub333()
On Error GoTo errhandle
ThisDrawing.Utility.Prompt vbCrLf & "当前命令:颜色选择" & vbCrLf
' Exit Sub
Dim i As Long
Dim k As Long
Dim entityObj As AcadEntity '实体变量
Dim nColor As Integer '颜色值
'创建空白选择集
Dim SelSet As AcadSelectionSet
If ThisDrawing.SelectionSets.Count > 0 Then '如果选择集已经存在,删除
For i = 0 To ThisDrawing.SelectionSets.Count - 1
If ThisDrawing.SelectionSets.Item(i).Name = "SelSet" Then
Set SelSet = ThisDrawing.SelectionSets.Item("SelSet")
SelSet.Delete
Exit For
End If
Next i
End If
Set SelSet = ThisDrawing.SelectionSets.Add("SelSet")
ThisDrawing.Utility.GetEntity entityObj, setpoint, "请拾取对象:"
nColor = entityObj.TrueColor.ColorIndex '获取颜色值
'0为block,256为bylayer,
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant
Dim lyObj As AcadLayer
Set lyObj = ThisDrawing.Layers.Item(entityObj.Layer)
If nColor = 256 Then '颜色为bylayer时不能刷选??????????????????????
nColor = lyObj.TrueColor.ColorIndex
End If
FilterType(0) = 62
FilterData(0) = nColor
SelSet.Select acSelectionSetAll, , , FilterType, FilterData '将目标颜色所有对象添加到选择集中
SelSet.Highlight True
Exit Sub
errhandle:
If Err.Number = -2147352567 Then
ThisDrawing.Utility.Prompt "取消选择" & vbCrLf
Else
ThisDrawing.Utility.Prompt vbCrLf & Err.Number & vbCrLf
ThisDrawing.Utility.Prompt vbCrLf & Err.Description & vbCrLf
End If
End Sub
If nColor = 256 Then '颜色为bylayer时不能刷选??????????????????????
nColor = lyObj.TrueColor.ColorIndex
End If
把这段代码删掉就行了,画蛇添足 zzyong00 发表于 2016-5-2 21:08 static/image/common/back.gif
If nColor = 256 Then '颜色为bylayer时不能刷选??????????????????????
...
删了不行,所有按照bylayer的实体颜色值都是256,但是颜色是不一样的。要是删除了,都当成一样选择了 哪估计得选完再过滤了
页:
[1]