Generative Design with FreeCAD

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
j8sr0230
Posts: 140
Joined: Thu Apr 07, 2022 8:59 am
Location: Chemnitz
Contact:

Re: Generative Design with FreeCAD

Post by j8sr0230 »

paullee wrote: Tue May 31, 2022 5:18 pm

Code: Select all

solid.Tag = i # Topological naming approach by realthunder
solid.Hasher = App.StringHasher() # Topological naming approach by realthunder
solid.Hasher.Threshold=10 # Topological naming approach by realthunder
These lines looks interesting, any pointer to explain how does it works in Realthunder's branch. I learned from abdullah there is a Tag in Part.geometry e.g. the geometry in Sketcher, which is 'semi-persistent', curious any relevance here? Thanks again ! Too many questions :D
Don't worry, firstly they are good questions and secondly many questions improve the code quality and the own understanding. The following information concerns only Realthunder's FreeCAD version. When I delete the lines of code quoted above, I get the following error message when creating polygon shaped dual mesh elements:

Code: Select all

16:06:39  <ComplexGeoData> GenerativeDesign.py(153)|ComplexGeoData.cpp(1628): unresolved duplicate element mapping 'Vertex1;:G(Vertex2;K-1);FFC Vertex1165/Vertex1153
This warning has already been documented by other power users. Realthunder's statement on this can be found here: https://github.com/looooo/freecad.gears/issues/90.

He said
This 'non fatal' error is due to failure in auto resolving topo name duplicates. The threshold is added because It is potentially expensive to auto resolve as each geometry element produced by each operation needs to have a name whenever possible. The intention is to remind the programmer to insert op code when making shapes to help disambiguation. The log message shows the error is triggered in features.py:1573, but I can't seem to find any code relevant there. Which branch are you using?
The big question now is how to insert the addressed op code to avoid these warnings and accurately name algorithmically generated shapes? I found the answer to this question in Realthunder's excellent asm3-wiki https://github.com/realthunder/asm3-wik ... -Naming.md, where he describes how to correctly name topological shapes according to his approach in order to avoid such errors. The 3 lines of code quoted above can be found in the StringHasher section of the wiki. These lines make the warning message disappear and seem to ensure correct topological naming. I must confess that I have not yet researched further how tag and hasher are used to generate unique names. Do you know anything about this?

By the way, this forum is a great place to keep such links in mind. I had to google a bit again to refind this answer.
Codelink on GitHub: https://github.com/j8sr0230/codelink
Codelink on PiPy: https://pypi.org/project/codelink/
FreeCAD Nodes Workbench on GitHub: https://github.com/j8sr0230/Nodes
paullee
Veteran
Posts: 5097
Joined: Wed May 04, 2016 3:58 pm

Re: Generative Design with FreeCAD

Post by paullee »

j8sr0230 wrote: Sat Jun 04, 2022 2:58 pm The big question now is how to insert the addressed op code to avoid these warnings and accurately name algorithmically generated shapes? I found the answer to this question in Realthunder's excellent asm3-wiki https://github.com/realthunder/asm3-wik ... -Naming.md, where he describes how to correctly name topological shapes according to his approach in order to avoid such errors. The 3 lines of code quoted above can be found in the StringHasher section of the wiki. These lines make the warning message disappear and seem to ensure correct topological naming. I must confess that I have not yet researched further how tag and hasher are used to generate unique names. Do you know anything about this?

By the way, this forum is a great place to keep such links in mind. I had to google a bit again to refind this answer.
Thanks again for the detailed explanation !

I have been trying to read and understand Realthunder's wiki but apparently it is far from my knowledge level :) Anyhow, it is a good start to be aware of such toponaming issue in the context of python coding. In the meantime, the mathematics of your code to generate the shape is good area to study :D

Putting links in the discussion is also good, easier to follow for future re-visit indeed.
User avatar
j8sr0230
Posts: 140
Joined: Thu Apr 07, 2022 8:59 am
Location: Chemnitz
Contact:

Re: Generative Design with FreeCAD

Post by j8sr0230 »

