EaBIM一直以来积极响应国家“十二五”推进建筑业信息化的号召,对建筑领域的信息技术开展深入技术交流和探讨!致力于打造“BIM-建筑师-生态技术”三位一体综合资源交流共享平台,希望为BIM与可持续设计理念及技术的普及做出微小的贡献!!!

EaBIM

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 3170|回复: 58
打印 上一主题 下一主题

设置两种过滤条件

[复制链接]

1514

主题

7465

帖子

1万

积分

admin

Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10

积分
12404

社区QQ达人

跳转到指定楼层
楼主
发表于 2014-1-14 10:23:37 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

在Inventor中做交互操作时,是否能同时设置kDrawingNoteFilter和kDrawingDimensionFilter两个过滤条件呢?也就是说是否可以让用户选择这两种标注样式呢?

答案是肯定的。除了两个特别的过滤条件(kSketchProfileFilter和kSketch3DProfileFilter),别的类型的过滤条件累加是没有问题的(通过重复调用AddSelectionFilter)。Inventor的开发帮组文档对AddSelectionFilter的参数的解释中暗示了可以增加多个过滤条件:

Parameters
Description
Filter
Input value to be added to the list that specifies the filter or the indication of the type of object(s) being looked for. The valid filters for sketch profile selection are kSketchProfileFilter, kSketch3DProfileFilter or both. If either of these filters is added, no other filters can be added (method returns an error). If any filter other than these two are already added, adding these filters return an error.

下面是我写的VBA测试代码,可以返回用户选取的标注文字和标注尺寸:

Module1:

Sub twoFilters()

' Create a new clsSelect object.

Dim oSelect As New clsSelect

Dim objs As ObjectCollection

Set objs = ThisApplication.TransientObjects.CreateObjectCollection

oSelect.Pick objs

Set oSelect = Nothing


If objs.Count > 0 Then

'Do something here...

End If

objs.Clear

Set objs = Nothing

End Sub


Class clsSelect:

'*************************************************************

' The declarations and functions below need to be copied into

' a class module whose name is "clsSelect". The name can be

' changed but you'll need to change the declaration in the

' calling function "testSelection" to use the new name.


' Declare the event objects

Private WithEvents oInteractEvents As InteractionEvents

Private WithEvents oSelectEvents As SelectEvents

Private oSelectedEnts As ObjectCollection


' Declare a flag that's used to determine when selection stops.

Private bStillSelecting As Boolean


Public Sub Pick(ByRef objCol As ObjectCollection)

' Initialize flag.

bStillSelecting = True


' Create an InteractionEvents object.

Set oInteractEvents = ThisApplication.CommandManager.CreateInteractionEvents


' Ensure interaction is enabled.

oInteractEvents.InteractionDisabled = False


' Set a reference to the select events.

Set oSelectEvents = oInteractEvents.SelectEvents


' Set the filter using the value passed in.

oSelectEvents.SingleSelectEnabled = False

oSelectEvents.AddSelectionFilter kDrawingNoteFilter

oSelectEvents.AddSelectionFilter kDrawingDimensionFilter

oInteractEvents.StatusBarText = "Select note and dimention, ESC to quit."


Set oSelectedEnts = ThisApplication.TransientObjects.CreateObjectCollection

' Start the InteractionEvents object.

oInteractEvents.Start

' Loop until a selection is made.

Do While bStillSelecting

DoEvents

Loop


' Get the selected items.

objCol.Clear

If oSelectedEnts.Count > 0 Then

Dim obj As Object

For Each obj In oSelectedEnts

objCol.Add obj

Next

End If


' Stop the InteractionEvents object.

oInteractEvents.Stop

' Clean up.

Set oSelectEvents = Nothing

Set oInteractEvents = Nothing

End Sub


Private Sub oInteractEvents_OnTerminate()

' Set the flag to indicate we're done.

bStillSelecting = False

End Sub


Private Sub oSelectEvents_OnSelect(ByVal JustSelectedEntities As ObjectsEnumerator, ByVal SelectionDevice As SelectionDeviceEnum, ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As View)

Dim obj As Object

For Each obj In JustSelectedEntities

oSelectedEnts.Add obj

Next

End Sub

Private Sub oSelectEvents_OnUnSelect(ByVal UnSelectedEntities As ObjectsEnumerator, ByVal SelectionDevice As SelectionDeviceEnum, ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As View)

Dim obj As Object

For Each obj In UnSelectedEntities

oSelectedEnts.RemoveByObject obj

Next

End Sub

文章来源:http://blog.csdn.net/barbarahan


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 转播转播 分享分享 分享淘帖 支持支持 反对反对
工作时间:工作日的9:00-12:00/13:30-18:00,节假日不在线,请勿留言

1514

主题

7465

帖子

1万

积分

admin

Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10

积分
12404

社区QQ达人

推荐
 楼主| 发表于 2016-4-10 11:42:37 | 只看该作者

(ˇˍˇ) 路过~
工作时间:工作日的9:00-12:00/13:30-18:00,节假日不在线,请勿留言

14

主题

2892

帖子

2085

积分

BIM经理

Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6

积分
2085
推荐
发表于 2016-4-5 10:12:16 | 只看该作者
(~ ̄▽ ̄)~路过!!~~

1514

主题

7465

帖子

1万

积分

admin

Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10Rank: 10

积分
12404

社区QQ达人

推荐
 楼主| 发表于 2014-6-24 14:53:49 | 只看该作者

学习了 谢谢分享
工作时间:工作日的9:00-12:00/13:30-18:00,节假日不在线,请勿留言
*滑块验证:
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|EaBIM网 ( 苏ICP备2020058923号-1  苏公网安备32011502011255号

GMT+8, 2024-11-16 21:59

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

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