New macro, Vision1, check it out
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: New macro, Vision1, check it out
I'll try to add some comments in the code so it could be more easily understood.
Re: New macro, Vision1, check it out
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
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
Re: New macro, Vision1, check it out
A bit more. 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.
Yep. Moreover having a native Qt coding may prevent bad interactions as told above.I think eventually this will be seen as a standard item for FreeCAD, it helps so much in the change from sketching to viewing.
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.I see what you mean about the docking issue, mine locks up also.
There are other minor improvements as well.
Feel free to ask details if needed.I will spend much time learning what you coded, thanks for that. I like the sliders also and the ability to adjust to 5%.
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.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.
As told above, seems to be fixed it. Was a chair/keyboard interface issue.
That's very kind but ... not true. 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.I can tell you have been writing Python for awhile.
Why not. This is not a big piece of code thus can be used as demonstration.This could turn into a good template for dockable macros.
Feel free to try, criticize & patch.
- Attachments
-
- VisionOB.FCMacro
- (5.61 KiB) Downloaded 38 times
Re: New macro, Vision1, check it out
Looking good.
Last edited by freedman on Mon Jun 17, 2019 9:33 pm, edited 1 time in total.
Re: New macro, Vision1, check it out
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.
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.
Re: New macro, Vision1, check it out
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.
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.
Re: New macro, Vision1, check it out
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
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
Re: New macro, Vision1, check it out
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.
Re: New macro, Vision1, check it out
Yes I am. My spare time is never guaranteed, but as code is shared anybody may improve it.
I'm not sure I would use such a feature, but this seems doable.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.
More useful to me than the previous one, and also 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.
Great. Would that help if I set up something on GitHub so we can branch ?I have some other thoughts but I will mock them up with my code or yours.
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.I think you did a great job, thanks it really looks good.
Hmmm... Not sure to understand the meaning of "skinner" (lack of english vocabulary inside).The only addition with what is there currently to improve on it would be to make it skinner. Sometimes not easy in windows.
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.
This is because I lock the widget to only one instance possible (I was feared of possible side effects if several are open ). 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.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.
Probably one of the numerous possible improvements.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.
This is indeed the behavior I coded. Not a big deal to change it.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.
Don't think storing something is needed. Just live read the Gui.Selection and apply.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.
I saw that you limited the workbenches where macro works, but didn't yet push this feature in the code.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.