Temporarily disable preselection in complete view

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Temporarily disable preselection in complete view

Post by HoWil »

Hi,
is it possible to temporarily disable preselection in the complete view.
I need this for a script I am working on where preseleciton is obstructive. There it prevents a directly view on highlighted inner faces/edges (see viewtopic.php?f=18&t=12381&p=151950#p151950). A manual workaround is to temporarily set the/all element/s to 'Selectable=False'. I could also set 'Selectable=False' for each object under the mouse cursor by script and restore its original state afterwards but I am sure there has to be a simpler and directer approach 8-) .

I found a similar post (viewtopic.php?f=22&t=17684&hilit=preselection) on disabling preselection for specific elements but want avoid this.

Thank you in advance,
HoWil
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Temporarily disable preselection in complete view

Post by wmayer »

Code: Select all

from pivy import coin
view=Gui.ActiveDocument.ActiveView.getViewer()
root=view.getSceneGraph()
root.highlightMode.getValue()
root.highlightMode.setValue(2) # off
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Temporarily disable preselection in complete view

Post by HoWil »

Thank you wmayer,
is exactly what I was looking for!
BR,
HoWil
User avatar
paddle
Veteran
Posts: 1413
Joined: Mon Feb 03, 2020 4:47 pm

Re: Temporarily disable preselection in complete view

Post by paddle »

wmayer wrote: Sun Jan 08, 2017 11:57 am

Code: Select all

from pivy import coin
view=Gui.ActiveDocument.ActiveView.getViewer()
root=view.getSceneGraph()
root.highlightMode.getValue()
root.highlightMode.setValue(2) # off
Is it possible to do that with the selection filter ? If so what is the string to use ?

Code: Select all

        filter = Gui.Selection.Filter('SELECT None')
        Gui.Selection.addSelectionGate(filter)

        Gui.Selection.removeSelectionGate()
Alternatively, how do you cancel the inactivation as per your code snippet?
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Temporarily disable preselection in complete view

Post by wmayer »

Is it possible to do that with the selection filter ? If so what is the string to use ?
You can do this

Code: Select all

Gui.Selection.addSelectionGate('SELECT None')
or use any string which isn't an existing typeid. Your suggestion by creating an instance of Gui.Selection.Filter should work too but crashes with current master (looks like a recent regression because in v0.21 it works).
Alternatively, how do you cancel the inactivation as per your code snippet?

Code: Select all

root.highlightMode.setValue(0)
Post Reply