Here's a little preview/update on the Node Editor project: I'm currently working my way through blenderfreak's great tutorial (https://www.youtube.com/watch?v=xbTLhMJ ... TgrKVemZkz) and implementing the editor as a QDockWidget for FreeCAD. The nodes don't have any functions yet, but at least they can be created and moved :) Soon I have to think about how the nodes should interact with the document tree. Maybe I'll do some kind of community survey or something like that...
FreeCAD Node Editor
FreeCAD Node Editor
FreeCAD_NodeEditor.PNG (252.93 KiB) Viewed 2178 times
Codelink on GitHub: https://github.com/j8sr0230/codelink
Codelink on PiPy: https://pypi.org/project/codelink/
FreeCAD Nodes Workbench on GitHub: https://github.com/j8sr0230/Nodes
bleber
Posts: 259
Joined: Thu Jun 30, 2016 5:12 pm

Re: Generative Design with FreeCAD

Post by bleber »

Good job, I expect something to test soon.
paullee
Veteran
Posts: 5097
Joined: Wed May 04, 2016 3:58 pm

Re: Generative Design with FreeCAD

Post by paullee »

Look good really :D
User avatar
j8sr0230
Posts: 140
Joined: Thu Apr 07, 2022 8:59 am
Location: Chemnitz
Contact:

Re: Generative Design with FreeCAD

Post by j8sr0230 »

Hello all together,
I have not been in touch for a while, so here is a small update. Kunda1 made me aware of the new FreeCADAnimation-Workbench (https://github.com/QuentinTournier40/AnimationFreeCAD), which uses PyFlow as NodeEditor. I have had a look at the framework and I think it is very good compared to all the other Qt node editors available. There are a few small bugs here and there, but nothing that can't be fixed as far as I can see. Long story short, I have forked the AnimationFreeCAD Workbench from QuentinTournier40 and will now continue to move my development to the PyFlow framework. At this point I would like to thank the young developers behind the AnimationFreeCAD Workbench and microelly2, without whose preliminary work I would not have been able to familiarize myself with the framework so quickly.
So far, I've fixed PyFlow's "drop on wire" functionality (which is mentioned in the documentation, but doesn't work) and fixed some minor layout issues resulting from the integration within FreeCAD.
In addition, I initialized a new FreeCAD node package and implemented first nodes (but not many yet, see figure). Among other pins, these nodes use a newly introduced ShapePin as a socket to transport geometries through the graph.
Parametric Box
Parametric Box
Parametric_Box.PNG (236.95 KiB) Viewed 1959 times
Currently there are the nodes
  • GetObject
  • MakeBox and
  • SetShape available.
You can find the corresponding GitHub repository here: https://github.com/j8sr0230/AnimationFreeCAD. Next, I want to implement all the nodes I need for my generative design macros DualMesh and DistributeOnFace. Support of any kind is appreciated :D
Codelink on GitHub: https://github.com/j8sr0230/codelink
Codelink on PiPy: https://pypi.org/project/codelink/
FreeCAD Nodes Workbench on GitHub: https://github.com/j8sr0230/Nodes
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Generative Design with FreeCAD

Post by Kunda1 »

Awesome news!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
j8sr0230
Posts: 140
Joined: Thu Apr 07, 2022 8:59 am
Location: Chemnitz
Contact:

Re: Generative Design with FreeCAD

Post by j8sr0230 »

Hi,
I posted a small update to the pyqt-node-editor project including a video in the call for screenshots thread https://forum.freecadweb.org/viewtopic. ... &start=250. I think I will implement my macros step by step as nodes for the pyqt-node-editor and publish them besides my collaboration on the PyFlow fork. It is always good to have a benchmark between different frameworks. You can find my fork of pyqt-node-editor here: https://github.com/j8sr0230/pyqt-node-editor.
Codelink on GitHub: https://github.com/j8sr0230/codelink
Codelink on PiPy: https://pypi.org/project/codelink/
FreeCAD Nodes Workbench on GitHub: https://github.com/j8sr0230/Nodes
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Generative Design with FreeCAD

Post by Kunda1 »

That is amazing!!! and also adding complexity :( since you're tackling on porting pyqt-node-editor instead of pyflow/trails. I guess we're going to have that multiple assembly workbench issue (A2+, A3, A4) with node editors :|
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Meetlat
Posts: 72
Joined: Tue Oct 13, 2020 7:00 am

Re: Generative Design with FreeCAD

Post by Meetlat »

Nice progress, can't wait to try it when I'm back from Holliday.
Post Reply