Select all visible objects by GUI tool

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
bernd
Posts: 8041
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Select all visible objects by GUI tool

Postby bernd » Sun Dec 18, 2016 2:23 pm

Is theres some GUI tool in FreeCAD to select all visible objects ? If ctrl->A is used all objects are selected!
triplus
Posts: 8439
Joined: Mon Dec 12, 2011 4:45 pm

Re: Select all visible objects by GUI tool

Postby triplus » Sun Dec 18, 2016 2:50 pm

I know there is an additional Edit -> Select all option.
User avatar
yorik
Site Admin
Posts: 11387
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Select all visible objects by GUI tool

Postby yorik » Sun Dec 18, 2016 2:51 pm

Not that I know of, but it's easy to do with a little macro (code below might contain syntax errors):

Code: Select all

Gui.Selection.clearSelection()
for obj in FreeCAD.ActiveDocument.Objects:
    if obj.ViewObject.isVisible():
        Gui.Selection.addSelection(obj)
triplus
Posts: 8439
Joined: Mon Dec 12, 2011 4:45 pm

Re: Select all visible objects by GUI tool

Postby triplus » Sun Dec 18, 2016 5:21 pm

I see i was too quick as i thought you are after GUI counterpart for CTRL +A (instead you where just after visible objects). ;)
User avatar
Chris_G
Posts: 1058
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Select all visible objects by GUI tool

Postby Chris_G » Sun Dec 18, 2016 5:31 pm

The Box Selection (Shift+B) should do it ?
User avatar
bernd
Posts: 8041
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Select all visible objects by GUI tool

Postby bernd » Tue Dec 20, 2016 9:39 pm

Thanks guys for your help.
yorik wrote:Not that I know of, but it's easy to do with a little macro (code below might contain syntax errors):

Code: Select all

Gui.Selection.clearSelection()
for obj in FreeCAD.ActiveDocument.Objects:
    if obj.ViewObject.isVisible():
        Gui.Selection.addSelection(obj)
How is it possible to add such an python command to the Main FreeCAD Gui as a new entry in Edit --> select all visible just under select all. Where do I have to look for this or is it not possible to add a command by python to the FreeCAD GUI. I had a look but I have done only very rare development outside FEM or Arch module and never anything in FreeCAD Gui.

Bernd
Turro75
Posts: 166
Joined: Mon Aug 15, 2016 10:23 pm

Re: Select all visible objects by GUI tool

Postby Turro75 » Tue Dec 20, 2016 11:21 pm

Hello Bernd,

here the simplest way to obtain a system command:
http://www.freecadweb.org/wiki/index.ph ... e_Toolbars

Valerio
wmayer
Site Admin
Posts: 14445
Joined: Thu Feb 19, 2009 10:32 am

Re: Select all visible objects by GUI tool

Postby wmayer » Wed Dec 21, 2016 8:49 am

How is it possible to add such an python command to the Main FreeCAD Gui as a new entry in Edit --> select all visible just under select all. Where do I have to look for this or is it not possible to add a command by python to the FreeCAD GUI.
There is no proper solution to customize the menus. You can try to use Qt stuff to access the menu and manipulate it but as soon as you switch to another workbench your changes might be lost again. The only customization that we actively support is adding your own additional toolbars. Then you can write a macro and bind it to a command and use this command in a custom toolbar.

But I think we can write a proper C++ command for this and add it to the Visibility sub-menu under View.
User avatar
microelly2
Posts: 4319
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Select all visible objects by GUI tool

Postby microelly2 » Wed Dec 21, 2016 9:15 am

You can connect the workbench change with your own menu-update method

Code: Select all

def r(*arg):
	FreeCAD.Console.PrintMessage("You will update your menues here")

t=Gui.getMainWindow()
t.workbenchActivated.connect(r)
triplus
Posts: 8439
Joined: Mon Dec 12, 2011 4:45 pm

Re: Select all visible objects by GUI tool

Postby triplus » Wed Dec 21, 2016 12:28 pm

On a slightly unrelated note i have created AccessoriesMenu module i plan to release in the future. I have around 30% work left to do for the first release. ETA was December 2016 but it looks like January 2017 will be it. It adds additional Accessories menu entry at the bottom of the Tools menu. One use case for it is it can be used for adding commands to it.

But there is another problem involved. If you want to add a Python command to it and for the command to be there when you open the menu command must exist first. And this isn't how FreeCAD works. FreeCAD works in a way you add Python command to a workbench and only after the workbench is loaded command is available.

Therefore for adding and using Python command in all workbenches 2 things would need to happen.

One is the mentioned work on adding some support to menubar. And another is to have a standard way to load FreeCAD command when FreeCAD loads. And not only after the workbench that has a command in it is loaded. The solution i plan to offer is Autoload (as seen in TabBar) and AccessoriesMenu module. Likely not 100% perfect but it does the job and offers more choice compared to the choice the user/dev has ATM.