Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.
When creating drawings I have a lot of parts within section views, so I often use the "Edit Select Filters..." option to only pick either Hatch or Edge as needed. It can get time consuming to jump back and forth between the two. I was hoping to create a couple VBA macros that could be embedded into the ribbon and/or shortcut menu.
The first would clear all filter options, set only "Hatch", and activate the custom filters.
The second would do the same for "Edge".
Beyond that I would like to be able to create more as needed, but I cannot find anything about changing that setting. I tried using "SelectEvents", SelectionPreferences", and "SelectSet", but only seem to affect part and assembly selection options.
I'm not entirely sure how to select only the Hatch yet, but I have this code for narrowing the SelectionPreferences to kEdgeObject only.
Dim oDoc As DrawingDocument
Set oDoc = ThisDrawing.Document
Dim oSelPref As SelectionPreferences Set oSelPref = oDoc.SelectionPreferences oSelPref.Clear oSelPref.Add(ObjectTypeEnum.kEdgeObject)
When I select the Hatch manually, then attempt to get the ObjectTypeEnum from it, I get the kSectionDrawingViewObject, for some reason.
Wesley Crihfield
(Not an Autodesk Employee)
I think I must be doing something wrong. I tried your code and got a 424 error ("Object required") so I switched line 2 to:
Set oDoc = ThisApplication.ActiveDocument
It runs without issue now, but nothing changes. The actual filter list does not change nor does my ability to select drawing elements change.
I tried something similar to this earlier and had the same issue. Is there perhaps something wrong with my Inventor preventing this from firing properly?
Unfortunately, this setting doesn't appear to stay in place after the macro has finished. I'm not sure why.
The API documentation says the SelectionPreferences was added in version 2016.
Somehow this doesn't appear to be the same thing as when you manually click the 'Select' tool (within the Quick Access Toolbar), and choose "Edit Select Filters..." from the drop-down, then manually check and uncheck check boxes next to all the different types of objects you want to (or don't want to) be able to select within the drawing environment. It seems like the folks at Autodesk need to clarify how this is supposed to work (when done purely by code), or at least clarify if this functionality is even available (working) yet.
On another note though, you CAN set the 'SelectionPriority' by VBA macro (or by an iLogic rule) and that setting will stay in-place after the macro has finished though.
The API documentation says the SelectionPriority was added in version 2008.
Here's the VBA code to set the drawing's SelectionPriority to Edges.
Sub Set_Edge_Selection_Priority()
If ThisApplication.ActiveDocumentType <> kDrawingDocumentObject Then
a = MsgBox("This macro only works when a Drawing document is active. Exiting.", vbOKOnly + vbCritical, " ")
Exit Sub
End If
Dim oDDoc As DrawingDocument
Set oDDoc = ThisApplication.ActiveDocument
oDDoc.SelectionPriority = kEdgeSelectionPriority
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
If you have time, please... Vote For My IDEAS :light_bulb:and Explore My CONTRIBUTIONS
Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield
(Not an Autodesk Employee)
Thanks for the suggestion but unfortunaltely it is not what it is necessary.
I would like to set custom filters mode and select it in drawing , like suggested in another thread, to avoid to select continuosly and not intentionally views during drafting process.
Like creo does with one click
Can't find what you're looking for? Ask the community or share your knowledge.