Force user to select a special subobject (face, line, vertex)
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Force user to select a special subobject (face, line, vertex)
Have you ever used 3D Wings? There are some icons that let you easily avoid selecting wrong (face, line or vertex) when you click an object.
Please look at the picture. You can choose if you want to select an object, a face, a line or a vertex when you are clicking to the object.
I would like to have that in my workbench .. either if there is existing functionality or I have to think how I can achieve that.
I tried google I couldn't find an answer. I might be wrong but I need your help thanks.
Please look at the picture. You can choose if you want to select an object, a face, a line or a vertex when you are clicking to the object.
I would like to have that in my workbench .. either if there is existing functionality or I have to think how I can achieve that.
I tried google I couldn't find an answer. I might be wrong but I need your help thanks.
- Attachments
-
- Wings_Selecting_mechanism.jpg (29.86 KiB) Viewed 875 times
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
-
- Posts: 529
- Joined: Fri Sep 18, 2020 5:40 pm
Re: Force user to select a special subobject (face, line, vertex)
This is possible. For example, in PartDesign certain commands control what you can select by using a the ReferenceSelection class. Have a look at
src/Mod/PartDesign/Gui/ReferenceSelection.cpp.
src/Mod/PartDesign/Gui/ReferenceSelection.cpp.
Re: Force user to select a special subobject (face, line, vertex)
Could this class help me?
Code: Select all
addSelectionGate(...)
addSelectionGate(String|Filter|Gate, resolve=1) -- activate the selection gate.
The selection gate will prohibit all selections which do not match
the given selection filter string.
Examples strings are:
'SELECT Part::Feature SUBELEMENT Edge',
'SELECT Robot::RobotObject'
You can also set an instance of SelectionFilter:
filter = Gui.Selection.Filter('SELECT Part::Feature SUBELEMENT Edge')
Gui.Selection.addSelectionGate(filter)
And the most flexible approach is to write your own selection gate class
that implements the method 'allow'
class Gate:
def allow(self,doc,obj,sub):
return (sub[0:4] == 'Face')
Gui.Selection.addSelectionGate(Gate())
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
Re: Force user to select a special subobject (face, line, vertex)
hi
see Macro_Select_Hovering this macro select a choice Face, Edge, Vertex hovering by the mouse.
mario
see Macro_Select_Hovering this macro select a choice Face, Edge, Vertex hovering by the mouse.
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: Force user to select a special subobject (face, line, vertex)
class SelObserver:
def addSelection(self,document, object, element, position):
try:
if element[0] == "E" or element[0] == "F" or element[0] == "V"
[0] is the first letter.Edge, Face, Vertex,
def addSelection(self,document, object, element, position):
try:
if element[0] == "E" or element[0] == "F" or element[0] == "V"
[0] is the first letter.Edge, Face, Vertex,
Re: Force user to select a special subobject (face, line, vertex)
HI Mario,
I tried your macro but it doesn't seems to work as it should.
I might be wrong but even with selecting one type, I could select the whole object, or something that wasn't chosen in the form.
Have you checked it using .19?
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
-
- Posts: 594
- Joined: Wed Aug 12, 2020 1:24 am
Re: Force user to select a special subobject (face, line, vertex)
In Blender this is called Selection Filters, this should be implemented in FreeCAD out the box
Re: Force user to select a special subobject (face, line, vertex)
In my macros I get the selection/element and then do a "clearSelection, this keeps the main program from doing more highlights like it does with multiple selections of the same face, for instance. Once I'm done with the code I re-select the item. It's kind of a pain but you do get clean selections and single item selections. Also, if someone works on this you can get multiple call-backs to addSelection for one mouse click.
Re: Force user to select a special subobject (face, line, vertex)
Thanks for your input. This is the first time someone else confirm that remove-callback is not working well. If you try my workbench you will see that placing some of the Primitive objects causes problem for FreeCAD, or the callback is still functioning while I remove them.freedman wrote: ↑Mon Feb 22, 2021 6:30 am In my macros I get the selection/element and then do a "clearSelection, this keeps the main program from doing more highlights like it does with multiple selections of the same face, for instance. Once I'm done with the code I re-select the item. It's kind of a pain but you do get clean selections and single item selections. Also, if someone works on this you can get multiple call-backs to addSelection for one mouse click.
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
Re: Force user to select a special subobject (face, line, vertex)
hi
my macro work without click on mouse only fly over (survoler) the arrow on object for select wire, face or vertex (checkBox checked)
mario
my macro work without click on mouse only fly over (survoler) the arrow on object for select wire, face or vertex (checkBox checked)
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.