[not bug] GetSelectionEx: selection order information is incomplete

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

[not bug] GetSelectionEx: selection order information is incomplete

Post by DeepSOIC »

1. make two Part Cubes, move them apart
2. select edges in this order:
select-order.png
select-order.png (7.44 KiB) Viewed 1077 times
3.

Code: Select all

>>> [(so.Object.Name, so.SubElementNames) for so in Gui.Selection.getSelectionEx()]
[('Box001', ('Edge12', 'Edge10')), ('Box', ('Edge12', 'Edge10'))]
As it should be clear from the console dump, it is impossible to figure out the true order in which the edges have been selected, as both Box001's edges have been grouped into one selection object.

This bug was causing me some trouble when invoking attachment with preselection.

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.21.0.32457 (Git)
Build type: Release
Branch: master
Hash: 85216bd12730bbc4c3cbf8f0bc50416ab1556cbb
Python 3.10.9, Qt 5.15.8, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: English/Germany (en_DE)
Installed mods: 
  * CurvesWB 0.4.4
  * DeepConsole
  * fir_design
  * Lattice2 1.0.0
  * Part-o-magic 1.1.0
  * TabBar
  * _disabled
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: GetSelectionEx: selection order information is incomplete

Post by openBrain »

I can confirm but it doesn't qualify as a bug.
It is ... well .. as intended.

You can get what you're expecting (I guess) with :

Code: Select all

[(so.Object.Name, so.SubElementNames) for so in Gui.Selection.getCompleteSelection()]
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: GetSelectionEx: selection order information is incomplete

Post by DeepSOIC »

okay, somehow i didn't know that, thanks!
freedman
Veteran
Posts: 3436
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: [not bug] GetSelectionEx: selection order information is incomplete

Post by freedman »

I remember an issue I had; as I clicked on objects using getSelectionEx it worked as expected except for one thing, it would not return anything for a click on a Body in the tree. It was strange because every other clicked item returned something. I will post some code if there is some question.
Thanks

I think I used "getSelectionEx()[0]
Edit; Changed selection type
Post Reply