[FR] macro to remap sketch to different reference
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
[FR] macro to remap sketch to different reference
After some recent help requests I was wandering - is it hard to create a macro that will remap a sketch to different reference without moving it from its place. If you have a sketch that is mapped to a face and want to map it to some of the basic planes instead it is relatively easy if that face is parallel to the plane. But what if it is some arbitrary face with hard to calculate origin, translation and rotation?
So what I ask is somebody more capable to program a macro that will take a sketch and face/plane/... and change the mapping of that sketch to that face/plane/... while calculating the corresponding origin, rotation and translation such that the sketch stays in place.
So what I ask is somebody more capable to program a macro that will take a sketch and face/plane/... and change the mapping of that sketch to that face/plane/... while calculating the corresponding origin, rotation and translation such that the sketch stays in place.
Re: [FR] macro to remap sketch to different reference
You can simply deactivate the attachment. Then the previously calculated placement determines the position which thus is the same as before.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: [FR] macro to remap sketch to different reference
I'm interested in knowing the use cases for this ability, because I think it would usually cause trouble if a Sketch, or a Feature made from that Sketch, appears at a place on the model that is away from the Placement of that Sketch. In the 3D view it would likely resemble the problems we see arising from Topological Naming problems, but here it would be the desired behavior.
Then I suppose that if someone would write a macro that places a Sketch at a new location but displays the Sketch at the old location, then the user should be alerted. One way might be that the color scheme of things inside that Sketch should be something entirely new (colors for both Constraints and Geometry when the Sketch is open in Sketcher, and color of that Sketch Geometry in the 3D view after exiting Sketcher).
Except for an extra Sketch, what would be wrong with creating a new Sketch on the desired face, then using Sketcher > Carbon Copy to copy everything from the first Sketch into the new Sketch?
Re: [FR] macro to remap sketch to different reference
The sketch should not change its location at all. That is the whole point. Noв if a sketch is mapped to a face and this face somehow changes (topo naming) the sketch will move to a new location. If that happens the user could undo the operation that lead to that change and remap the sketch to some other more stable place. Present workflow will require either map to corresponding new face (which again could brake later) or select some of the base planes (sketch jumps to it), then adjust position and rotation of the sketch (without transformation widget) to the correct position.
My request is to automate the second part and make it mathematically correct. Sketch stays at same location and orientation but they are derived from another reference.
My request is to automate the second part and make it mathematically correct. Sketch stays at same location and orientation but they are derived from another reference.
Re: [FR] macro to remap sketch to different reference
Seems reachable. I won't have any time in the coming days but could manage to give it a try on next week.
- HarryGeier
- Veteran
- Posts: 1231
- Joined: Mon Jul 10, 2017 12:36 pm
- Location: Hof Germany
Re: [FR] macro to remap sketch to different reference
Well, if you remap to a different reference...i assume it will move position. But it seems possible to to like:
create a sketch on a datum plane lying around randomly in space. Use properties -> map mode and switch it to deactived. The Sketch stays in place. Now to proof..delete the datum plane. Here the sketch..even though i was warned, stayed in its place.
i don´t know what happens when going further ..
create a sketch on a datum plane lying around randomly in space. Use properties -> map mode and switch it to deactived. The Sketch stays in place. Now to proof..delete the datum plane. Here the sketch..even though i was warned, stayed in its place.
i don´t know what happens when going further ..
Kaum macht man´s richtig , gehts´s
My Video Tutorials on Youtube: https://www.youtube.com/channel/UCoe3B ... p8Q/videos
My FreeCAD Stuff on Hidrive: https://my.hidrive.com/share/qr3l1yddy6#$/
My Video Tutorials on Youtube: https://www.youtube.com/channel/UCoe3B ... p8Q/videos
My FreeCAD Stuff on Hidrive: https://my.hidrive.com/share/qr3l1yddy6#$/
Re: [FR] macro to remap sketch to different reference
Thanks for explaining it for me.
I suppose there could be some kind of checking mechanism so that if a Sketch is attached to a Face (say Face5), and that Face becomes renumbered, the Sketch could be automatically be detached and simply remain in the same position in the 3D space instead of being re-positioned because Face5 has now become some other Face in the model.
As things are now, using the Part Design > Reorient Sketch (it's only on the pull-down menu) does the same thing if the user confirms that the Sketch should be detached and then clicks Cancel in the next pop-up window to keep the Sketch at the same location in the 3d space. This is often a method I use when I rebuild someone's model that has become broken because after detaching the Sketches, so they don't move around, it's usually easy to determine where they belong. Even with some Sketches detached and just floating in the 3D space the model is often valid.
I think if you can automate that detaching for affected Sketches instead of having them move unwantedly it would be great, and if you can then re-attach the Sketch to whatever new number Face that old Face5 has become (and so on, down the history tree), well, that would be even better (supposing I haven't misunderstood you).
Re: [FR] macro to remap sketch to different reference
I was trying to find arguments against simply detaching the sketch (I know that it works, I had proposed that for a workflow with DatumPlanes) and realized that without attachment you actually don't see the full info needed to define the plane where the sketch is. We see the position where the 0,0 of the sketch is, axis of rotation and rotation angle. But which are the main axes of the sketch? Sketch is probably in base XY_plane (not explained in Part_Attachment ) but where do we see that? So having it attached to something is better. But we already have it in proper place/orientation in 3D space. We should not loose that. This could even be a setting in mapping dialog - checkbox for "keep current position/orientation" and all relevant parameters be autocalculated.
Re: [FR] macro to remap sketch to different reference
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: [FR] macro to remap sketch to different reference
The whole point is for the sketch NOT to move from its original place. Orienting without actual attachment is nice too but the goal here is to keep the sketch in place, just derive that place from another reference.