Editing sketch used as source by "link to external geometry"
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Editing sketch used as source by "link to external geometry"
Hi,
I'm trying to find a workflow to do the following :
1) create a sketch that will serve as a skeleton for the rest of the part modeling, containing major dimensions
2) then create more sketches for each shape (pad, revolution, etc.), that use the first sketch as reference, with the "Create an edge linked to external geometry" tool
3) edit the first sketch, for example removing a line (I mean one that is not referenced by other sketches) without breaking everything
It seems the references are stored by index, like "Edge3 of Sketch001". Then if I delete Edge2, it will shift all the following edges ; Edge3 will become Edge2, and Edge4 will become Edge3. So now my sketches are referencing the wrong edge.
I've found a few discussions about the issue, for example here: https://forum.freecadweb.org/viewtopic.php?t=17319
Is there a solution to that problem? Or is it a dead end (until someone fixes that behavior) and I should work differently?
I'm trying to find a workflow to do the following :
1) create a sketch that will serve as a skeleton for the rest of the part modeling, containing major dimensions
2) then create more sketches for each shape (pad, revolution, etc.), that use the first sketch as reference, with the "Create an edge linked to external geometry" tool
3) edit the first sketch, for example removing a line (I mean one that is not referenced by other sketches) without breaking everything
It seems the references are stored by index, like "Edge3 of Sketch001". Then if I delete Edge2, it will shift all the following edges ; Edge3 will become Edge2, and Edge4 will become Edge3. So now my sketches are referencing the wrong edge.
I've found a few discussions about the issue, for example here: https://forum.freecadweb.org/viewtopic.php?t=17319
Is there a solution to that problem? Or is it a dead end (until someone fixes that behavior) and I should work differently?
Re: Editing sketch used as source by "link to external geometry"
There is nothing what you could have done better - except making up your mind earlier.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Editing sketch used as source by "link to external geometry"
OK, thanks for the answer.
Don't know if this is the right place to talk about this, but looking quickly at the code, in method SketchObject::addExternal, the external is indeed stored as a string, such as "Edge3" (along with a pointer to the referenced DocumentObject, another sketch in my case). Actually, this would be fine if sub-elements were never renamed. Deleting "Edge2" should keep "Edge3" as-is, not renaming it "Edge2" to fill the gap. An alternative would be to assign a persistent ID (for example a random GUID) to each sub-element that can be linked to. I'll see if I have some time to dig into this (but I have not much knowledge about the internals of freecad, so I don't know if I'll have time and motivation to come up with a fix that would be worth sharing).
Don't know if this is the right place to talk about this, but looking quickly at the code, in method SketchObject::addExternal, the external is indeed stored as a string, such as "Edge3" (along with a pointer to the referenced DocumentObject, another sketch in my case). Actually, this would be fine if sub-elements were never renamed. Deleting "Edge2" should keep "Edge3" as-is, not renaming it "Edge2" to fill the gap. An alternative would be to assign a persistent ID (for example a random GUID) to each sub-element that can be linked to. I'll see if I have some time to dig into this (but I have not much knowledge about the internals of freecad, so I don't know if I'll have time and motivation to come up with a fix that would be worth sharing).
Re: Editing sketch used as source by "link to external geometry"
Good to see someone who wants to help coding. Abdullah is probably the right person to give additional information
Abdullah wrote:ping
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Editing sketch used as source by "link to external geometry"
Another discussion that may be relevant.
https://forum.freecadweb.org/viewtopic.php?f=22&t=28575
BTW, not sure about status of Realthundar's branch …
https://forum.freecadweb.org/viewtopic.php?f=22&t=28575
BTW, not sure about status of Realthundar's branch …
Re: Editing sketch used as source by "link to external geometry"
Hi there!youen wrote: ↑Sun May 19, 2019 8:47 pm OK, thanks for the answer.
Don't know if this is the right place to talk about this, but looking quickly at the code, in method SketchObject::addExternal, the external is indeed stored as a string, such as "Edge3" (along with a pointer to the referenced DocumentObject, another sketch in my case). Actually, this would be fine if sub-elements were never renamed. Deleting "Edge2" should keep "Edge3" as-is, not renaming it "Edge2" to fill the gap. An alternative would be to assign a persistent ID (for example a random GUID) to each sub-element that can be linked to. I'll see if I have some time to dig into this (but I have not much knowledge about the internals of freecad, so I don't know if I'll have time and motivation to come up with a fix that would be worth sharing).
Basically, yes. It is like you say.
Realthunder experimented first with the UUID that every Geometry object has, and then introduced a new index because the UUID is not human-friendly. In his branch he has evolved this concept quite a lot and it is possible to reassign indices.
Together with Geometry extensions, I am coding something in the lines of Realthunder effort that can be integrated into main FreeCAD. But this effort is stall because we do not have proper c++11 support in the CI system. So I am trying to fix the problems with the CI system and then continue with that effort.
However, if you do not require to rely on the external geometry tool, an alternative can be to use carbon copy as in here:
https://forum.freecadweb.org/viewtopic. ... 68#p309194
Re: Editing sketch used as source by "link to external geometry"
Hi @abdullah, isn't there a Sketch Export feature I do not remember if you implement . Is that tolerent to Sketch Editimg?abdullah wrote: ↑Mon May 20, 2019 11:56 am
However, if you do not require to rely on the external geometry tool, an alternative can be to use carbon copy as in here:
https://forum.freecadweb.org/viewtopic. ... 68#p309194
Re: Editing sketch used as source by "link to external geometry"
OK, I won't work on this then, no need to make the same thing twice (and I don't know when I would have been able to get started anyway). Do you also have ideas to improve the situation with other links to external geometry (i.e. not just link to sketches) ? I believe this is much harder problem to solve, so I'm curious if there are plans.abdullah wrote: ↑Mon May 20, 2019 11:56 am Together with Geometry extensions, I am coding something in the lines of Realthunder effort that can be integrated into main FreeCAD. But this effort is stall because we do not have proper c++11 support in the CI system. So I am trying to fix the problems with the CI system and then continue with that effort.
Thanks for the pointer. Either I don't fully understand, or this solution also has problems: if you want to add something in the "master" sketch, it won't appear in the duplicated sketch. And if I copy the master again, I end up with duplicate edges everywhere. For my use case, "link to external geometry" really seems to be the right tool, it just needs to be a little bit more stable when editing the master sketch.abdullah wrote: ↑Mon May 20, 2019 11:56 am However, if you do not require to rely on the external geometry tool, an alternative can be to use carbon copy as in here:
https://forum.freecadweb.org/viewtopic. ... 68#p309194
In the meantime, I realized that I can work around this issue by refraining from deleting anything in the master sketch. Instead, I can detach edges (remove constraints), and move them somewhere else as construction lines (and possibly reuse them for something else later). Far from ideal, but at least it doesn't break everything that depends on the master sketch.
Re: Editing sketch used as source by "link to external geometry"
Interesting, thanks.paullee wrote: ↑Sun May 19, 2019 10:11 pm Another discussion that may be relevant.
https://forum.freecadweb.org/viewtopic.php?f=22&t=28575
BTW, not sure about status of Realthundar's branch …
Re: Editing sketch used as source by "link to external geometry"
Hmm, just tested that idea, and in fact it doesn't work at all. Links get broken even though I only remove constraints, not edges. More specifically, it seems that "detaching" an edge from other edges, so that edges that were forming a path become disconnected, is enough to break links to other (apparently unrelated) edges.youen wrote: ↑Mon May 20, 2019 8:27 pm In the meantime, I realized that I can work around this issue by refraining from deleting anything in the master sketch. Instead, I can detach edges (remove constraints), and move them somewhere else as construction lines (and possibly reuse them for something else later).