NoobQuestion: 'Curve' object has no attribute 'primitive_bezier_circle_add'

Hello together!

First i want to state: i now really fell in love with blender, i guess i bought my last CINEMA 4D version :wink: improvements over the last 2 years are tremendous.

but…problem have:
I have a existing Curve (Polyline), now i want to add a bezierCircle to it (should be a hole in the end). So…

(folling steps via normal UI by Mouse) i select the Curve-Object, change into Edit-Mode, Schift-A for add -> add BezierCircle. -> fine.

i copy the code from the InfoPanel:
bpy.ops.curve.primitive_bezier_circle_add(view_align=F…

and paste it directly into the console to run it again, but i get:
AttributeError: ‘Curve’ object has no attribute ‘primitive_bezier_circle_add’ in the API this function is member of the Class Curve… -> :eek:

if i’d understand what goes wrong here, it’d solve more cases, in which i meet the same behaviour.
i tried a lot by now, but i’m afraid something essential is missing in my understanding of blender.

pls help
Greetings

bpy.ops executes within a certain context. It relies on the context it was issued from for information on what to operate upon. When you paste the code into the console you change the context, there is not enough information for the operation to take place. Typically the missing data translate into None. The python None object/variable does not have the attribute so the error is thrown. It is possible to construct a ‘fake’ context for some bpy.ops methods.

If you really want to generate curve based objects from code take a look at some of the existing AddOns and how they operate for more detail.

Personally I try to avoid all bpy.ops operations if possible. I only resort to using them when I encounter no other way to solve a problem.

Hi,

The python console is a handy way to work out blender. ctrl-space gives you auto complete
displayed here where there is a list and no >>>


>> bpy.ops.curve.primitive_
                            bezier_circle_add(
                            bezier_curve_add(
                            nurbs_circle_add(
                            nurbs_curve_add(
                            nurbs_path_add(
>>> bpy.ops.curve.primitive_bezier_c
                                    ircle_add(
                                    urve_add(
>>> bpy.ops.curve.primitive_bezier_curve_add(             <----- an autocomplete at the brace gives the arguments...
primitive_bezier_curve_add()
bpy.ops.curve.primitive_bezier_curve_add(radius=1, view_align=False, enter_editmode=False, location=(0, 0, 0), rotation=(0, 0, 0), layers=(False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
>>> bpy.ops.curve.primitive_bezier_curve_add()
{'FINISHED'}


>>> 

Operators only return a message indicating the result, in this case {‘FINISHED’} which is good news and there is a new curve in the 3D viewport located at the cursor.