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 »

Version of today here on GH. ;)
Fixes the "2 clicks to get user value" issue and hopefully the one preventing the widget display when no 3D view is available.
Also add a button (at the bottom) to make all objects visible, but it suffers a bug in the implementation of Part container (its "OutList" property doesn't correctly returns only the top level objects)...
freedman
Veteran
Posts: 3478
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro, Vision1, check it out

Post by freedman »

I commented out; self.move(Gui.getMainWindow().frameGeometry().center()..ect
This way I get the slider on the upper left all the time, I can then dock it only on mon#2, after the dock I can then move it to mon#1. Kind of a pain but at least it shows, I have been messing around with it some.

There is still a bug in your code. If you turn on user and then go into sketcher some things won't work. You can click on items and they won't operate until you go the the slider and turn off user. I wish I could be more specific, it seems kind of a moving target. I would say just try to drawing a few things and constrain, delete stuff, remove constraints and try to do stuff in the combo view.
Hmmm... Not sure to understand the meaning of "skinner" (lack of english vocabulary inside).
That was supposed to be "skinnier", typo... :)

Future stuff and some info:
In case some users don't know:
There is a panel called "selection view", it can be useful. If you mouse select a 3D object, the objects name comes up in the selection panel, right click on the name in the selection panel an pick " Goto selection", it will highlight the object in the tree ( expanding if required) no matter where it is. I would like Vision to do that someday.
I like the "vis" button. If you need to edit something, say inside an engine, you can click on objects and hide them as you work your way down thru the solids. Edit a piston for instance and hit "vis", all back to normal.

I will read up on GIt and figure out what I need to do.

Thanks
Last edited by freedman on Thu Jun 20, 2019 3:03 pm, edited 1 time in total.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: New macro, Vision1, check it out

Post by openBrain »

wmayer wrote: Ping @ Dev master
yorik wrote: Ping @ Python master
Hi guys, sorry to bother. Could one tell if there is in FC observer(s)/callback(s) that can be subscribed to be called in case of following events :
  • A document is opened/closed (or eventually a 3D view is created/destroyed)
  • The current workbench is changed (by user or app)
Thanks.
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: Wed Jun 19, 2019 8:32 am I commented out; self.move(Gui.getMainWindow().frameGeometry().center()..ect
[...]
There is still a bug in your code. If you turn on user and then go into sketcher some things won't work.
[...]
That was supposed to be "skinnier", typo... :)
Basic fix of the 3 above items in today's version. :)
wmayer
Founder
Posts: 20324
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: New macro, Vision1, check it out

Post by wmayer »

A document is opened/closed

Code: Select all

class DocObserver:
  def slotCreatedDocument(self,doc):
    print ("Create document")
  def slotDeletedDocument(self,doc):
    print ("Delete document")
    
obs=DocObserver()
App.addDocumentObserver(obs)
The current workbench is changed (by user or app)

Code: Select all

def wbChange(name):
  print ("Activated workbench: {}".format(name))

mw=Gui.getMainWindow()
mw.workbenchActivated.connect(wbChange)
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: New macro, Vision1, check it out

Post by openBrain »

wmayer wrote: Thu Jun 20, 2019 12:53 pm
Many thanks. ;)
freedman
Veteran
Posts: 3478
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro, Vision1, check it out

Post by freedman »

I tried this, notice the lines commented out:

Code: Select all

    
      if obj.ViewObject.Transparency != 95-self.sliUser.value()*5:
           obj.ViewObject.Transparency = 95-self.sliUser.value()*5
     #      else:
     #         obj.ViewObject.Transparency = 95-self.sliAll.value()*5
     #         Gui.Selection.clearSelection()
    elif self.natState == True:
    self.userToggle()
This removes toggle and just changes the selected object to the user visibility. It works even though it does highlight objects faces, it might be best to structure the program this way because I'm concerned about the comments that other macros don't work correctly, that change would fix that problem. If the user picks on lines instead of faces then highlights seem to be minimal. If the clear selection is removed I believe all the sketcher issues will disappear also :). This also allows the space bar to work and all selections to work as normal.
I just tried my code when clear selection and workbench selecting is removed, works just fine. It might not be as good looking this way but I think it removes future issues.

