Oceanable 发表于 2019-3-16 13:00:25

这样写代码为何无法隐藏选择的对象?

========================================================
Public Sub HideSelect()

Dim SeleObjts As AcadSelectionSet
CreateSelectionSet SeleObjts, "Seleobjts": SeleObjts.SelectOnScreen

Dim Objt As AcadEntity

For Each Objt In SeleObjts
Objt.Visible = False
Next Objt

ThisDrawing.Regen acAllViewports

End Sub
========================================================
上述代码为何无法隐藏选择的对象?
尝试过,只显示选择的对象是可以的,呵呵,,,,

Oceanable 发表于 2019-6-7 12:37:52

这里十分奇怪啊,,,,请高手指教。

zzyong00 发表于 2019-6-7 12:48:27

如果你的CreateSelectionSet 没问题,这代码应该没问题

Oceanable 发表于 2019-6-7 16:02:19

zzyong00 发表于 2019-6-7 12:48
如果你的CreateSelectionSet 没问题,这代码应该没问题

我已经尝试过,选择对象后,只显示是可以的,就是将其他对象的 visible 属性设置为 false。所以我选择对象这个自编函数应该是没有问题的。

现在就是“隐藏选择对象”不行,所以很奇怪。

我等下将所有代码都贴上来:

Oceanable 发表于 2019-6-7 18:43:40

zzyong00 发表于 2019-6-7 12:48
如果你的CreateSelectionSet 没问题,这代码应该没问题

Public Sub CreateSelectionSet(SeleObjects As AcadSelectionSet, Name As String)

On Error Resume Next

If Not IsNull(ThisDrawing.SelectionSets.Item(Name)) Then
Set SeleObjects = ThisDrawing.SelectionSets.Item(Name)
SeleObjects.Delete
End If

Set SeleObjects = ThisDrawing.SelectionSets.Add(Name)

End Sub

==========================================================

Public Sub HideSelect()

Dim SeleObjts As AcadSelectionSet
CreateSelectionSet SeleObjts, "Seleobjts": SeleObjts.SelectOnScreen

On Error Resume Next

Dim Objt As AcadEntity

For Each Objt In SeleObjts
Objt.Visible = False
Next Objt

ThisDrawing.Regen acAllViewports

End Sub
页: [1]
查看完整版本: 这样写代码为何无法隐藏选择的对象?