Who helps finishing this Bexziercirle script?

Nearly all problems solved behalves of making the bezier curve cyclic

Who knows the API for that!???
it is curve.py from the snippets adjusted …


#----------------------------------------------------------
# File makebezierCircle.py
#----------------------------------------------------------
import bpy


def createCurveObject():    
    # Create curve and object
    cu = bpy.data.curves.new('MyCurve', 'CURVE')
    ob = bpy.data.objects.new('MyCurveObjectCirclePKHG', cu)
    bpy.context.scene.objects.link(ob)
    ob.location = (0,1,0) #?neede?
    print(dir(ob))
    # Set some attributes
    cu.dimensions = '3D'
    cu.use_fill_back = True
    cu.use_fill_front = True
    ob.show_name = True

    beziers = [
         ((1, 0 , 0 ),( 1, 0.5 , 0 ), (1 , -0.5 , 0 )),
         ((0, -1 , 0 ),( 0.5, -1, 0 ), (-0.5 , -1 , 0 )),
         ((-1, 0 , 0 ),( -1, -0.5 , 0 ), (-1 , 0.5 , 0 )),
        ]

    # Create spline and set Bezier control points
    spline = cu.splines.new('BEZIER')
    nPointsU = len(beziers)
    spline.bezier_points.add(nPointsU)
    for n in range(nPointsU):
        bpt = spline.bezier_points[n]
        (bpt.co, bpt.handle_left, bpt.handle_right) = beziers[n]
    print(dir(spline))
    startPoint = spline.bezier_points[-1]  #NOTE this is created by a new action above!!!!
    startPoint.co = (0,1,0)
    startPoint.handle_left = (-0.5,1,0)
    startPoint.handle_right = (0.5,1,0)
    #>>> b0.handle_left=[-0.5,1,0]
 #>>> b0.handle_right=[0.5,1,0]
#    bpy.context.area.type="VIEW_3D"
#    bpy.ops.object.editmode_toggle()
#    bpy.ops.curve.select_all(action='SELECT')
#    bpy.ops.curve.cyclic_toggle(direction='CYCLIC_U')

#    print(spline.bezier_points[-1].co)
    return ob
        
def run(origin):

    curveob = createCurveObject()
    curveob.location = origin
    curveob.select = True
#    bpy.ops.transform.translate(value=(2,0,0))
    
    return

if __name__ == "__main__":
    run((0,0,0))


Now it is a 3/4 circle :frowning: only

just spline.use_cyclic_u = True
or am i missing something…?

No does not work,
The curve must be in edit-mode and all points selected

The command alone does not do it ;-(

Try it ;-)!

the problem seems to be on your side… works ok here :slight_smile:
again, i may be missing something

@liero
you are right … I tried it and it did not work … but now I put it into the script and it works as you said
Thanks! Sometimes I need someone else … thanks again!

glad to help! take care

So here is a real version (because of a bezier circle can be created directly in a script)
http://www.petergragert.info/pmwiki/pmwiki.php/MeanderPath/SourceBevelObjecte