设置两种过滤条件
在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 clsSelectDim objs As ObjectCollectionSet objs = ThisApplication.TransientObjects.CreateObjectCollectionoSelect.Pick objsSet oSelect = Nothing
If objs.Count > 0 Then'Do something here...End Ifobjs.ClearSet objs = NothingEnd 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 objectsPrivate WithEvents oInteractEvents As InteractionEventsPrivate WithEvents oSelectEvents As SelectEventsPrivate 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 = FalseoSelectEvents.AddSelectionFilter kDrawingNoteFilteroSelectEvents.AddSelectionFilter kDrawingDimensionFilteroInteractEvents.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 bStillSelectingDoEventsLoop
' Get the selected items.objCol.ClearIf oSelectedEnts.Count > 0 ThenDim obj As ObjectFor Each obj In oSelectedEntsobjCol.Add objNextEnd If
' Stop the InteractionEvents object.oInteractEvents.Stop' Clean up.Set oSelectEvents = NothingSet oInteractEvents = NothingEnd Sub
Private Sub oInteractEvents_OnTerminate()' Set the flag to indicate we're done.bStillSelecting = FalseEnd 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 ObjectFor Each obj In JustSelectedEntitiesoSelectedEnts.Add objNextEnd SubPrivate 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 ObjectFor Each obj In UnSelectedEntitiesoSelectedEnts.RemoveByObject objNextEnd Sub 文章来源:http://blog.csdn.net/barbarahan
(ˇˍˇ) 路过~ (~ ̄▽ ̄)~路过!!~~
学习了 谢谢分享 (*^__^*) 嘻嘻…… 路过!!!
帮顶…… 路过!!!
不发表意见…… 路过!!!
不发表意见…… 顶......
楼下跟上..... 顶!!!!!!!!!!!!!!!!!!!!!!!!! 顶!!!!!!!!!!!!!!!!!!!!!!!!! 顶......
楼下跟上..... 顶起来………… 顶!!!!!!!!!!!!!!!!!!!!!!!!! 路过!!!
帮顶…… (*^__^*) 嘻嘻…… 顶......
楼下跟上..... 路过!!!
帮顶……