I noticed; in a multi-sketch part, when a sketch is edited, FreeCAD sets the target sketch to wireframe (to make editing easy) and the other parts are left as solids. With the sketch opened, click on "Vis" and it returns the sketch back to solid. This is very helful when trying to fit solids together.
freedman
Veteran
Posts: 3478
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro, Vision1, check it out

Post by freedman »

openBrain, maybe I didn't understand your intension or something else. Here is a plan, if Vision "User" is only enabled by (Ctl + Shift) then I think everything would work with clearSelection included in the code. If we can exclude sketcher then maybe that's better but I can't see the operator holding (ctl+shift) for long while sketching.
So if the On/Off button turned into a status indicator (and only a status indicator) for (ctl + Shift) and On enables "User", that seems perfect to me and allows toggle to work. I think this would solve a bunch of logic problems. Don't bother reading my prior post if you like this concept.
Do you see some issue with these control keys and other macros?

Thanks for writing the code in; def makeVisible(self, obj):
Using this code has allowed me to change some properties that I couldn't get to prior. :)

I'm just rambling here, I understand that I can make a branch. I want to get thru some basic program logic so I can add my half-a-dozen buttons. :)
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: New macro, Vision1, check it out

Post by openBrain »

Today's version patching issue with Part containers in the "make all visible" function. ;)
freedman wrote: Fri Jun 21, 2019 7:02 am openBrain, maybe I didn't understand your intension or something else.
Hmmm. Actually I got no real intention. Originally I found your idea interesting and useful thus just wanted to push some lines of code in case it may help. :)
Here is a plan, if Vision "User" is only enabled by (Ctl + Shift) then I think everything would work with clearSelection included in the code. If we can exclude sketcher then maybe that's better but I can't see the operator holding (ctl+shift) for long while sketching.
So if the On/Off button turned into a status indicator (and only a status indicator) for (ctl + Shift) and On enables "User", that seems perfect to me and allows toggle to work. I think this would solve a bunch of logic problems. Don't bother reading my prior post if you like this concept.
Do you see some issue with these control keys and other macros?
This plan looks good. ;) Ctrl+shift could be a (small) problem as it can create glitches where the macro "user" setting is enabled with some shortcuts (eg. Ctrl+Shift+Z for redoing). But this should never lead to weird things. Notice that this can be changed to virtually any key combination. I find Ctrl+Shift easy to press, but feel free to change. ;)
Thanks for writing the code in; def makeVisible(self, obj):
Using this code has allowed me to change some properties that I couldn't get to prior. :)
You're welcome (patched code today). What about an addition that will hide all objects but selected ?
I'm just rambling here, I understand that I can make a branch. I want to get thru some basic program logic so I can add my half-a-dozen buttons. :)
:? Not sure to well understand this paragraph. :lol:
freedman
Veteran
Posts: 3478
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro, Vision1, check it out

Post by freedman »

Hmmm. Actually I got no real intention. Originally I found your idea interesting and useful thus just wanted to push some lines of code in case it may help. :)
Got it, cool, and thank you
What about an addition that will hide all objects but selected ?
That works. This allows access to all faces of an object with everything else hidden.

I had another thought, a little complicated: I'll call it "Vhidden". Lets say 6 buttons numbered "OBJ-1 thru OBJ-6") . These buttons link to the names of the last 6 hidden objects (in the current FreeCAD session). Any time later after a button is stored with data, it can be clicked on to set the associated object to visible. Where would this get used: I will use a car as a model example. I have my car visually just the way I want it and I want to modify a piston, I can hide the hood, now that the hood is hidden I can select the head so I hide that also. Now I can select the piston and find it's sketch in the tree with the selection panel. Once I'm finished with the edit I click on buttons 5 and 6 to unhide the head and hood. I don't need to know the names of things to hide and show items, I just click.
I have read other posts where folks want to edit buried items, I think this would make it easy.
Post Reply