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)
 
Top