New macro, Vision1, check it out

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: New macro, Vision1, check it out

Post by openBrain »

I'll try to add some comments in the code so it could be more easily understood. ;)
freedman
Veteran
Posts: 3476
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro, Vision1, check it out

Post by freedman »

OpenBrain, concerning lock-up. It must be pretty serious because I have to restart my PC to fix the problem after using visionOB just once, restarting FreeCAD isn't enough. If you need I will search up some dockable examples.

Code documentation, it seems readable and well thought out. I can tell you have been writing Python for awhile.

This could turn into a good template for dockable macros.

Thanks
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: New macro, Vision1, check it out

Post by easyw-fc »

freedman wrote: Sun Jun 16, 2019 4:02 pm This could turn into a good template for dockable macros.

Thanks
Hi @freedman
you may have a look at defeaturing wb tools and manipulator wb tools to et some ideas of a dockable tool.
Defeaturing-tabified-tool.gif
Defeaturing-tabified-tool.gif (302.79 KiB) Viewed 1067 times
Manipulator-tabified-tools.gif
Manipulator-tabified-tools.gif (422.82 KiB) Viewed 1067 times
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: New macro, Vision1, check it out

Post by openBrain »

freedman wrote: Sat Jun 15, 2019 8:00 pm Wow! That looks good. I think I saw 2 lines of code that I wrote originally. :lol:
A bit more. :lol: Your idea of clearing selection is clever. I guess it's not ideal as it can disturb other macros that may use the same kind of observer, but I can't find a better way ATM.
I think eventually this will be seen as a standard item for FreeCAD, it helps so much in the change from sketching to viewing.
Yep. Moreover having a native Qt coding may prevent bad interactions as told above. ;)
I see what you mean about the docking issue, mine locks up also.
Attached a patched version. My main oversight was to not call the Selection Observer inherited class initializer. I think that this is what was messing up. Now the new version is stable here.
There are other minor improvements as well. ;)
I will spend much time learning what you coded, thanks for that. I like the sliders also and the ability to adjust to 5%.
Feel free to ask details if needed.
I have seen a design logic issue (from my version and yours), when going to sketcher the "user" on/off status should change to off. This will show the operator the panel is disabled. It could be re-enabled on exiting sketcher.
This isn't implemented in the attached version. ;) It would need an observer or callback on 3D view changes. I don't know if it is possible.
freedman wrote: Sun Jun 16, 2019 4:02 pm OpenBrain, concerning lock-up. It must be pretty serious because I have to restart my PC to fix the problem after using visionOB just once, restarting FreeCAD isn't enough. If you need I will search up some dockable examples.
As told above, seems to be fixed it. Was a chair/keyboard interface issue. :lol:
I can tell you have been writing Python for awhile.
That's very kind but ... not true. :P I had interest in Python as a preferred script language I'd like to learn for years. But actually didn't found any motivating project till a colleague needed some FC macros. Since there I'm constantly amazed of what PySide/Shiboken makes possible alongside with Python (and FreeCAD core). ;) But to be complete, I have decent experience with other languages such as C, C++ (with Qt), PHP and others that very probably smooth the learning curve. :lol:
This could turn into a good template for dockable macros.
Why not. This is not a big piece of code thus can be used as demonstration. ;)

Feel free to try, criticize & patch. :)
Attachments
VisionOB.FCMacro
(5.61 KiB) Downloaded 38 times
freedman
Veteran
Posts: 3476
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro, Vision1, check it out

Post by freedman »

Looking good.
Last edited by freedman on Mon Jun 17, 2019 9:33 pm, edited 1 time in total.
freedman
Veteran
Posts: 3476
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro, Vision1, check it out

Post by freedman »

I wrote there was a bug but I can't recreate, deleting the post.

I can see a few added features, at least in my future, not sure if you want to discuss more;

1)A button on/off that will enable setting all to 5% when entering sketcher. On exiting sketcher, leave at 5%, it would too hard to reset every object, besides there is a slider for that. :) Not sure if there is a signal for wokbench change.

2)A button that turns on all objects. Often a user will turn objects off( space bar) to look around and then gets stuck because currently there is no way to turn them back on without searching thru the entire tree to find them.

And maybe later for FreeCAD....An addition to the tree, a "turned off" object list so they could be clicked on to return to view.

I have some other thoughts but I will mock them up with my code or yours.

I think you did a great job, thanks it really looks good. :)

The only addition with what is there currently to improve on it would be to make it skinner. Sometimes not easy in windows.
freedman
Veteran
Posts: 3476
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro, Vision1, check it out

Post by freedman »

I think I found something else. If I start the macro before a model is opened I get a message "no file open". If I then open a file and once again try to run the macro I get a message " already running" and no slider shown. And probably connected...
After a fresh win7 start, start FreeCAD, open file, start macro and nothing appears. Both of these tests were on my dual monitor system, looked all over, nothing. It works on my single screen laptop just fine. Hmm.
freedman
Veteran
Posts: 3476
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro, Vision1, check it out

