node editor - pyflow

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!
User avatar
victor_calixto
Posts: 2
Joined: Thu Aug 21, 2014 12:15 am

Re: node editor - pyflow

Postby victor_calixto » Fri Jan 17, 2020 11:37 am

First of all, many thanks for started to develop this project @microelly2. It is amazing!! :D.
I have been using Grasshopper and Rhino from the last 10 years and when I saw this project I felt that I need to collaborate somehow with that.
So, I had some problems when I tried to install here, but I already fixed them, but I still have some problems with some components.

My configuration;
OS: Manjaro Linux (XFCE/xfce)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19274 (Git) AppImage
Build type: Release
Branch: master
Hash: 1da11e4e5c760e0db7b8e0d9a80ca5a8c172b326
Python version: 3.8.1
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.4.0
Locale: English/Australia (en_AU)


The first problem was the same that @pablogil noticed, then I installed all libraries and set the python "site-packages" manually as described by @pablogil, many thanks @pablogil.

quote=pablogil post_id=360718 time=1579114003 user_id=4517]
Well,

I have done some progressions trying to get it to install:
  • I had to manually install missing python modules (at least here in macOS):
    • blinker: pip install blinker
    • numpy: pip install numpy
    • docutils: pip install docutils
    • nine: pip install nine)
  • then I had to manually find the path to the python "site-packages" path: python -m site
  • copy the path, open the workbench "InitGui.py" and after line 38 add a new line with the copied path: sys.path.append('path_here')
  • close FreeCAD and open it again
This way I could open the PyFlow workbench and start "playing". :D

If I follow your README.md, you ask run the Script "create all Nodes for Test" from Menu tests, but it partially fails:

Code: Select all

---------get FreeCADPyFlow------------------- getInstance @ ...ablo/Library/Preferences/FreeCAD/Mod/NodeEditor/nodeeditor/pfwrap.py li: 46
<nodeeditor.freecad_pyflowapp.FreeCADPyFlow object at 0x1353510c8>
create instance getInstance @ ...ablo/Library/Preferences/FreeCAD/Mod/NodeEditor/nodeeditor/pfwrap.py li: 72
Running the Python command 'Micro_createAllNodesforTests' failed:
Traceback (most recent call last):
  File "<string>", line 195, in Activated
  File "<string>", line 1, in <module>
  File "/Users/pablo/Library/Preferences/FreeCAD/Mod/NodeEditor/nodeeditor/Commands.py", line 1198, in createAllNodesforTests
    from PyFlow.Packages.PyFlowFreeCAD.Nodes.FreeCAD_Logic import nodelist

No module named 'PyFlow.Packages.PyFlowFreeCAD'
pyflow.png

Now I'm going to play around if I can do something else but it would be nice if you guide me a little, hehehe.

Thanks
However, I have had another problem because of the python 3.8 version, in which the method time.clock() does not work anymore.
So, I changed all time.clock() in the python scripts in NodeEditor and Pyflow folders to other time method called as described here:

https://github.com/PyTables/PyTables/issues/744
https://www.webucator.com/blog/2015/08/ ... explained/

So, the NodeEditor started work after that, but I had problems with the FreeCad dragger component when I tried to execute the command to start it while I was following @microelly2's introduction tutorial. Anyway, the other components look work properly.

