Sketcher Carbon Copy functionality

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Sketcher Carbon Copy functionality

Post by abdullah »

Dear all,

Lately I was using Part Design NEXT, trying the Normand-DeepSOIC methodology for robustness (no external links, sketches when supported only on planes). The result is awesome, but the amount of work involved is just too much. Part of this extra work goes in referencing sketcher geometry already introduced in another sketch.

With that in mind, I am developing a new sketcher functionality to facilitate building a model, codename Carbon Copy. In simple words, Carbon Copy copies the geometry of one sketch into another. When finished, it will do it in a smart way (referencing valued constraints to the original sketch via the Expressions Engine). This last part is not yet done.

As teaser and maybe to get some of your valuable user input/requirements, I show you what currently works:

1. This is an empty sketch in edit mode, in which you can see another sketch in the background.
CarbonCopy1.png
CarbonCopy1.png (21.68 KiB) Viewed 3218 times
2. So I click that ugly icon between the external geometry and the toggle construction/normal geometry, then I go a geometry of that sketch in the background and click on it. And I get this:
CarbonCopy2.png
CarbonCopy2.png (32.75 KiB) Viewed 3218 times
Carbon Copy is responsive to the toggle mode, therefore if you just want to get the geometry for reference, you can put it in "construction" creation mode and when hitting the ugly icon you get this:
CarbonCopy3.png
CarbonCopy3.png (32.91 KiB) Viewed 3218 times
ATM those constraints that got copied are full copies (not clones). So the functionality is very limited for my use case. The next step is to link the values of the generated copy to the original via the expressions engine, so that any change in the original propagates automatically.

Let me know your impressions and critics :)

The branch, in case you want to play:
https://github.com/abdullahtahiriyo/Fre ... arbon_copy
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Sketcher Carbon Copy functionality

Post by DeepSOIC »

How about letting one to toggle external-geometry edge out of its permanent construction mode, no?
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Sketcher Carbon Copy functionality

Post by NormandC »

Hello Abdullah,
abdullah wrote:In simple words, Carbon Copy copies the geometry of one sketch into another. When finished, it will do it in a smart way (referencing valued constraints to the original sketch via the Expressions Engine). This last part is not yet done.
This looks awesome.

But I have a question: why do you need to copy the valued constraints and link them to the original ones from the parent sketch? This looks like unnecessary work to me.

My reason for asking is quite simple: I believe that your Sketcher Carbon Copy tool may very well be what the External geometry tool should always have been. It's always annoyed me that External geometry cannot be used directly, and if you need some identical geometry in your sketch you have no choice but to sketch it entirely and superimpose it over/constrain it to the external geometry. It's an incredible hassle, and considering the visibility issues with overlapping geometry in sketches, a usability issue.

I wonder if that's what DeepSOIC was inferring by saying
DeepSOIC wrote:How about letting one to toggle external-geometry edge out of its permanent construction mode, no?
To summarize, what I would like from either your carbon copy tool or the external geometry tool is to:
  • Select any individual edge or group of edges from external geometry
  • Use it either as active geometry by default, or as construction geometry, in such case by turning it into construction mode. IMHO that way there should be no reason for two separate tools
  • In your example, if I select the slot's 2 lines and 2 arcs, the slot would be entirely cloned and be fully constrained, without dimensional constraints; if I select one arc and one contiguous line, they would be constrained to each other and locked in their location, but otherwise would be unconstrained at their opposite ends.
BTW the behaviour I described is what the few commercial parametric CAD programs I've used do.
abdullah wrote:Lately I was using Part Design NEXT, trying the Normand-DeepSOIC methodology for robustness (no external links, sketches when supported only on planes). The result is awesome, but the amount of work involved is just too much.
O/T but just FYI,

There is basically a trade-off that you need to define/decide for yourself. Indeed it takes planning and time to build a 100% robust model. Which is why I never go to the full length (what? you will ask, NormandC admits to being sloppy? :o ;) ) and I tolerate a moderate risk of breakage. IMO it is sometimes less time consuming to deal with an occasional broken model than to try to implement a 100% break-proof methodology for all designed models. ;)
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher Carbon Copy functionality

