huazhijia 发表于 2006-4-13 12:04:00

请斑竹过来看看,重复点程序有无问题?请指教!

<P>Sub delchongfupoint()<BR>Dim entity As AcadPoint<BR>Dim xyz As Variant<BR>Dim i As Double<BR>Dim j As Double<BR>Dim counter As Integer<BR>Dim ftype(0 To 1) As Integer<BR>Dim fdata(0 To 1) As Variant<BR>Dim sset As AcadSelectionSet<BR>'初始颜色是acwhite;扫描过的颜色是acblue;重合点的颜色是acred<BR>If ThisDrawing.ModelSpace.Count &lt;&gt; 0 Then<BR>&nbsp; i = ThisDrawing.ModelSpace.Count<BR>'先循环一下,初始化设置所有的颜色为acwhite,如果已知颜色的话是不需要做的<BR>&nbsp; For j = 0 To i - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set entity = ThisDrawing.ModelSpace.Item(j)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entity.Color = acWhite<BR>&nbsp; Next j<BR>&nbsp; For j = 0 To i - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set entity = ThisDrawing.ModelSpace.Item(j)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xyz = entity.Coordinates&nbsp; '取得点的坐标<BR>'判断图形中是否已经存在同名的选择集<BR>&nbsp; On Error Resume Next<BR>&nbsp;&nbsp;&nbsp;&nbsp; If Not IsNull(ThisDrawing.SelectionSets.Item("sset")) Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set sset = ThisDrawing.SelectionSets.Item("sset")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sset.Delete&nbsp;&nbsp;&nbsp; '及时删除不用的选择集非常重要<BR>&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>'创建新选择集<BR>&nbsp;&nbsp;&nbsp;&nbsp; Set sset = ThisDrawing.SelectionSets.Add("sset")<BR>&nbsp;&nbsp;&nbsp;&nbsp; If Err Then Set sset = ThisDrawing.SelectionSets.Add("sset")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sset.Clear<BR>'指定过滤机制<BR>&nbsp; ftype(0) = 0: fdata(0) = "point"<BR>&nbsp; ftype(1) = 8: fdata(1) = "*"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '图层名<BR>'使用crossing的选择模式<BR>&nbsp; sset.Select acSelectionSetCrossing, xyz, xyz, ftype, fdata<BR>&nbsp;&nbsp;&nbsp;&nbsp; Dim obj As AcadPoint<BR>&nbsp;&nbsp;&nbsp;&nbsp; For Each obj In sset<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If obj.Color = acBlue Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; obj.Color = acRed<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If obj.Color = acWhite Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; obj.Color = acBlue<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp; Next<BR>&nbsp; Next j<BR>MsgBox "描点结束!"<BR>Else<BR>MsgBox "在模型空间中没有对象存在。"<BR>End If<BR>End Sub</P>
<P>'请教斑竹,我用acSelectionSetCrossing时,不是只选择这个xyz上的点吗,但是程序运行,有的时候它旁边的点也变红,不知道是怎么回事,请指教!</P>
<P>这是我根据买你的VBA书写的,请赐教!</P>

esri 发表于 2006-4-13 20:24:00

<P>cad用点来选择是不准的!</P>

huazhijia 发表于 2006-4-14 20:27:00

<P>那么怎么根据一个坐标,将这个坐标上所有的点能选中呢?</P>
页: [1]
查看完整版本: 请斑竹过来看看,重复点程序有无问题?请指教!