Code: Select all

  
[bug]  
  File "/home/klixto/.FreeCAD/Mod/PyFlow/PyFlow/Packages/PyFlowBase/Pins/ExecPin.py", line 69, in call
    super(ExecPin, self).call(*args, **kwargs)
  File "/home/klixto/.FreeCAD/Mod/PyFlow/PyFlow/Core/PinBase.py", line 608, in call
    self.onExecute.send(*args, **kwargs)
  File "/home/klixto/anaconda3/lib/python3.7/site-packages/blinker/base.py", line 266, in send
    return [(receiver, receiver(sender, **kwargs))
  File "/home/klixto/anaconda3/lib/python3.7/site-packages/blinker/base.py", line 266, in <listcomp>
    return [(receiver, receiver(sender, **kwargs))
  File "/home/klixto/.FreeCAD/Mod/NodeEditor/PyFlowPackages/PyFlowFreeCAD/Nodes/FreeCAD_Coin.py", line 114, in start
    import nodeeditor.dev
  File "/home/klixto/.FreeCAD/Mod/NodeEditor/nodeeditor/dev.py", line 6, in <module>
    import matplotlib.pyplot as plt
  File "/tmp/.mount_freecauGzJuK/usr/lib/python3.8/site-packages/matplotlib/pyplot.py", line 2349, in <module>
    switch_backend(rcParams["backend"])
  File "/tmp/.mount_freecauGzJuK/usr/lib/python3.8/site-packages/matplotlib/__init__.py", line 833, in __getitem__
    plt.switch_backend(rcsetup._auto_backend_sentinel)
  File "/tmp/.mount_freecauGzJuK/usr/lib/python3.8/site-packages/matplotlib/pyplot.py", line 213, in switch_backend
    switch_backend("agg")
  File "/tmp/.mount_freecauGzJuK/usr/lib/python3.8/site-packages/matplotlib/pyplot.py", line 221, in switch_backend
    backend_mod = importlib.import_module(backend_name)
  File "/tmp/.mount_freecauGzJuK/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/tmp/.mount_freecauGzJuK/usr/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 45, in <module>
    from PIL import Image
  File "/home/klixto/anaconda3/lib/python3.7/site-packages/PIL/Image.py", line 90, in <module>
    from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (/home/klixto/anaconda3/lib/python3.7/site-packages/PIL/__init__.py)
[/bug]
pyflox-teste.png
pyflox-teste.png (178.36 KiB) Viewed 587 times
pyflox-teste2.png
pyflox-teste2.png (237.7 KiB) Viewed 587 times
Many thanks again.

Cheers
Last edited by Kunda1 on Fri Jan 17, 2020 11:53 am, edited 2 times in total.
Reason: fixed incorrect usage of [quote] bbcode
User avatar
microelly2
Posts: 4627
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: node editor - pyflow

Postby microelly2 » Fri Jan 17, 2020 2:53 pm

victor_calixto wrote:
Fri Jan 17, 2020 11:37 am

However, I have had another problem because of the python 3.8 version, in which the method time.clock() does not work anymore.
So, I changed all time.clock() in the python scripts in NodeEditor and Pyflow folders to other time method called as described here:

https://github.com/PyTables/PyTables/issues/744
https://www.webucator.com/blog/2015/08/ ... explained/

So, the NodeEditor started work after that, but I had problems with the FreeCad dragger component when I tried to execute the command to start it while I was following @microelly2's introduction tutorial. Anyway, the other components look work properly.
https://github.com/wonderworks-software ... /issues/79
if your workaround works you may share your work with us please.
User avatar
victor_calixto
Posts: 2
Joined: Thu Aug 21, 2014 12:15 am

Re: node editor - pyflow

Postby victor_calixto » Fri Jan 17, 2020 11:14 pm

microelly2 wrote:
Fri Jan 17, 2020 2:53 pm
victor_calixto wrote:
Fri Jan 17, 2020 11:37 am

However, I have had another problem because of the python 3.8 version, in which the method time.clock() does not work anymore.
So, I changed all time.clock() in the python scripts in NodeEditor and Pyflow folders to other time method called as described here:

https://github.com/PyTables/PyTables/issues/744
https://www.webucator.com/blog/2015/08/ ... explained/

So, the NodeEditor started work after that, but I had problems with the FreeCad dragger component when I tried to execute the command to start it while I was following @microelly2's introduction tutorial. Anyway, the other components look work properly.
https://github.com/wonderworks-software ... /issues/79
if your workaround works you may share your work with us please.
Sure, I made some changes in ' ~/.FreeCAD/Mod/NodeEditor/nodeeditor/Dev.py ' and ' ~/.FreeCAD/Mod/PyFlow/PyFlow/App.py '...changing all 'from time import clock' to 'import time' and replacing all instances of 'clock()' to 'time.perf_counter()' .

I have attached here my InitGui.py, and Dev.py from NodeEditor and App.py from Pyflow that I have changed.

Cheers
Attachments
InitGui.py
(13.33 KiB) Downloaded 12 times
App.py
(26.54 KiB) Downloaded 9 times
dev.py
(139.27 KiB) Downloaded 11 times
User avatar
microelly2
Posts: 4627
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: node editor - pyflow

Postby microelly2 » Tue Jan 21, 2020 7:54 pm

phpBB [video]


This is an example of the task:
How can a get from a set of points which describe a curve with a lot of noise a simple curve with s small number of poles.
redraw the curve by hand may work but my idea was to simplify only some area of the generated curve. This may be sometimes faster than repaint the whole picture by hand. The whole flow can become parametric because the configurations between the commits can be stored as a history track.
the method is segment based that means that the interaction creates from a large chain of segments a chain with only 4 segments configured by only one point/pole. the other segments of the curve are preserved.
User avatar
microelly2
Posts: 4627
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: node editor - pyflow

Postby microelly2 » Wed Jan 22, 2020 2:39 pm

I added two features to the reduce curve node:
reduce segments to a shortest curve
reduce and fit a point
phpBB [video]

documentation is here
http://freecadbuch.de/doku.php?id=pyflo ... educecurve
User avatar
microelly2
Posts: 4627
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: node editor - pyflow

Postby microelly2 » Thu Jan 23, 2020 5:44 pm

phpBB [video]

this video demonstrates the if else node to switch between computation pathes/models
and the loft node implementation with pyflow..
it's a good example to see how faster grid presentation of a face than the face model.
User avatar
microelly2
Posts: 4627
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: node editor - pyflow

Postby microelly2 » Sat Jan 25, 2020 5:39 pm

phpBB [video]

I made a function pin which can be used to send functions to nodes. this makes sense when I work with scipy.
User avatar
Pauvres_honteux
Posts: 262
Joined: Sun Feb 16, 2014 12:05 am
Location: Far side of the moon

Re: node editor - pyflow

Postby Pauvres_honteux » Sun Jan 26, 2020 1:07 pm

Hi Thomas, really excellent work there!

I hope it will not be too far away in the future when we mere mortals can use it as well?

Reduce curve - this we do use quite frequently at work, while designing reflect curves for castings, but with a twist. In our CAD-program there's a integrated function to force the resulting curve to be on/connected to the surface/face in question. For this reason I'd like to propose to implement that very function (curve on surface/face) into "Reduce curve".

Loft and B-spline surface/face - just in case it is not on your To-Do-list I put a little reminder here about the super critical function "tangent to counter surface" connected to the same line/curve as the B-spline surface/face. Put it another way, the curve/line rule both surfaces simultaneously. I really hope this surface creator will be able to take any curve/line as an argument?
User avatar
microelly2
Posts: 4627
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: node editor - pyflow

Postby microelly2 » Tue Jan 28, 2020 5:38 pm

demo how to define tangents and border points of a surface
the dragger node can process direction soon.
phpBB [video]
User avatar
Ilgar
Posts: 1
Joined: Wed Jan 29, 2020 10:11 am

Re: node editor - pyflow

Postby Ilgar » Wed Jan 29, 2020 10:18 am

Hi folks!!! I'm amazed of all this features you developed!! :shock: Thank you microelly2!!! I'll be watching here)