Force user to select a special subobject (face, line, vertex)

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
openBrain
Posts: 5477
Joined: Fri Nov 09, 2018 5:38 pm

Re: Force user to select a special subobject (face, line, vertex)

Postby openBrain » Mon Feb 22, 2021 11:52 am

marja1 wrote:
Sun Feb 21, 2021 8:25 pm
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())
Yes, this is the right function. Unfortunately I didn't find it to be extensively documented. ;)
freedman
Posts: 1790
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Force user to select a special subobject (face, line, vertex)

Postby freedman » Mon Feb 22, 2021 6:13 pm

marja1 wrote
This is the first time someone else confirm that remove-callback is not working well.
There could be a strategy behind addSelection to give feedback info in the call-back, even giving multiples. It is a little difficult to deal with in a macro. I found that if you print the call-back info the print routine takes so long that it only sees one call-back. If you write code it runs faster and you can receive two. I didn't analyze all the data but I believe that in those two call-backs the data is actually different, like maybe one is from the screen info and the other has tree info. I also found that if you select something in the tree you could get two call-backs, if you select the next tree item, you get one, go to the next, you get two. I finally gave up and took the first call-back and locked out receiving any others for awhile with a timer. I had plans to start a post in the "Macro" section, it could use a write-up.
User avatar
marja1
Posts: 80
Joined: Wed Jan 06, 2021 2:00 pm

Re: Force user to select a special subobject (face, line, vertex)

Postby marja1 » Tue Feb 23, 2021 8:23 am

[/quote]
Yes, this is the right function. Unfortunately I didn't find it to be extensively documented. ;)
[/quote]

OpenBrain.
I don't know if you are one of the Core Developer. I made the implementation. Two things I don't like in this implementation.
1-Warning sound generates if you select the undesired object. I would like to stop it.
2-Have it as toolbar not in the 3d View screen.

I really wish and want to have the buttons inside the 3D view. As you know for me it is a black box how you do that. If you know please let me know.
And this functionality is essential to have in FreeCAD so I hope it will be added to the core.
Please clone the WB to use it and test it .. You will see 4 icons with clear view what they are doing.
openBrain
Posts: 5477
Joined: Fri Nov 09, 2018 5:38 pm

Re: Force user to select a special subobject (face, line, vertex)

Postby openBrain » Tue Feb 23, 2021 9:04 am

marja1 wrote:
Tue Feb 23, 2021 8:23 am
I don't know if you are one of the Core Developer.
I'm not.

1-Warning sound generates if you select the undesired object. I would like to stop it.

Actually I never used a SelectionGate. Will try to have a look.

2-Have it as toolbar not in the 3d View screen.

I really wish and want to have the buttons inside the 3D view. As you know for me it is a black box how you do that. If you know please let me know.

I didn't get this point. Could you explain a bit more?

And this functionality is essential to have in FreeCAD so I hope it will be added to the core.

There is a global discussion (and a feature request) about improving selection ability.

Please clone the WB to use it and test it .. You will see 4 icons with clear view what they are doing.
Too busy ATM. Eventually will do later.
User avatar
marja1
Posts: 80
Joined: Wed Jan 06, 2021 2:00 pm

Re: Force user to select a special subobject (face, line, vertex)

Postby marja1 » Tue Feb 23, 2021 10:11 am

I meant that selections options (Body, Face ..etc) should be already in FreeCAD .. Without WB like the box in the right corner.
User avatar
Zolko
Posts: 1218
Joined: Mon Dec 17, 2018 10:02 am

Re: Force user to select a special subobject (face, line, vertex)

Postby Zolko » Thu Feb 25, 2021 10:43 am

marja1 wrote:
Tue Feb 23, 2021 10:11 am
I meant that selections options (Body, Face ..etc) should be already in FreeCAD .. Without WB like the box in the right corner.
I agree with you, and the same is true for a good measuring tool.

