Bevel Curve Problem

Hey Everyone. I am trying to use a Python script to bevel a bezier curve with a bezier circle. Here is the line of code that I used:

bpy.data.curves[‘BezCurve’].bevel_object=bpy.data.objects.get(“BezCircle”)

When I first load the script and run it, it works great—creating the bevel that I desire. However, if I try to run the script again, the bevel command does nothing. I have to load the script into a new Blender file, for it to work properly again. And again, it will only work once.

I suspect that internally, Blender is creating “BezCurve.001, 002, 003…” and “BezCircle.001, 002, 003…”—even though I am manually deleting the objects each time, before I run the script again.

Do I need to use some sort of “purge” command, or perhaps, dummy variables? Is there some other step that I am omitting? or, is there simply a better way of doing this?

Also, on a related note, is there a way (using script) to remove the duplicate control point, and close the path, of the Bezier circle that I created? Or, does Blender have a script command for creating a Bezier circle?

clear temporary cache

bpy.data.curves[‘name’].user_clear() ?

add circle

bpy.ops.curve.primitive_bezier_circle_add()

Unfortunately, the first suggested code line did nothing. Still have the same problem.

The second line, worked great, to create the bezier circle. However, that only seemed to compound the first problem—the problem where the beveling function can’t seem to find the curves.

Or, am I somehow going about this in the wrong way?