pivy: highlevel graphics api
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
pivy: highlevel graphics api
Pivy is a nice tool to create 3d-graphics, interactions, animations.... But there is much time needed to get used to it. I think the python interface of FreeCAD could benefit from a high-level graphics interface. Therefor I have started to transport some basic stuff to pivy. This is at the moment mostly a copy of tools I am using in the glider-workbench.
The tools will be available via from pivy import graphics
If anyone has custom pivy /coin3d code which is useful for others please let me know, or directly add it to pivy.graphics and create a PR. Any ideas are welcome.
First little demonstration of an interaction (highlighting, selecting, dragging): it's this example: https://github.com/looooo/pivy/blob/mas ... raction.py
The tools will be available via from pivy import graphics
If anyone has custom pivy /coin3d code which is useful for others please let me know, or directly add it to pivy.graphics and create a PR. Any ideas are welcome.
First little demonstration of an interaction (highlighting, selecting, dragging): it's this example: https://github.com/looooo/pivy/blob/mas ... raction.py
Re: pivy: highlevel graphics api
FreeCAD user interaction capability options are indeed currently a bit lacking in my opinion. To evolve the user experience further. Luckily things are changing. Although slowly but nonetheless they are.
P.S. Looking at your example i can't help to think about spline (surface).
P.S. Looking at your example i can't help to think about spline (surface).
Re: pivy: highlevel graphics api
Does your code involves changes in the pivy swig code looo? Because otherwise it might be better to be hosted inside freecad than pivy, otherwise it will be a headache to make that reach all the distributions out there, before we can use it in freecad...
Re: pivy: highlevel graphics api
I worked on some swig stuff too, but there were not many changes done. I have never tested this with the official 0.5.0 version of pivy.yorik wrote:Does your code involves changes in the pivy swig code looo?
as it is possible to run the code without freecad, I think it's not a bad idea to have it available via pivy. I will try to update the pip version of pivy to a newer version (0.6.x) if there is some interest in these tools.
Re: pivy: highlevel graphics api
I am guessing if the tools will be made available (more or less made available by default) there is a chance to be used in foreseeable future.
Re: pivy: highlevel graphics api
btw.: everything is available via: https://github.com/FreeCAD/pivy/blob/ma ... _init__.py
you only have to use the pivy-fork available here: https://github.com/FreeCAD/pivy
you only have to use the pivy-fork available here: https://github.com/FreeCAD/pivy
Re: pivy: highlevel graphics api
@yorik can you explain briefly how to use the draft snapper. I would like to use the interaction nodes for the editing-mode of some draft objects.
yorik wrote:
Re: pivy: highlevel graphics api
Sure. There are two ways to use the snapper. This is the simple one:
Code: Select all
def cb(point):
if point:
print "got a 3D point: ",point
FreeCADGui.Snapper.getPoint(callback=cb)
And the more complex one is to use directly FreeCADGui.Snapper.snap() which will simply set the mouse cursor and screen widget if a snapping location was obtained, and return a (snapped) 3D point. You must take care yourself of calling this on each mouse move, update any needed ui control, and call FreeCADGui.Snapper.off() when you are done, to restore the normal mouse cursor and clean the screen widgets.
Re: pivy: highlevel graphics api
Hi looo,
I wanted to play with your graphics api, but I get an error (pivy 0.6.4 installed from FC-daily ppa) :
Code: Select all
>>> from pivy import graphics
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pivy/graphics/__init__.py", line 3, in <module>
from .colors import COLORS
ModuleNotFoundError: No module named 'pivy.graphics.colors'
Re: pivy: highlevel graphics api
sorry for this one. I think it should work with the master-branch. At least it works for me with conda-packages (pivy 0.6.5a0)