明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1839|回复: 10

过滤器的选择的问题

[复制链接]
发表于 2015-2-2 21:52 | 显示全部楼层 |阅读模式
按理来说我这个没错误,但一运行显示 参数 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


发表于 2015-2-2 23:20 | 显示全部楼层
SSet.SelectOnScreen filtertype, filterdate
filtertype,filterdate必须是变体variant,而不是数组,你再定义两个变体,把这两个数组赋值给定义的两个变体即可

点评

你这就是误导人家! 第一个数组绝对不需要是变体类型  发表于 2015-2-4 11:00
发表于 2015-2-2 23:47 来自手机 | 显示全部楼层
本帖最后由 wangshuping42 于 2015-2-4 11:06 编辑

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

  2.     Dim sset As AcadSelectionSet
  3.     Dim filtertype(0 To 3) As Integer
  4.     Dim filterdate(0 To 3) As Variant
  5.    
  6.     Set sset = ThisDrawing.SelectionSets.Add("test")
  7.     filtertype(0) = -4
  8.     filterdate(0) = "<or"
  9.     filtertype(1) = 0
  10.     filterdate(1) = "lwpolyline"
  11.     filtertype(2) = 0
  12.     filterdate(2) = "line"
  13.     filtertype(3) = -4
  14.     filterdate(3) = "or>"
  15.     ThisDrawing.Utility.Prompt "选择要偏移的多段线:"
  16.     sset.SelectOnScreen filtertype, filterdate
  17.    
  18. End Sub

点评

请先充实一下自己,再来说别人吧!  发表于 2015-2-3 10:53
发表于 2015-2-2 23:49 来自手机 | 显示全部楼层

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

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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x

点评

呵呵,好吧,你赢了  发表于 2015-2-4 13:52
发表于 2015-2-3 10:54 | 显示全部楼层
本帖最后由 zzyong00 于 2015-2-3 22:22 编辑

  1. Public Sub ss()
  2. Dim filtertype(0 To 3) As Integer
  3.     Dim filterdate(0 To 3) As Variant
  4.     filtertype(0) = -4
  5.     filterdate(0) = "<or"
  6.     filtertype(1) = 0
  7.     filterdate(1) = "lwpolyline"
  8.     filtertype(2) = 0
  9.     filterdate(2) = "line"
  10.     filtertype(3) = -4
  11.     filterdate(3) = "or>"
  12.     ThisDrawing.Utility.Prompt "选择要偏移的多段线:"
  13.     Dim ft As Variant, fd As Variant
  14.     ft = filtertype: fd = filterdate
  15.     Dim SSet As AcadSelectionSet
  16.     ThisDrawing.SelectionSets("ss1").Delete
  17.     Set SSet = ThisDrawing.SelectionSets.Add("ss1")
  18.     SSet.SelectOnScreen ft, fd
  19. End Sub
 楼主| 发表于 2015-2-3 21:52 | 显示全部楼层
zzyong00 发表于 2015-2-3 10:54

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

点评

啥叫开不出来?能运行不比不能运行好吗?实现目的是错吗?早知道如此,我何必呢  发表于 2015-2-3 22:07
发表于 2015-2-4 11:11 | 显示全部楼层
charlesli8 发表于 2015-2-3 21:52
你写的这个运行起来可以  ft  和fd开不出来有啥用啊

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


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2015-2-4 12:39 | 显示全部楼层
嗯   多谢了 各位  领教
发表于 2015-2-4 13:36 | 显示全部楼层
本帖最后由 zzyong00 于 2015-2-4 13:51 编辑

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

FilterType

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

FilterData

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

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

发表于 2015-2-4 13:40 | 显示全部楼层
  1. 另外:如果仅仅是选多种对象,只需要这样就行!

  2. Public Sub asdf()
  3. On Error Resume Next
  4.     Dim filtertype(0) As Integer
  5.     Dim filterdate(0) As Variant
  6.     filtertype(0) = 0
  7.     filterdate(0) = "lwpolyline,line,arc,circle"
  8.     Dim ft As Variant, fd As Variant
  9.     ft = filtertype: fd = filterdate
  10.     Dim SSet As AcadSelectionSet
  11.     ThisDrawing.SelectionSets("ss1").Delete
  12.     Set SSet = ThisDrawing.SelectionSets.Add("ss1")
  13.     SSet.SelectOnScreen ft, fd
  14. End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-2 21:33 , Processed in 0.198876 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表