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
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Select all visible objects by GUI tool

Post by bernd »

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

Re: Select all visible objects by GUI tool

Post by triplus »

I know there is an additional Edit -> Select all option.
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Select all visible objects by GUI tool

Post by yorik »

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
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Select all visible objects by GUI tool

Post by triplus »

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
Veteran
Posts: 2598
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Select all visible objects by GUI tool

Post by Chris_G »

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

Re: Select all visible objects by GUI tool

Post by bernd »

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: 179
Joined: Mon Aug 15, 2016 10:23 pm

Re: Select all visible objects by GUI tool

Post by Turro75 »

Hello Bernd,

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

Valerio
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Select all visible objects by GUI tool

Post by wmayer »

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
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Select all visible objects by GUI tool

Post by microelly2 »

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
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Select all visible objects by GUI tool

Post by triplus »

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.
Post Reply