FreeCAD Macros to create plane from one face using as support the XY
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
FreeCAD Macros to create plane from one face using as support the XY
Hello everyone, in the telegram group "FreeCAD en español" arose the need for the following macros. I share with you in case any of you find it useful.
Two macros for PartDesign are presented.
The first one creates a datum plane from a face, using as support the XY plane corresponding to the body of the selected face. In this way there is no dependency on the face, and therefore the problem of topological naming is avoided.
The second macro, allows to update the position of the plane, in case the position of the face has changed, by selecting the plane and the face.
https://github.com/sebasg84/planeFromFace
Two macros for PartDesign are presented.
The first one creates a datum plane from a face, using as support the XY plane corresponding to the body of the selected face. In this way there is no dependency on the face, and therefore the problem of topological naming is avoided.
The second macro, allows to update the position of the plane, in case the position of the face has changed, by selecting the plane and the face.
https://github.com/sebasg84/planeFromFace
-
- Posts: 436
- Joined: Wed Sep 15, 2010 9:38 am
Re: FreeCAD Macros to create plane from one face using as support the XY
Nice macros. Would you agree to put them on the official repository (and accept that others may modify your code)? Please send a pull request if yes.
Thanks,
Gaël
Re: FreeCAD Macros to create plane from one face using as support the XY
Nice. Does it have the option to create just a sketch? Since all I typically need is a sketch and it can be positioned the same as a Datum plane.sebasg84 wrote: ↑Fri Nov 19, 2021 7:47 pm Hello everyone, in the telegram group "FreeCAD en español" arose the need for the following macros. I share with you in case any of you find it useful.
Two macros for PartDesign are presented.
The first one creates a datum plane from a face, using as support the XY plane corresponding to the body of the selected face. In this way there is no dependency on the face, and therefore the problem of topological naming is avoided.
The second macro, allows to update the position of the plane, in case the position of the face has changed, by selecting the plane and the face.
https://github.com/sebasg84/planeFromFace
Edit: I modded it to make just a sketch.
And, yes, I did it quick and dirty.
- Attachments
-
- sketchFromFace.py
- (1.59 KiB) Downloaded 81 times
Last edited by drmacro on Sun Nov 21, 2021 7:16 pm, edited 1 time in total.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: FreeCAD Macros to create plane from one face using as support the XY
Of course I would like to share them in the official repository. But first, I want to make some arrangements. For example, currently the plane is located at the center of mass of the face, but if the shape of the face changes, then the center of mass also, and the plane would move. I already thought about the solution. As soon as I do, I upload it, and make the pull request.galou_breizh wrote: ↑Sat Nov 20, 2021 12:30 pmNice macros. Would you agree to put them on the official repository (and accept that others may modify your code)? Please send a pull request if yes.
Thanks,
Gaël
Thanks,
Sebastian
Re: FreeCAD Macros to create plane from one face using as support the XY
I did this too, but I still haven't upload the macro to github. Then I compare your solution with mine, and get the best of both.
I share my macro that create a sketch over the plane in case you want to see it.
Thanks,
Sebastian
- Attachments
-
- sketchPlaneFromFace.py
- (3.66 KiB) Downloaded 85 times
Last edited by sebasg84 on Sun Nov 21, 2021 7:33 pm, edited 1 time in total.
Re: FreeCAD Macros to create plane from one face using as support the XY
I did it really quick. I just changed the type of object it creates to sketch. at this point my version now has variable names that would make the reader (of the code) think it was a datum, when it is in reality a sketch. I'd clean up the names for any sort of release code.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: FreeCAD Macros to create plane from one face using as support the XY
Edit the previous message, and attach the macro that creates sketch in case you want to try it. The macros need some fixes, which in a short time I will have them ready and upload to github.drmacro wrote: ↑Sun Nov 21, 2021 7:25 pm I did it really quick. I just changed the type of object it creates to sketch. at this point my version now has variable names that would make the reader (of the code) think it was a datum, when it is in reality a sketch. I'd clean up the names for any sort of release code.
Re: FreeCAD Macros to create plane from one face using as support the XY
You misunderstand me. I don't want a datum plane.
In most cases I consider datum planes redundant, so my version creates a sketch, and only a sketch.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: FreeCAD Macros to create plane from one face using as support the XY
I did it, before you ask. And yes, you changed the datumplane to sketch, modifying the line:
datumPlane = body.newObject('PartDesign::Plane','DatumPlane')
for
datumPlane = body.newObject('Sketcher::SketchObject','Sketch')
datumplane may not be necessary. In the group I mentioned, they asked about doing it this way.
You can also add:
Gui.ActiveDocument.setEdit(body,0,datumPlane.Name+".")
If you want the skectch to enter directly into edit.
Re: FreeCAD Macros to create plane from one face using as support the XY
Hi - this thread is a bit old and I'm wondering if this macro(s) are stable and ready to be used by average users - like me