bug? Duplicate multi selection of sketch element produces many sketches

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
jmaustpc
Posts: 8827
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

bug? Duplicate multi selection of sketch element produces many sketches

Postby jmaustpc » Thu Oct 22, 2015 3:29 am

Hi all
I noticed to day that if you create a sketch, then with it not in edit mode, you multi select several edges and then do any of
1) Edit menu... Duplicate selection
2) Draft ...Clone
3)Part... Simple copy
The result is multiple complete sketches.

Here is just a very simple sketch, a rectangle with a circle inside.
sketchselecttesting.fcstd
(9.04 KiB) Downloaded 18 times
In this I am talking about selecting edges from a sketch via the GUI in the main window while the sketch is not in edit mode.

If you "shift B" "box select" all the sketcher elements in the main window and Draft Clone etc. you get one Clone or new sketch etc. as you would expect.

However if you select something like 2 edges of the rectangle using "control left click" Clone etc. will out put 2 (or however many edges are selected) copies of the entire sketch.

Is this a bug? I would have thought in the above scenario one would expect the outcome to either be one complete copy of the entire sketch, or the creation of a new sketch that contains only the selected edges.

Jim


OS: Kubuntu 14.04.3 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.5764 (Git)
Build type: Release
Branch: master
Hash: eff27994e57bc1eb07af8f378d1b85e3b635e194
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
wmayer
Site Admin
Posts: 13608
Joined: Thu Feb 19, 2009 10:32 am

Re: bug? Duplicate multi selection of sketch element produces many sketches

Postby wmayer » Thu Oct 22, 2015 7:53 am

Is this a bug? I would have thought in the above scenario one would expect the outcome to either be one complete copy of the entire sketch, or the creation of a new sketch that contains only the selected edges.
Yes, that's clearly a bug. The expected behaviour is to make a SINGLE and FULL copy of the selected object. It shouldn't make a difference whether you select the whole object (in the tree), one or several sub-elements (in the view).

Btw, when creating a sketch rectangle, select all edges and then Duplicate selection it creates four sketches but three of them are completely empty.

When doing box-selection:

Code: Select all

s=Gui.Selection.getSelectionEx()[0]
s.SubElementNames # ==> empty tuple
When selecting the individual edges:

Code: Select all

s=Gui.Selection.getSelectionEx()[0]
s.SubElementNames # ==> ('Edge4', 'Edge1', 'Edge2', 'Edge3')
DeepSOIC
Posts: 6293
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: bug? Duplicate multi selection of sketch element produces many sketches

Postby DeepSOIC » Thu Oct 22, 2015 1:24 pm

Hmm... what you see is a bug. What I see is a feature =) - a strange way to make a few copies at once!
But "Duplicate selection" command produces only one copy, and the other sketches are indeed empty, which can be considered a bug in that strange feature.

EDIT: please don't listen to me, it's a counterintuitive "feature".
jmaustpc
Posts: 8827
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: bug? Duplicate multi selection of sketch element produces many sketches

Postby jmaustpc » Thu Oct 22, 2015 1:28 pm

User avatar
Kunda1
Posts: 3672
Joined: Thu Jan 05, 2017 9:03 pm

Re: bug? Duplicate multi selection of sketch element produces many sketches

Postby Kunda1 » Thu Jan 26, 2017 9:50 pm

soft bump
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Kunda1
Posts: 3672
Joined: Thu Jan 05, 2017 9:03 pm

Re: bug? Duplicate multi selection of sketch element produces many sketches

Postby Kunda1 » Sun Oct 01, 2017 8:21 pm

wmayer offered fix:
git commit ce559a4643e5 fixes creation of simple copies. Duplicate selection was fixed in the past.
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Kunda1
Posts: 3672
Joined: Thu Jan 05, 2017 9:03 pm

Re: bug? Duplicate multi selection of sketch element produces many sketches

Postby Kunda1 » Sat Nov 18, 2017 8:49 am

Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
damian
Posts: 583
Joined: Sun May 31, 2015 6:16 pm

Re: bug? Duplicate multi selection of sketch element produces many sketches

Postby damian » Sat Nov 18, 2017 12:29 pm

In the Draft module (Draft.py) to include a function

Code: Select all

def consolidateSelection():
    ""
    if gui:
        selection = []
        for obj in FreeCADGui.Selection.getSelection():
            if obj not in selection:
                selection.append(obj)
    	return  selection
    # return FreeCADGui.Selection.getSelection()
Later, to apply it in Draft_Clone and Draft_Mirror commands
EDIT GRAMMAR: consolidateSelection
EDIT INDENTATION: return