Post by abdullah »

DeepSOIC wrote:How about letting one to toggle external-geometry edge out of its permanent construction mode, no?
A good idea, but a different use case IMO.

From a programming point of view, what you are indicating is not trivial, as external geometry is fixed solver geometry because it is external. Once it is not external, then should be constrained. We would need to define a fourth category of geometry that is fixed to solver but defines a curve for the purpose of sketching... maybe it is not that difficult after all... An external geometry I think it is construction=true as of today. Theoretically, we could have construction=false and still external... gotta take a look...

About the different use case:
1. External geometry is linked geometry that in absence of proper naming handling will break with model, so it is not robust, but it is indeed convenient.
2. Carbon Copy is meant to be robust, you can not import just one line, but the full sketch, as you do not know how this line is constrained (can be via 3 or more geometric elements). I had in mind asking the solver what constraints a line, but it is out of the initial functionality.

Carbon Copy pursues some kind of evolved "master sketch" approach, in which you do not necessarily construct the whole master sketch in the first sketch (probably I have demean "master sketch" by this characterisation). The idea is that whatever you have constrained in your first sketch can be easily used:
a) to define geometry when needed (non-construction import)
b) to position new geometry in a way that, if you reposition elements in your base sketches, the sketches that depend on it will also move automatically (construction import)
c) a mixture of a) and b), where some geometry is construction and some is not.
NormandC wrote:why do you need to copy the valued constraints and link them to the original ones from the parent sketch? This looks like unnecessary work to me.
I am manually linking expressions of the first sketch into subsequent sketches. When I reach sketch number 5, or if I let a night pass in the middle, I no longer remember the names of the constraints used in expressions and how it was constrained. I have to exit editing mode, go the other sketch, open it, look into it, remember, exit, reenter edit mode in the previous sketch, reenter value edition and create an expression there. It is robust but killing.

With the expression engine automatic referencing, I should be able to have most of the positioning that depends on previous sketches out of the box. Then if I need a modification I can undertake it (like offsetting a dimension via editing the expression).

The bad of this is that you may end up with lots of (construction or not) geometry imported from several "parent/previous" sketches. Powerful, but may not be very clear.

If there are other use cases for the same tool, I can program a copy with expression engine linking and another one without. Feel free to do some usability tests of the branch I have provided and come with additional user input. I listen as always.
NormandC wrote:My reason for asking is quite simple: I believe that your Sketcher Carbon Copy tool may very well be what the External geometry tool should always have been. It's always annoyed me that External geometry cannot be used directly, and if you need some identical geometry in your sketch you have no choice but to sketch it entirely and superimpose it over/constrain it to the external geometry. It's an incredible hassle, and considering the visibility issues with overlapping geometry in sketches, a usability issue.
I would then to say that I would give a go to DeepSOICs idea with your additional input separately as I believed it to be a different use case/user need. However this is kindda hybrid behaviour:
NormandC wrote:In your example, if I select the slot's 2 lines and 2 arcs, the slot would be entirely cloned and be fully constrained, without dimensional constraints; if I select one arc and one contiguous line, they would be constrained to each other and locked in their location, but otherwise would be unconstrained at their opposite ends.
Carbon Copy would import the whole sketch linked to the previous sketch as normal or construction geometry, then the work of the user to achieve what you want is "delete what you do not want". If you want to redimension a line either edit the expression, discard the expression and enter a value of your choice or delete the dimensional constraint if that is what you want...
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher Carbon Copy functionality

Post by abdullah »

NormandC wrote: O/T but just FYI,

There is basically a trade-off that you need to define/decide for yourself. Indeed it takes planning and time to build a 100% robust model. Which is why I never go to the full length (what? you will ask, NormandC admits to being sloppy? :o ;) ) and I tolerate a moderate risk of breakage. IMO it is sometimes less time consuming to deal with an occasional broken model than to try to implement a 100% break-proof methodology for all designed models. ;)
The aim of this tool, being part of an array of new tools, is that you never feel that way again, i.e. that you won't have to compromise. These aids are aimed so that doing it 100% break-proof is faster and better than the current "sloppy" fast-track. Whether we attain our goal or not depends ultimately on us all ;)
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Sketcher Carbon Copy functionality