But in the mean time, I used your finding (about the selectionGate) and implemented a selection filter in the Assembly4 WB (in the development branch for now). You can find the code here: https://github.com/Zolko-123/FreeCAD_As ... nFilter.py. It's a separate toolbar, and there is some extra code that is not selectionGate() to select entire solids and even linked objects (which the selectionGate() doesn't handle I think). The selection buttons are toggled-able, which is the better behaviour I think, see https://forum.freecadweb.org/viewtopic. ... 31#p481531

Please feel free to test, comment, improve, fork ...

selectionFilter.PNG
selectionFilter.PNG (243.54 KiB) Viewed 131 times
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
User avatar
marja1
Posts: 80
Joined: Wed Jan 06, 2021 2:00 pm

Re: Force user to select a special subobject (face, line, vertex)

Postby marja1 » Thu Feb 25, 2021 11:58 am

Zolko wrote:
Thu Feb 25, 2021 10:43 am
marja1 wrote:
Tue Feb 23, 2021 10:11 am
I meant that selections options (Body, Face ..etc) should be already in FreeCAD .. Without WB like the box in the right corner.
I agree with you, and the same is true for a good measuring tool.

But in the mean time, I used your finding (about the selectionGate) and implemented a selection filter in the Assembly4 WB (in the development branch for now). You can find the code here: https://github.com/Zolko-123/FreeCAD_As ... nFilter.py. It's a separate toolbar, and there is some extra code that is not selectionGate() to select entire solids and even linked objects (which the selectionGate() doesn't handle I think). The selection buttons are toggled-able, which is the better behaviour I think, see https://forum.freecadweb.org/viewtopic. ... 31#p481531

Please feel free to test, comment, improve, fork ...


selectionFilter.PNG
For sure I will use, test it.
EDIT: I cannot see the buttons. I updated the WB using the Manager.. Should I clone your github?
But, it comes to my mind to ask you something else.. Would you like to combine both WB in one? My aim in doing Design456 is to collect best of all tools which make life easier for Maker and FC user. So we make it bigger project and more rich in tools.?
If you wish that .. Please consider give me the proposal of joining both. How would you like to do that? I can do it like I did for Draft.. Not chaining anything than the WB loader. By that we keep (today's progress for your github) and fork it in my branch .. and after that I will modify what I need to modify to make it suitable for Desgin456 ..
Please let me know what you think?
Many of the functionality we have in Part or Draft are not user-friendly .. My goal is to add new tools, make old tools easier to use ..etc
And assembly is of the essentials tools that you should have it in Design456.
I really wish to keep the name of the WB I made as my intention is to give a hidden indication that this WB is aimed to be easy as 123D design.
Attachments
assembly.JPG
assembly.JPG (36.85 KiB) Viewed 93 times
User avatar
Zolko
Posts: 1218
Joined: Mon Dec 17, 2018 10:02 am

Re: Force user to select a special subobject (face, line, vertex)

Postby Zolko » Thu Feb 25, 2021 1:08 pm

marja1 wrote:
Thu Feb 25, 2021 11:58 am
Would you like to combine both WB in one ?
You are free to copy/clone the Assembly4 WB, but for the time being I'll update my repository independently, there are still many improvements/fixes to be made.
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
User avatar
Zolko
Posts: 1218
Joined: Mon Dec 17, 2018 10:02 am

Re: Force user to select a special subobject (face, line, vertex)

Postby Zolko » Thu Feb 25, 2021 1:10 pm

marja1 wrote:
Thu Feb 25, 2021 11:58 am
Zolko wrote:
Thu Feb 25, 2021 10:43 am
But in the mean time, I used your finding (about the selectionGate) and implemented a selection filter in the Assembly4 WB (in the development branch for now). You can find the code here: https://github.com/Zolko-123/FreeCAD_As ... nFilter.py
EDIT: I cannot see the buttons. I updated the WB using the Manager.. Should I clone your github?
no, since it's the development branch you have to download that (https://github.com/Zolko-123/FreeCAD_As ... evelopment) and install it manually into your Addons folder.
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
jtm2020hyo
Posts: 381
Joined: Wed Aug 12, 2020 1:24 am

Re: Force user to select a special subobject (face, line, vertex)

Postby jtm2020hyo » Thu Feb 25, 2021 5:28 pm

+1
Please devs, add this feature to default FreeCAD