Post by freedman »

I still have problems running the new version on my dual monitor system. I'll work on Nvidia manager and see what it will do. The slider comes up if FreeCAD is run on mon.#1 but if I run the app on mon.#2 the slider is nowhere to be found. It's not in the window list.

The sliders; I noticed a slight difference using the slider vs my buttons. Move the slider to a new position and select an object, the object changes to the all value first and then the user. Using my buttons the user value is enable first. Not a big deal but it takes 2 clicks. I see this occur on a reselect of the same object.

I see a possible feature on the current version; With user ON, what about adding if an object was selected and the slider is moved the visibility changes to that immediately. The object selection name/handle would need to be stored from the previous selection.

Thanks
freedman
Veteran
Posts: 3476
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro, Vision1, check it out

Post by freedman »

There is something going on in sketcher in visionOB. When I coded Vision1 I noticed that in sketcher there was an issue with selection. That's why I keyed on the only in "part design,part,arch" For some reason when asking what workbench is current, sketcher workbench looses focus sometimes, like during a double click. Using visionOB in sketcher, I could not select a dimension and delete, it would not turn green.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: New macro, Vision1, check it out

Post by openBrain »

freedman wrote: Mon Jun 17, 2019 9:32 pm I can see a few added features, at least in my future, not sure if you want to discuss more;
Yes I am. My spare time is never guaranteed, but as code is shared anybody may improve it. ;)
1)A button on/off that will enable setting all to 5% when entering sketcher. On exiting sketcher, leave at 5%, it would too hard to reset every object, besides there is a slider for that. :)
I'm not sure I would use such a feature, but this seems doable.
2)A button that turns on all objects. Often a user will turn objects off( space bar) to look around and then gets stuck because currently there is no way to turn them back on without searching thru the entire tree to find them.
More useful to me than the previous one, and also seems doable. :)
I have some other thoughts but I will mock them up with my code or yours.
Great. Would that help if I set up something on GitHub so we can branch ?
I think you did a great job, thanks it really looks good. :)
Thanks. Though no pretentiousness that my macro is fine-tuned and polished. ;) Just to show what I was thinking about so I'm not just a criticizer. :lol:
The only addition with what is there currently to improve on it would be to make it skinner. Sometimes not easy in windows.
Hmmm... Not sure to understand the meaning of "skinner" (lack of english vocabulary inside). :D
freedman wrote: Mon Jun 17, 2019 10:32 pm I think I found something else. If I start the macro before a model is opened I get a message "no file open".
This is because if no model is opened, no 3DInventor view exists. But the keyboard event callback needs it, thus the macro just tell that keyboard shortcuts won't work. ;) To be improved, it would need still another observer/callback about document opening/closing or Inventor view creation/destruction. Don't know if exist.
If I then open a file and once again try to run the macro I get a message " already running" and no slider shown. And probably connected...
After a fresh win7 start, start FreeCAD, open file, start macro and nothing appears. Both of these tests were on my dual monitor system, looked all over, nothing. It works on my single screen laptop just fine. Hmm.
This is because I lock the widget to only one instance possible (I was feared of possible side effects if several are open :P ). Maybe the first instance doesn't show correctly because of the exception (on Windows). Possible to replace the show() call by raise(), perhaps it will improve. ;)
freedman wrote: Tue Jun 18, 2019 12:31 am I still have problems running the new version on my dual monitor system. I'll work on Nvidia manager and see what it will do. The slider comes up if FreeCAD is run on mon.#1 but if I run the app on mon.#2 the slider is nowhere to be found. It's not in the window list.
Probably one of the numerous possible improvements. :)
The sliders; I noticed a slight difference using the slider vs my buttons. Move the slider to a new position and select an object, the object changes to the all value first and then the user. Using my buttons the user value is enable first. Not a big deal but it takes 2 clicks. I see this occur on a reselect of the same object.
This is indeed the behavior I coded. Not a big deal to change it. ;)
I see a possible feature on the current version; With user ON, what about adding if an object was selected and the slider is moved the visibility changes to that immediately. The object selection name/handle would need to be stored from the previous selection.
Don't think storing something is needed. Just live read the Gui.Selection and apply. ;)
freedman wrote: Tue Jun 18, 2019 6:28 am There is something going on in sketcher in visionOB. When I coded Vision1 I noticed that in sketcher there was an issue with selection. That's why I keyed on the only in "part design,part,arch" For some reason when asking what workbench is current, sketcher workbench looses focus sometimes, like during a double click. Using visionOB in sketcher, I could not select a dimension and delete, it would not turn green.
I saw that you limited the workbenches where macro works, but didn't yet push this feature in the code. ;)
Post Reply