Assigning sketches to standard planes, macro

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
freedman
Veteran
Posts: 3440
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Assigning sketches to standard planes, macro

Post by freedman »

TheMarkster wrote this in a post and it got me fired up to generate a macro:
https://forum.freecadweb.org/viewtopic. ... 88#p444030

See the last post.
Last edited by freedman on Fri Nov 20, 2020 3:17 pm, edited 2 times in total.
kisolre
Veteran
Posts: 4163
Joined: Wed Nov 21, 2018 1:13 pm

Re: Assigning sketches to standard planes, macro

Post by kisolre »

Could you add possibility too remap to selected objects CS? Like add a datum plane and remap several linked sketches to it for easy common manipulation?
freedman
Veteran
Posts: 3440
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Assigning sketches to standard planes, macro

Post by freedman »

See last post.
Last edited by freedman on Fri Nov 20, 2020 3:18 pm, edited 1 time in total.
freedman
Veteran
Posts: 3440
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Assigning sketches to standard planes, macro

Post by freedman »

Old info, removed
Last edited by freedman on Thu Apr 14, 2022 4:27 am, edited 1 time in total.
freedman
Veteran
Posts: 3440
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Assigning sketches to standard planes, macro

Post by freedman »

I plan to add recompute to the macro, I have had some FreeCAD crashes, this thing is a bit dangerous without a recompute I think. You can also imagine as I do that mapping a sketch to new place could have some serious issues if not done in a correct way and finished completely.

If anyone has thoughts about features that could make this more useful as a test bed for anti-TNP modeling. Is there some sort of next step?
Some thoughts I had:

1) I could add an auto assign to sketch button that would automatically assign a sketch to a plane when exiting Sketcher.

2)A thought, could everything just be assigned to the XY_Plane. If I create a model and pad, then pocket a few features the model doesn't care if I map everything to the XY_plane, the Pad/pocket holds the correct offsets, granted they can be very complex in the properties, but not in the Pad/Pocket task combo view windows

3) When the remapping occurs could the map-to face location be saved and compared later for changes.

Thanks
freedman
Veteran
Posts: 3440
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Assigning sketches to standard planes, macro

Post by freedman »

Removed all, old info
Last edited by freedman on Thu Apr 14, 2022 4:26 am, edited 2 times in total.
freedman
Veteran
Posts: 3440
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Assigning sketches to standard planes, macro

Post by freedman »

Removed all
Last edited by freedman on Thu Apr 14, 2022 4:25 am, edited 2 times in total.
edi
Posts: 481
Joined: Fri Jan 17, 2020 1:32 pm

Re: Assigning sketches to standard planes, macro

Post by edi »

Could you please give a workflow how to use the script.
I did the following:
- create a sketch and a datum plane
- start the script
- select the sketch
- click the XY-Plane button
- select the plane
- click the upper Map to support button

Returned are the messages:
1372.47 <App> Document.cpp(3151): The graph must be a DAG.
1372.52 <App> Document.cpp(3504): Unbenannt#Sketch still touched after recompute
freedman
Veteran
Posts: 3440
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Assigning sketches to standard planes, macro

Post by freedman »

This macro keeps the location of your sketch but assigns the Support to a standard plane.

Step #1,
You select the reference in the tree and click the button, you will see the button text populate. Let's say it states "XY_plane001". You can use Origin planes/Datum Planes/LCS as a support target. The default is XY_plane. Be sure to use the numbered plane/datum/LCS that go with the targeted sketch.

Step #2,
Select a sketch and click Map to support, your now finished with one mappping. If you go look at the sketch support you will see XY_Plane001 as the support field.

If you are mapping to the same plane again you don't need to do step #1 again, just repeat step #2.
Attachments
Map_to_standard_plane2.FCMacro
(7.55 KiB) Downloaded 9 times
map_to.png
map_to.png (51.17 KiB) Viewed 313 times
Post Reply