Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Modify Select Filters with a Macro

7 REPLIES 7
Reply
Message 1 of 8
swalroth8KYHK
909 Views, 7 Replies

Modify Select Filters with a Macro

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.

7 REPLIES 7
Message 2 of 8
WCrihfield
in reply to: swalroth8KYHK

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

EESignature

(Not an Autodesk Employee)

Message 3 of 8
swalroth8KYHK
in reply to: WCrihfield

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?

Message 4 of 8

It happens the same for me...

is there any other instruction to add?

Message 5 of 8

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

EESignature

(Not an Autodesk Employee)

Message 6 of 8

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

 

2020-11-06 12_44_09-Marking Menu.png

Message 7 of 8

@filippo.toniello Did you find a solution? I'm interested in the same solution such as Set a custom filter using a button or something like that.
Message 8 of 8

nope

almost in 2020 release

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report