Post by DeepSOIC »

What does it copy over from the other sketch? A single wire with constraints? or the other sketch in its full glory? Is it going to update if I topologically modify the original sketch (or change the way it is constrained)?

I think this is going to be useful. At least, it will likely come in handy in some situations. For example, when creating sections for loft... Or as a series of shapes of similar geometry...
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher Carbon Copy functionality

Post by abdullah »

DeepSOIC wrote:What does it copy over from the other sketch? A single wire with constraints? or the other sketch in its full glory?
In principle the full glory version. Why? Geometry gets constrained indirectly by other geometry and I want to...
DeepSOIC wrote: Is it going to update if I topologically modify the original sketch (or change the way it is constrained)?
... be able to update thru when there is modification in the original sketch (or parent sketches, because there is no limitation to one sketch, only DAG due to expressions).
DeepSOIC wrote:I think this is going to be useful. At least, it will likely come in handy in some situations. For example, when creating sections for loft... Or as a series of shapes of similar geometry...
Well, I think I am going to do a quite intensive use of it. Why? Even in cases where the geometry is not shared at all between operations, it allows you to propagate all the positioning you already have in the parent sketches. Just imagine a very simple example where I have one rectangle padded and I want to make holes in it relative to the corners or edges of the rectangle. Options:

a) you make a new construction rectangle and constraint the circles for the holes relative to it (if you modify the original you have to update all copies unless you use expressions entered by yourself).
b) you import some vertex or edges via external geometry and pray it does not eventually break (yes, for this simple case it will be difficult, but you get the idea).
c) you use this tool to bring the "full glory" fully referenced by expressions as construction geometry with one click.

Of course, you can always delete a part of the "full glory" if you do not need it. For example you are just referencing with respect of one corner of the rectangle, which has a lock constraint on it, then you can delete the two superfluous lines.

If any of you sees merit in:
a) Not referencing via expressions
b) Importing only the clicked edge and its constraints
c) ...

Just let me know.

Carbon copy compared to external geometry has an additional limitation that only works on sketches, not on real edges.

In images (the highest amount of work was actually creating the circles and making them coincident, the other was just one click):
cc_Ex1.png
cc_Ex1.png (4.56 KiB) Viewed 3111 times
cc_Ex2.png
cc_Ex2.png (5.42 KiB) Viewed 3111 times
cc_Ex3.png
cc_Ex3.png (14.56 KiB) Viewed 3111 times
cc_Ex4.png
cc_Ex4.png (14.68 KiB) Viewed 3111 times
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher Carbon Copy functionality

Post by abdullah »

I am very happy with myself today. I have implemented the linking with the expression engine.

Now if you change the original sketch, geometry changes propagate thru the model. Expression Engine is great! Thanks Erik and company!!

If you name the variables in your original sketch, then the carbon copied constraints also have that very same name. This helps a lot with focusing in the design and not needing to remember constraints name.

At this point I would gently ask you wonderful FreeCAD community to test it and come with bugs or further usability requirements :)
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher Carbon Copy functionality

Post by abdullah »

Here you have a model created with carbon copy in its current state. Of course can be opened with normal PPA freecad.

This took me very little time to do, and now try to change the dimensions in the original sketch.

There is still something to figure out regarding the directions of the sketch though (see last sketch)...
carbon_copy_trial.fcstd
(20.78 KiB) Downloaded 75 times
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher Carbon Copy functionality

Post by abdullah »

I have been using Carbon Copy in my designs for the last couple of days.

I save a lot of time in common operations (mostly because the positioning gets copied with the sketch). I am very happy with it.

I have detected some bugs, like for example when the sketch mapping is reversed, or the sketches are not actually parallel. I have just fixed the bugs I have found and pushed the code to the branch:

https://github.com/abdullahtahiriyo/Fre ... arbon_copy

I intend to merge this just after the bspline package gets merged (because it is likely to conflict with it). If anybody wants to test it and finds any issue let me know :)
Post Reply