Help wanted for scripting an "epicycloid" for sketcher
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- manuelkrause
- Posts: 442
- Joined: Thu Jul 05, 2018 7:16 pm
Help wanted for scripting an "epicycloid" for sketcher
Hi people,
can someone point me to the ways how to create a scripted sketch for an epicyloid?
The result should be either point based or even better usable for later FC part design. Spline?
I've currently hand-made the first steps, by constrained geometry, but they're getting slower over each new constraint.
EDIT: on my slow CPU ~3min. at a next angular constraint.
Many thanks in advance!
BR,
Manuel
can someone point me to the ways how to create a scripted sketch for an epicyloid?
The result should be either point based or even better usable for later FC part design. Spline?
I've currently hand-made the first steps, by constrained geometry, but they're getting slower over each new constraint.
EDIT: on my slow CPU ~3min. at a next angular constraint.
Many thanks in advance!
BR,
Manuel
- Attachments
-
- Screenshot_20190105_173502.png (159.78 KiB) Viewed 2005 times
Re: Help wanted for scripting an "epicycloid" for sketcher
Added a little bit to the requirements.
The question seems to be how to create your own 2d-shape object type given by equations (indicated red below in the screen shot)
https://en.wikipedia.org/wiki/Epicycloid
The red curve is given by the formula. --HJH
The question seems to be how to create your own 2d-shape object type given by equations (indicated red below in the screen shot)
https://en.wikipedia.org/wiki/Epicycloid
The red curve is given by the formula. --HJH
Last edited by hjh on Sat Jan 05, 2019 5:43 pm, edited 1 time in total.
- manuelkrause
- Posts: 442
- Joined: Thu Jul 05, 2018 7:16 pm
Re: Help wanted for scripting an "epicycloid" for sketcher
Many thanks,hjh wrote: ↑Sat Jan 05, 2019 5:35 pm Added a little bit to the requirements.
The question seems to be how to create your own 2d-shape object type given by equations (indicated red below in the screen shot)
https://en.wikipedia.org/wiki/Epicycloid
Epicycloid_Wikipedia_Screenshot_2019-01-05.png
--HJH
but my main question is, how to guide it (the Epicyloid formula) into a python usable formula, to gather coordinates for points etc. I've read the wikipedia etc.
Manuel
- manuelkrause
- Posts: 442
- Joined: Thu Jul 05, 2018 7:16 pm
Re: Help wanted for scripting an "epicycloid" for sketcher
Don't understand me wrong. I just want to get the curves into usable sketch points.hjh wrote: ↑Sat Jan 05, 2019 5:35 pm Added a little bit to the requirements.
The question seems to be how to create your own 2d-shape object type given by equations (indicated red below in the screen shot)
https://en.wikipedia.org/wiki/Epicycloid
Epicycloid_Wikipedia_Screenshot_2019-01-05.png
The red curve is given by the formula.
epicycloid_formula_wp.png
--HJH
Re: Help wanted for scripting an "epicycloid" for sketcher
It seems that the issue is to follow the Octahedron example
https://www.freecadweb.org/wiki/Scripted_objects
and create a class Epicycloid.
What makes it more complex is that the new shape is given by a formula and not by discrete points.
Maybe there is an example in the documentation somewhere how to describe an object shape with a formula, not discrete points.
BTW could you please indicate how you produced what is seen on your screen shot?
--HJH
https://www.freecadweb.org/wiki/Scripted_objects
and create a class Epicycloid.
What makes it more complex is that the new shape is given by a formula and not by discrete points.
Maybe there is an example in the documentation somewhere how to describe an object shape with a formula, not discrete points.
BTW could you please indicate how you produced what is seen on your screen shot?
--HJH
- manuelkrause
- Posts: 442
- Joined: Thu Jul 05, 2018 7:16 pm
Re: Help wanted for scripting an "epicycloid" for sketcher
Do you understand a little German? Doesn't matter if not. Main actual math of it I re-derived from wikipedia. The base data info was from http://rx7ch.com/files/wankelmotor_matura_arbeit.pdf (german). Page 16 and following.hjh wrote: ↑Sat Jan 05, 2019 5:54 pm It seems that the issue is to follow the Octahedron example
https://www.freecadweb.org/wiki/Scripted_objects
and create a class Epicycloid.
What makes it more complex is that the new shape is given by a formula and not by discrete points.
Maybe there is an example in the documentation somewhere how to describe an object shape with a formula, not discrete points.
BTW could you please indicate how you produced what is seen on your screen shot?
--HJH
For the work for the screenshot I stupidly made all the geometric settings in the sketch. One degree on main circle, two degrees on rolling circle, including some distance always rotated with the rolling circle, leading to the needed resulting curve point.
BR,
Manuel
- manuelkrause
- Posts: 442
- Joined: Thu Jul 05, 2018 7:16 pm
Re: Help wanted for scripting an "epicycloid" for sketcher
Thank you very much for this collection !saso wrote: ↑Sat Jan 05, 2019 6:06 pm There are some macros
https://www.freecadweb.org/wiki/Macro_Draw_2D_Function
https://www.freecadweb.org/wiki/Macro_D ... D_Function
https://www.freecadweb.org/wiki/Macro_3 ... tric_Curve
I need to have a closer look at them during next days.
Best regards,
Manuel
Re: Help wanted for scripting an "epicycloid" for sketcher
Oh--that's cool. I tried it out and this should get you going. I tried it with R = 3, 5, and 15, and from wiki link, it looks correct.
I placed this in the XY plane, but you should be able to manipulate to your own needs from here I suspect. You can convert to a Sketch in DraftWB, but I don't think that will help you much--this has 3003 degrees of freedom in the Sketcher;)
I looked a bit further, and this isn't correct yet for fractional k values.
Cheers,
Josh
Code: Select all
import FreeCAD
from FreeCAD import Gui
from FreeCAD import Base
from FreeCAD import Vector
import Part
import math
import Sketcher
import os
import Draft
R = 3.0 # Big Radius
r = 1.0 # Little Radius
k = R/r # Altenate form constant
K = (k + 1)
Num_Theta_Points = 1000
Theta_Step = ((2* math.pi / Num_Theta_Points))
Epicycloid_Points = []
for t in range(0, (Num_Theta_Points - 1), 1):
Theta = (t * Theta_Step)
x = (r * K * math.cos(Theta)) - (r * math.cos(K * Theta))
y = (r * K * math.sin(Theta)) - (r * math.sin(K * Theta))
epicycloid_point = Base.Vector(x, y, 0.0)
Epicycloid_Points.append(epicycloid_point)
Draft.makeBSpline(Epicycloid_Points)
I looked a bit further, and this isn't correct yet for fractional k values.
Cheers,
Josh
- Attachments
-
- Epicycloid.FCMacro
- (722 Bytes) Downloaded 61 times
-
- Posts: 24
- Joined: Mon Dec 31, 2018 6:43 pm
- Location: France
Re: Help wanted for scripting an "epicycloid" for sketcher
Here is a Script which draw the Epicycloid in the Sketch
Create a new document and sketch and then launch the macro
You will see how the drawing is made by the movement of a line and a circle
Create a new document and sketch and then launch the macro
You will see how the drawing is made by the movement of a line and a circle
- Attachments
-
- Epicycloide2.FCMacro
- (2.14 KiB) Downloaded 94 times