ddg.blender.curve module
- ddg.blender.curve.curve(name, points, periodic)[source]
Create a Blender curve from points.
- Parameters:
- namestr
The
nameattribute of the curve.- pointsarray_like of shape (num_points, 3)
The points of the curve. The dtype must be some kind of floating point dtype.
- periodicbool
The curve is closed if and only if periodic is
True.
- Returns:
- bpy.types.Curve
- Raises:
- ValueError
If there already exists a curve with the given name.
- ddg.blender.curve.disconnected_curve(name, curve_components, /)[source]
Create a Blender curve from connected components.
- Parameters:
- namestr
The
nameattribute of the curve.- curve_componentsddg.arrays.DisconnectedCurve
- Returns:
- bpy.types.Curve
- Raises:
- ValueError
If there already exists a curve with the given name.
- ddg.blender.curve.curve_as_mesh(name, points)[source]
Create a Blender curve from points and convert it to a curve.
- Parameters:
- namestr
The
nameattribute of the mesh.- pointsarray_like of shape (num_points, 3)
The points of the curve/mesh. The dtype must be some kind of floating point dtype.
- Returns:
- bpy.types.Mesh
- ddg.blender.curve.curve_object(points, periodic, curve_and_object_name, collection)[source]
Create a curve from points and wrap it in a Blender object.
- Parameters:
- pointsarray_like of shape (num_points, 3)
The points of the curve. The dtype must be some kind of floating point dtype.
- periodicbool
The curve is closed if and only if periodic is
True.- curve_and_object_namestr or tuple[str, str]
The
nameattribute of the curve and the object. If only one string is passed, then use the same name for both.- collectionbpy.types.Collection, str, None
If
None, then the Blender object is not linked. Otherwise, the Collection or name of collection to link the object to.
- Returns:
- bpy.types.Object
- Raises:
- ValueError
If there already exists a Blender curve or Blender object with the same name.
- ddg.blender.curve.disconnected_curve_object(curve_components, curve_and_object_name, collection, /)[source]
Create a Blender curve from connected components.
- Parameters:
- curve_componentssequence of ddg.arrays.Curve
- curve_and_object_namestr or tuple[str, str]
The
nameattribute of the curve and the object. If only one string is passed, then use the same name for both.- collectionbpy.types.Collection, str, None
If
None, then the Blender object is not linked. Otherwise, the Collection or name of collection to link the object to.
- Returns:
- bpy.types.Object
- Raises:
- ValueError
If there already exists a Blender curve or Blender object with the same name.
- ddg.blender.curve.create_curve(coordinates, name='Curve', type_='POLY', with_weights=False, cyclic=None, curve=None)[source]
Create a curve object from given coordinates.
- Parameters:
- coordinatesnumpy.ndarray of shape (n,i) or list of such numpy.ndarray
Array containing the coordinates of the splines.
A single 2D array means a single spline, a list of 2D arrays means a collection of splines.
iis 4 iftypeis “POLY” andwith_weightsis True. Otherwiseiis 3.nis the number of (control) points of each curve. Can be different for each curve.
- namestr (default=”Curve”)
Name of the new curve object.
- type_{“POLY”, “BEZIER”, “NURBS”}, (default=”POLY”)
Type of the created splines.
- with_weightsbool (default=False)
Specify whether weights are given.
This is only checked if
typeis “POLY”.If False, the weights will default to 1.0.
- cycliclist of bool (default=None)
Specify which splines are cyclic (defaulting to non-cyclic).
- curvebpy.types.Curve (default=None)
When given, the curve object to store the created data
- Returns:
- bpy.types.Curve
- ddg.blender.curve.add_curve(curvedata, name='Curve', location=(0.0, 0.0, 0.0), collection=None)[source]
Add a
bpy.types.Curveobject to a collection.- Parameters:
- curvedatabpy.types.Curve
Curve to add.
- namestr (default=”Curve”)
Name of the
bpy.types.Objectobject.- locationtriple of float (default=(0.0, 0.0, 0.0))
Location of the new
bpy.types.Objectobject.- collectionbpy.types.Collection, optional
Collection to add the curve to.
- Returns:
- bpy.types.Object
The new created object containing the curve.
Notes
The
collectionoption defaults tobpy.context.scene.collection.
- ddg.blender.curve.new_bezier_curve(ctr_pts, handles, closed=False, name='Curve', collection=None)[source]
Create a new bezier curve.
- Parameters:
- ctr_ptsIterable of triples of float
Control points of the bezier curve.
- handlesIterable of tuples of triples of float
Left and right handles at the control points.
- closedbool (default=False)
Specify whether curve is closed.
- namestr (default=”Curve”)
Name of the
bpy.types.Curveandbpy.types.Objectobject.- collectionbpy.types.Collection (default=None)
Collection the curve shall be linked to.
- Returns:
- bpy.types.Curve or (bpy.types.Object, bpy.types.Curve)
The created curve object if
collectionis None. Else the curve object and the object linked tocollectioncontaining it.
See also
- ddg.blender.curve.set_curve_properties(curve, **properties)[source]
Set curve properties for a Blender curve.
- Parameters:
- curvebpy.types.Object or bpy.types.Curve
Curve to set properties.
- **propertieskeyword arguments
Properties to set.
- ddg.blender.curve.create_circle_data(name='Circle', radius=1.0, location=(0.0, 0.0, 0.0), rotation=(0.0, 0.0, 0.0))[source]
Create a new bezier circle using standard
bpy.opsmethods.Creates a new
bpy.types.Curveof bezier type, wraps it in abpy.types.Objectand links this object tobpy.context.scene.collection.- Parameters:
- namestr (default=”Circle”)
Name of the created objects.
- radiusfloat (default=1.0)
Radius of the circle.
- locationtriple of float (default=(0.0, 0.0, 0.0))
Center of the
bpy.types.Objectobject.- rotationtriple of float (default=(0.0, 0.0, 0.0))
Rotation of the
bpy.types.Objectobject.
- Returns:
- bpy.types.Curve
- ddg.blender.curve.new_bezier_circle(trafo=array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), collection=None)[source]
Create a new bezier circle.
- Parameters:
- trafonumpy ndarray (default=numpy.eye(4))
Similarity transformation applied to the circle before adding.
- collectionbpy.types.Collection (default=None)
Collection the curve shall be linked to.
- Returns:
- bpy.types.Curve or (bpy.types.Object, bpy.types.Curve)
The created curve object if
collectionis None. Else the curve object and the object linked tocollectioncontaining it.
See also
Notes
The circle lies in the xy-plane before applying
trafo.The first control point will be
(1, 0, 0)before applyingtrafo.The circle is oriented in counterclockwise direction per default.
- ddg.blender.curve.new_bezier_arc(phi, nbr_ctr_pts='AUTO', trafo=array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), reverse=False, collection=None)[source]
Create a circular arc bezier curve.
- Parameters:
- phifloat
Angle of the circular arc.
- nbr_ctr_ptsint (default=”AUTO”)
Number of control points evenly spaced on the circular arc.
- trafonumpy.ndarray (default=numpy.eye(4))
Similarity transformation applied to the circle before adding.
- reversebool (default=False)
Reverse the orientation of added circle.
- collectionbpy.types.Collection, optional
Collection the curve shall be linked to.
- Returns:
- bpy.types.Curve or (bpy.types.Object, bpy.types.Curve)
The created curve object if
collectionis None. Else the curve object and the object linked tocollectioncontaining it.
See also
Notes
The circle lies in the xy-plane before applying
trafo.The first control point will be
(1,0,0)before applyingtrafo.The circle is oriented in counterclockwise direction per default.
- ddg.blender.curve.add_bezier_points(spline, ctr_pts, handles, new=False)[source]
Add control points to a bezier spline.
- Parameters:
- splinebpy.types.Spline
Spline to operate on.
- ctr_ptsIterable of triple of float
Control points to add.
- handlesIterable of tuple of triple of float
Left and right handles at the control points.
- newbool (default=False)
Is the spline newly created and contains no old data.
See also
Notes
This function CHANGES the given spline
spline.The control points and handles are paired by index.
The first item of a handle is the left handle and the second is the right.
- ddg.blender.curve.glue_bezier_points(spline, ctr_pts, handles)[source]
Add control points to a spline and match the handles.
- Parameters:
- splinebpy.types.Spline
Spline to operate on.
- ctr_ptsIterable of triple of float
Control points to add.
- handlesIterable of tuple of triple of float
Left and right handles at the control points.
See also
Notes
This function CHANGES the given spline
spline.The spline
splinehas to contain at least one control point.The function overrides the right handle of the last control point of
spline.handleshas to contain one more item thenctr_pts.
- ddg.blender.curve.add_circle_points(spline, nbr_ctr_pts=4, trafo=array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), reverse=False)[source]
Add a circle to a spline.
- Parameters:
- splinebpy.types.Spline
Spline to operate on.
- nbr_ctr_ptsint (default=4)
Number of control points evenly spaced on the circle.
- trafonumpy.ndarray (default=numpy.eye(4))
Similarity 4x4 transformation applied to the circle before adding.
- reversebool (default=False)
Reverse the orientation of added circle.
See also
Notes
This function CHANGES the given spline
spline.The circle lies in the xy-plane before applying
trafo.The first control point will be
(1,0,0)before applyingtrafo.The circle is oriented in counterclockwise direction per default.
- ddg.blender.curve.add_arc_points(spline, phi, nbr_ctr_pts='AUTO', trafo=array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), reverse=False)[source]
Add a circular arc to a spline.
- Parameters:
- splinebpy.types.Spline
Spline to operate on.
- phifloat
Angle of the circular arc.
- nbr_ctr_ptsint (default=”AUTO”)
Number of control points evenly spaced on the circular arc.
- trafonumpy.ndarray (default=numpy.eye(4))
Similarity transformation applied to the circle before adding.
- reversebool (default=False)
Reverse the orientation of added circle.
See also
Notes
This function CHANGES the given spline
spline.The circle lies in the xy-plane before applying
trafo.The first control point will be
(1,0,0)before applyingtrafo.The circle is oriented in counterclockwise direction per default.
- ddg.blender.curve.glue_circle_points(spline, nbr_ctr_pts=4, trafo=array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), reverse=False)[source]
Add a circle to a spline and match the handles.
- Parameters:
- splinebpy.types.Spline
Spline to operate on.
- nbr_ctr_ptsint (default=4)
Number of control points evenly spaced on the circel.
- trafonumpy ndarray (default=numpy.eye(4))
Similarity transformation applied to the circle before adding.
- reversebool (default=False)
Reverse the orientation of added circle.
See also
Notes
This function CHANGES the given spline
spline.The circle lies in the xy-plane before applying
trafo.The first control point will be
(1,0,0)before applyingtrafo.The circle is oriented in counterclockwise direction per default.
- ddg.blender.curve.glue_arc_points(spline, phi, nbr_ctr_pts='AUTO', trafo=array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), reverse=False)[source]
Add a circular arc to a spline and match the handles.
- Parameters:
- splinebpy.types.Spline
Spline to operate on.
- phifloat
Angle of the circular arc.
- nbr_ctr_ptsint (default=”AUTO”)
Number of control points evenly spaced on the circular arc.
- trafonumpy.ndarray (default=numpy.eye(4))
Similarity transformation applied to the circle before adding.
- reversebool (default=False)
Reverse the orientation of added circle.
See also
Notes
This function CHANGES the given spline
spline.The circle lies in the xy-plane before applying
trafo.The first control point will be
(1,0,0)before applyingtrafo.The circle is oriented in counterclockwise direction per default.
- ddg.blender.curve.clear(curves=None, do_unlink=True)[source]
Delete all given curves.
- Parameters:
- curvesIterable of bpy.type.Curve (default=True)
Curves to be deleted. If argument is not provided or None all curves will be deleted.
- do_unlinkbool (default=True)
Unlink curves from their scenes, if needed, before deleting them.