找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 595|回复: 0

[VBA程序]:设置BLOCK和LAYER的“过滤器”

[复制链接]

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-10-9 13:57:24 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×

  1. [FONT=century gothic]
  2. How to setup selectionset filters for a block or layer?  
  3. ID    19147  
  4. Applies to:    AutoCAD 2000

  5. This document is part of    Layers   Block Reference   COM-ActiveX Interfaces   Selecting Entities   Selection Sets   VBA     


  6. Question
  7. How do I use a selection set filter to select a block with a particular name
  8. that is on a particular layer ?
  9. Answer
  10. The following sample code allows you to select blocks based on this criteria:

  11. 1. selectALayer() - create a selectionset with entities on "layer1"
  12. 2. selectABlock() - create a selectionset with a block insert "testBlock"
  13. 3. selectABlockOnALayer() - create a selectionset with a block insert
  14. "testBlock"
  15.   on "layer1"
  16. Sub selectALayer()
  17.    Dim sset As Object
  18.    
  19.    Set sset = ThisDrawing.SelectionSets.Add("TestSet1")
  20.    Dim filterType As Variant
  21.    Dim filterData As Variant
  22.    Dim p1(0 To 2) As Double
  23.    Dim p2(0 To 2) As Double
  24.    
  25.    Dim grpCode(0) As Integer
  26.    grpCode(0) = 8
  27.    filterType = grpCode
  28.    Dim grpValue(0) As Variant
  29.    grpValue(0) = "layer1"
  30.    filterData = grpValue
  31.        
  32.    sset.Select acSelectionSetAll, p1, p2, filterType, filterData
  33.    
  34. End Sub

  35. Sub selectABlock()
  36.    Dim sset As Object
  37.    
  38.    Set sset = ThisDrawing.SelectionSets.Add("TestSet2")
  39.    Dim filterType As Variant
  40.    Dim filterData As Variant
  41.    Dim p1(0 To 2) As Double
  42.    Dim p2(0 To 2) As Double
  43.    
  44.    Dim grpCode(0) As Integer
  45.    grpCode(0) = 2
  46.    filterType = grpCode
  47.    Dim grpValue(0) As Variant
  48.    grpValue(0) = "testBlock"
  49.    filterData = grpValue
  50.        
  51.    sset.Select acSelectionSetAll, p1, p2, filterType, filterData
  52. End Sub


  53. Sub selectABlockOnALayer()
  54.    Dim sset As Object
  55.    
  56.    Set sset = ThisDrawing.SelectionSets.Add("TestSet3")
  57.    Dim filterType As Variant
  58.    Dim filterData As Variant
  59.    Dim p1(0 To 2) As Double
  60.    Dim p2(0 To 2) As Double
  61.    
  62.    Dim grpCode(0 To 1) As Integer
  63.    grpCode(0) = 8
  64.    grpCode(1) = 2
  65.    filterType = grpCode
  66.    Dim grpValue(0 To 1) As Variant
  67.    grpValue(0) = "layer1"
  68.    grpValue(1) = "testBlock"
  69.    filterData = grpValue
  70.    
  71.    sset.Select acSelectionSetAll, p1, p2, filterType, filterData
  72. End Sub[/FONT]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-5-6 07:52 , Processed in 0.342643 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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