charlesli8 发表于 2015-2-2 21:52:27

过滤器的选择的问题

按理来说我这个没错误,但一运行显示 参数 filter list(位于selectonscreen中)无效    麻烦帮忙看看啊
'设置过滤器
    Dim filtertype(0 To 3) As Integer
    Dim filterdate(0 To 3) As Variant
    filtertype(0) = -4
    filterdate(0) = " <or "
    filtertype(1) = 0
    filterdate(1) = "lwpolyline"
    filtertype(2) = 0
    filterdate(2) = "line"
    filtertype(3) = -4
    filterdate(3) = " or > "
    ThisDrawing.Utility.Prompt "选择要偏移的多段线:"
    SSet.SelectOnScreen filtertype, filterdate


zzyong00 发表于 2015-2-2 23:20:00

SSet.SelectOnScreen filtertype, filterdate
filtertype,filterdate必须是变体variant,而不是数组,你再定义两个变体,把这两个数组赋值给定义的两个变体即可

wangshuping42 发表于 2015-2-2 23:47:10

本帖最后由 wangshuping42 于 2015-2-4 11:06 编辑

我现在有电脑测试了,发现楼主的问题就是在数组中多打了空格,按下面的就可以了Sub Test()

    Dim sset As AcadSelectionSet
    Dim filtertype(0 To 3) As Integer
    Dim filterdate(0 To 3) As Variant
   
    Set sset = ThisDrawing.SelectionSets.Add("test")
    filtertype(0) = -4
    filterdate(0) = "<or"
    filtertype(1) = 0
    filterdate(1) = "lwpolyline"
    filtertype(2) = 0
    filterdate(2) = "line"
    filtertype(3) = -4
    filterdate(3) = "or>"
    ThisDrawing.Utility.Prompt "选择要偏移的多段线:"
    sset.SelectOnScreen filtertype, filterdate
   
End Sub

wangshuping42 发表于 2015-2-2 23:49:45

某些人不服气,我就上个视频

本帖最后由 wangshuping42 于 2015-2-4 11:15 编辑

zzyong00 发表于 2015-2-3 10:54:27

本帖最后由 zzyong00 于 2015-2-3 22:22 编辑

Public Sub ss()
Dim filtertype(0 To 3) As Integer
    Dim filterdate(0 To 3) As Variant
    filtertype(0) = -4
    filterdate(0) = "<or"
    filtertype(1) = 0
    filterdate(1) = "lwpolyline"
    filtertype(2) = 0
    filterdate(2) = "line"
    filtertype(3) = -4
    filterdate(3) = "or>"
    ThisDrawing.Utility.Prompt "选择要偏移的多段线:"
    Dim ft As Variant, fd As Variant
    ft = filtertype: fd = filterdate
    Dim SSet As AcadSelectionSet
    ThisDrawing.SelectionSets("ss1").Delete
    Set SSet = ThisDrawing.SelectionSets.Add("ss1")
    SSet.SelectOnScreen ft, fd
End Sub

charlesli8 发表于 2015-2-3 21:52:07

zzyong00 发表于 2015-2-3 10:54 static/image/common/back.gif


你写的这个运行起来可以ft和fd开不出来有啥用啊

wangshuping42 发表于 2015-2-4 11:11:01

charlesli8 发表于 2015-2-3 21:52 static/image/common/back.gif
你写的这个运行起来可以ft和fd开不出来有啥用啊

zzyong00的解释不对,你的写法是对的,就是多打了空格,见下图


charlesli8 发表于 2015-2-4 12:39:47

嗯   多谢了 各位领教

zzyong00 发表于 2015-2-4 13:36:28

本帖最后由 zzyong00 于 2015-2-4 13:51 编辑

SelectOnScreen 方法
提示用户从屏幕上拾取对象。
语法
object.SelectOnScreen [, FilterData]
Object
    SelectionSet
   使用该方法的对象。

FilterType

   Variant[变体](整数数组); 仅用于输入; 可选项
    指定使用的过滤器类型的 DXF 组码。

FilterData

   Variant[变体](变体数组); 仅用于输入; 可选项
   过滤器的值。

-----------------------------

zzyong00 发表于 2015-2-4 13:40:10

另外:如果仅仅是选多种对象,只需要这样就行!

Public Sub asdf()
On Error Resume Next
    Dim filtertype(0) As Integer
    Dim filterdate(0) As Variant
    filtertype(0) = 0
    filterdate(0) = "lwpolyline,line,arc,circle"
    Dim ft As Variant, fd As Variant
    ft = filtertype: fd = filterdate
    Dim SSet As AcadSelectionSet
    ThisDrawing.SelectionSets("ss1").Delete
    Set SSet = ThisDrawing.SelectionSets.Add("ss1")
    SSet.SelectOnScreen ft, fd
End Sub
页: [1] 2
查看完整版本: 过滤器的选择的问题