Solution for one instance of the Topological Naming Problem

Discussions about the wiki documentation of FreeCAD and its translation.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
dprojects
Posts: 721
Joined: Mon Mar 06, 2017 6:02 pm
Location: Poland
Contact:

Re: Topological Naming, My Take

Post by dprojects »

Just to let you know the page: https://wiki.freecadweb.org/TNP_solution has been little redesigned. There is also new section:


This code above shows how to solve the example from Topological Naming Problem described at: Topological Naming Problem but exactly the same rules you can use to solve other problems. The approach is simple:

Store the key before any operation
Search for the key after operation

The specific implementation may be different. In this example the plane is XY, but you can do exactly the same for other axes. Also you can choose other key. At Woodworking project I make many operations at non-existing objects, so I had to solve the Topological Naming Problem many times.

Here I change Cube objects into PartDesign Thickness objects:

Image

At this example below I change Cubes into PartDesign Chamfers, so I had to store key for edges:

Image

This example below is little more complicated because as you see at the GUI screen, the references to the object and face changes automatically. But also to make a hole I call function defined in my library not directly in the tool. So, I had to use small trick with selection and deselection, to get new reference:

Image

There are many such problems when programming in FreeCAD, but they can all be solved in a similar way. I hope, it helps.

Thanks
Darek
github.com/dprojects

workbench for woodworking is available at: github.com/dprojects/Woodworking
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Topological Naming, My Take

Post by Zolko »

adrianinsaval wrote: Tue Aug 16, 2022 8:03 pm
The worry I'd have with the second approach is how well it behaves for very complex models with lots of history, including booleans, copies, clones, shapebinders ...
what exactly are your worries?
stability and maintainability. FreeCAD was very buggy before v0.17 or 0.18, it crashed all the time for no apparent reason. It became very stable since v0.19, and has been very stable in v0.20 and 0.21. Bringing in a load of changes, that only a single person understands, to the core of FreeCAD could jeopardize this excellent state.
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Topological Naming, My Take

Post by adrianinsaval »

Zolko wrote: Wed Aug 17, 2022 2:04 pm stability and maintainability. FreeCAD was very buggy before v0.17 or 0.18, it crashed all the time for no apparent reason. It became very stable since v0.19, and has been very stable in v0.20 and 0.21. Bringing in a load of changes, that only a single person understands, to the core of FreeCAD could jeopardize this excellent state.
Ok but that's a general worry not much to do with model complexity, could be easier to spot or more serious for more complex models but that's true for everything. I can't remember if there where crash reports related to toponaming algorithm, realthunder's code has undergone massive testing over the years and it's probably still going to be a good amount of testing of the PR itself before merge, or at least that was the stated plan.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Topological Naming, My Take

Post by adrianinsaval »

dprojects wrote: Wed Aug 17, 2022 11:27 am Just to let you know the page: https://wiki.freecadweb.org/TNP_solution has been little redesigned.
The wiki page is a place for documenting FreeCAD not a blog, I do not like this page. It's content is better suited to a dedicated forum post where you can share all your ideas. Your "solution" is very limited so IMO the wording is very misleading. Can we split this conversation into a post in the wiki subforum? I would like to hear the opinions of the people working on the wiki.

As a side note, why are you creating part containers with a single body inside them? It is redundant, putting a body inside a Part container only makes sense if it's going to be along side other objects. What you are doing in your workbench is also very unusual and not exactly what people usually understand when talking about TNP, why make a Part object only to them remove it and replace with a PD object? Why not make a PD box then just apply a thickness to that box instead.
The TNP that you are "solving" consist of recreating the exact same shape with another tool, this is trivial, just compare the old with the new and find a match. This is not equivalent to the normal circumstances where one finds the TNP.
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: Topological Naming, My Take

Post by chrisb »

adrianinsaval wrote: Wed Aug 17, 2022 2:45 pm The wiki page is a place for documenting FreeCAD not a blog, I do not like this page. It's content is better suited to a dedicated forum post where you can share all your ideas. Your "solution" is very limited so IMO the wording is very misleading.
+1
I have split the topic.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
user1234
Veteran
Posts: 3333
Joined: Mon Jul 11, 2016 5:08 pm

Re: Topological Naming, My Take

Post by user1234 »

adrianinsaval wrote: Wed Aug 17, 2022 2:45 pm The wiki page is a place for documenting FreeCAD not a blog, I do not like this page.
+1

Greetings
user1234
Post Reply