What's new

Drawing Parabole, need help [SOLVED]

Kunstmaan

Alibre Super User
Some years ago I created a "Wizo" script to make a parbole and at that time it worked.
But now it doesnt, so I am puzled.
Code:
Units.Current = UnitTypes.Millimeters
x_max = 600
y_max = 180
step = 25
f = 500
#formula  x=y^2/4f

def para(x):
    y = x**2 / (4*f)
    print " x = %.3f , y = %.3f" % (x, y)
    return(y)

#Create part
MyPart = Part("Parabola")
Parabola = MyPart.AddSketch("Parabola", MyPart.GetPlane("XY-Plane"))

#Generate list of points
points = []
for x in range(0, x_max+step, step):
    points.extend([x, para(x)])

# Place it in a sketch
Parabola.AddBsplineThroughPoints(3, points, False)

Can somebody what wrong in this code
 

idslk

Alibre Super User
your last line should look:
Parabola.AddBspline(points, False)

in addition to be language independent you should use "MyPart.XYPlane" instead of "MyPart.GetPlane("XY-Plane")"
 

idslk

Alibre Super User
This change creates a error
which one?
Here it runs:
1703095272533.png
Python:
Units.Current = UnitTypes.Millimeters
x_max = 600
y_max = 180
step = 25
f = 500
#formula  x=y^2/4f

def para(x):
    y = x**2 / (4*f)
    print " x = %.3f , y = %.3f" % (x, y)
    return(y)

#Create part
MyPart = Part("Parabola")
Parabola = MyPart.AddSketch("Parabola", MyPart.XYPlane) #GetPlane("XY-Plane"))

#Generate list of points
points = []
for x in range(0, x_max+step, step):
    points.extend([x, para(x)])

# Place it in a sketch
Parabola.AddBspline(points, False)
 

stepalibre

Alibre Super User
....may I ask, given the equation for the Parabola, what is the best way to remove the wobbles in the parabolic curve?
Is this better?
1733032110435.png
Python:
Units.Current = UnitTypes.Millimeters
x_max = 600
y_max = 180
f = 500
def para(x):
    y = float(x**2) / (4*f)
    print " x = %.3f , y = %.3f" % (x, y)
    return y
MyPart = Part("Parabola")
Parabola = MyPart.AddSketch("Parabola", MyPart.XYPlane)
points = []
x = 0
while x <= 50:
    y = para(x)
    if y <= y_max:
        points.extend([x, y])
    x += 1
while x <= 200:
    y = para(x)
    if y <= y_max:
        points.extend([x, y])
    x += 3
while x <= x_max:
    y = para(x)
    if y <= y_max:
        points.extend([x, y])
    x += 5
Parabola.AddBspline(points, False)
You can increase points to make a smoother curve.
 
Is this better?
View attachment 43361
Python:
Units.Current = UnitTypes.Millimeters
x_max = 600
y_max = 180
f = 500
def para(x):
    y = float(x**2) / (4*f)
    print " x = %.3f , y = %.3f" % (x, y)
    return y
MyPart = Part("Parabola")
Parabola = MyPart.AddSketch("Parabola", MyPart.XYPlane)
points = []
x = 0
while x <= 50:
    y = para(x)
    if y <= y_max:
        points.extend([x, y])
    x += 1
while x <= 200:
    y = para(x)
    if y <= y_max:
        points.extend([x, y])
    x += 3
while x <= x_max:
    y = para(x)
    if y <= y_max:
        points.extend([x, y])
    x += 5
Parabola.AddBspline(points, False)
You can increase points to make a smoother curve.
Thanks Stephen, you're a legend!!!!

LOVE the Alibre community
 

bolsover

Alibre Super User
Just out of curiosity, I wondered what might be done to generate a parabolic curve without using a script - just the equation editor.
For a plain parabola with a 0,0 vertex it turns out to be simple and the curve can be controlled with just 2 parameters.
Would be a little more complex for an offset vertex.

Screenshot 2024-12-08 121520.png

Screenshot 2024-12-08 121720.png
 

Attachments

  • Parabola.AD_PRT
    251.5 KB · Views: 6
Hi David, Happy New Year! :), hmmm, I had not considered that approach (silly me). I will take a look at this method however, I am dealing with optics that requires a unique parabolic shape....I am wondering if your approach could accommodate that....I'll try and get back to you.
Thanks so much for your detailed response.
 

bolsover

Alibre Super User
Hi David, Happy New Year! :), hmmm, I had not considered that approach (silly me). I will take a look at this method however, I am dealing with optics that requires a unique parabolic shape....I am wondering if your approach could accommodate that....I'll try and get back to you.
Thanks so much for your detailed response.
@FailureByDesign
After the earlier post, I played with the idea some more..
I adjusted the formulae so you can enter just height and width of the parabola - also calculated focal point..
David
 

Attachments

  • Parabola.AD_PRT
    452.5 KB · Views: 2
Top