Draw curve based on a function in Sketch(Part Design) Workbench
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!
-
- Posts: 36
- Joined: Thu Sep 09, 2021 10:58 pm
Draw curve based on a function in Sketch(Part Design) Workbench
Hello dear community and developers,
I hope you are doing fine. I want to know how can I draw a curve in a XY plane based on a function (ie. exponential function) in the Sketcher (or Part Design) Workbech.
Big hugs
Diego
I hope you are doing fine. I want to know how can I draw a curve in a XY plane based on a function (ie. exponential function) in the Sketcher (or Part Design) Workbech.
Big hugs
Diego
Re: Draw curve based on a function in Sketch(Part Design) Workbench
Hi Diego and welcome to the forum!
You cannot do it directly in Sketcher, but you can use addon macro "3D Parametric Curve" to create a draft object which then can be converted into a sketch.
You cannot do it directly in Sketcher, but you can use addon macro "3D Parametric Curve" to create a draft object which then can be converted into a sketch.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
-
- Posts: 36
- Joined: Thu Sep 09, 2021 10:58 pm
Re: Draw curve based on a function in Sketch(Part Design) Workbench
Hello dear Chrisb
Thanks for your reply, it worked. I actually could manage to draw the parametric function curve into a draft. Now I want to convert this draft into an sketch object in order to work with it in the Part Design Workbench, and build a compound out of other parts from that parts planes/faces,etc
Big Hugs and thanks for the weloming
Diego
-
- Posts: 36
- Joined: Thu Sep 09, 2021 10:58 pm
Re: Draw curve based on a function in Sketch(Part Design) Workbench
Hello dear Markster,TheMarkster wrote: ↑Fri Sep 10, 2021 2:34 pm I'm working on an update to that macro.
https://forum.freecadweb.org/viewtopic.php?f=22&t=61707
Awesome job. I will check up your videos on this macro upgrade.
Big hugs
Diego
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: Draw curve based on a function in Sketch(Part Design) Workbench
You can use the ParametricCurve object like you would a sketch. It can even be attached.dfosorio11 wrote: ↑Fri Sep 10, 2021 3:15 pmHello dear Chrisb
Thanks for your reply, it worked. I actually could manage to draw the parametric function curve into a draft. Now I want to convert this draft into an sketch object in order to work with it in the Part Design Workbench, and build a compound out of other parts from that parts planes/faces,etc
Big Hugs and thanks for the weloming
Diego
Suppose I want to get this curve into a Body:
Click on the Body. In the property view look for the Group property. Click it, and then the [...] button to bring up the editor. Select the ParametricCurve object to add it to the Body.
Now the ParametricCurve is in the Body. We can attach to one of the planes as we would a sketch, Pad it, whatever.
Of course, it must be 2D in order to use Pad with it. You can ensure this by setting the Z formula to 0 or some constant value or just leaving it blank.
-
- Posts: 36
- Joined: Thu Sep 09, 2021 10:58 pm
Re: Draw curve based on a function in Sketch(Part Design) Workbench
Hi dear Markster!
Thanks a lot for your help. I did could mange to attach the 3D Parametric Curve object to the body. The problem is I can't edit the sketch or the Part in the solid directly, so I can't restrict the sketch with other lines, points, curves, etc to form a sketch to extrude. I tryed your attachment procedure in the Draft WB and the Sketch WB, but still could not get to build my 2D geometry for extrude.
The 3D parametric curve I am modeling is y(a,b,t)= a*exp(b*t), a=0,05 b=0,204 t=x , -12.33<t<0 (I attached pictures from the Vivaldi Broadband 3D model antenna I am trying to build), so the thing is this y(f) Parametric Curve is just a part of the 2D Sketch (or draft). I need to add the remaiding top and lower lines, and the vertical x-axis line, and the mirror the 2D sketch for extrude. I can visualize the 3D parametric curve but I can't unite it with the other lines.
Any ideas? I've been working with this antenna for 2 weeks and my boss is like killing me (
Big hugs as always!
PS: Check the attached files to see the curves ;o)
Diego!
Thanks a lot for your help. I did could mange to attach the 3D Parametric Curve object to the body. The problem is I can't edit the sketch or the Part in the solid directly, so I can't restrict the sketch with other lines, points, curves, etc to form a sketch to extrude. I tryed your attachment procedure in the Draft WB and the Sketch WB, but still could not get to build my 2D geometry for extrude.
The 3D parametric curve I am modeling is y(a,b,t)= a*exp(b*t), a=0,05 b=0,204 t=x , -12.33<t<0 (I attached pictures from the Vivaldi Broadband 3D model antenna I am trying to build), so the thing is this y(f) Parametric Curve is just a part of the 2D Sketch (or draft). I need to add the remaiding top and lower lines, and the vertical x-axis line, and the mirror the 2D sketch for extrude. I can visualize the 3D parametric curve but I can't unite it with the other lines.
Any ideas? I've been working with this antenna for 2 weeks and my boss is like killing me (
Big hugs as always!
PS: Check the attached files to see the curves ;o)
Diego!
-
- Posts: 36
- Joined: Thu Sep 09, 2021 10:58 pm
Re: Draw curve based on a function in Sketch(Part Design) Workbench
TheMarkster wrote: ↑Fri Sep 10, 2021 9:11 pmYou can use the ParametricCurve object like you would a sketch. It can even be attached.dfosorio11 wrote: ↑Fri Sep 10, 2021 3:15 pmHello dear Chrisb
Thanks for your reply, it worked. I actually could manage to draw the parametric function curve into a draft. Now I want to convert this draft into an sketch object in order to work with it in the Part Design Workbench, and build a compound out of other parts from that parts planes/faces,etc
Big Hugs and thanks for the weloming
Diego
Suppose I want to get this curve into a Body:
Snip macro screenshot-3226ee.png
Click on the Body. In the property view look for the Group property. Click it, and then the [...] button to bring up the editor. Select the ParametricCurve object to add it to the Body.
Snip macro screenshot-8acfff.png
Snip macro screenshot-71c9bc.png
Now the ParametricCurve is in the Body. We can attach to one of the planes as we would a sketch, Pad it, whatever.
Snip macro screenshot-28433b.png
Of course, it must be 2D in order to use Pad with it. You can ensure this by setting the Z formula to 0 or some constant value or just leaving it blank.
- Attachments
-
- im2.png (130.83 KiB) Viewed 4096 times
-
- im1.png (161.4 KiB) Viewed 4096 times
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: Draw curve based on a function in Sketch(Part Design) Workbench
To use Parametric_Curve_FP you must put the Parametric_Curve_FP.py file in your macros folder and also Make_Parametric_Curve.py into the same folder. Execute Make_Parametric_Curve to create the parametric curve fp object.
I entered the parameters you said, but I get a very flat curve. Perhaps I entered them wrong?
Attach a screenshot of your parameters as you have put them so I can see if they are the same that I used. Attach your file, too, if you can.
You can bring the bspline into your sketch as follows:
Use the link to external geometry tool (keyboard shortcut: X) in the sketch to create the external (purple) link.
Select the purple edge.
Sketch menu -> Sketcher bspline tools -> convert geometry to bspline
Now you have the curve into your sketch. You should be able to add coincidence constraints to the end points of the curve.
If the curve object is not inside the body (if using Part Design) you can create a shapebinder of it and use that with the external geometry.
I entered the parameters you said, but I get a very flat curve. Perhaps I entered them wrong?
Attach a screenshot of your parameters as you have put them so I can see if they are the same that I used. Attach your file, too, if you can.
You can bring the bspline into your sketch as follows:
Use the link to external geometry tool (keyboard shortcut: X) in the sketch to create the external (purple) link.
Select the purple edge.
Sketch menu -> Sketcher bspline tools -> convert geometry to bspline
Now you have the curve into your sketch. You should be able to add coincidence constraints to the end points of the curve.
If the curve object is not inside the body (if using Part Design) you can create a shapebinder of it and use that with the external geometry.
-
- Veteran
- Posts: 3079
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Draw curve based on a function in Sketch(Part Design) Workbench
You sure it's not 0<t<12.33? Origin in your figure is not at the right hand edge.dfosorio11 wrote: ↑Sun Sep 12, 2021 10:51 pm The 3D parametric curve I am modeling is y(a,b,t)= a*exp(b*t), a=0,05 b=0,204 t=x , -12.33<t<0