ddg.blender package
Submodules
- ddg.blender.animation module
- ddg.blender.bmesh module
- ddg.blender.camera module
- ddg.blender.collection module
- ddg.blender.context module
- ddg.blender.curve module
curve()disconnected_curve()curve_as_mesh()curve_object()disconnected_curve_object()create_curve()add_curve()new_bezier_curve()set_curve_properties()create_circle_data()new_bezier_circle()new_bezier_arc()add_bezier_points()glue_bezier_points()add_circle_points()add_arc_points()glue_circle_points()glue_arc_points()clear()
- ddg.blender.freestyle module
- ddg.blender.light module
- ddg.blender.material module
- ddg.blender.mesh module
- ddg.blender.object module
- ddg.blender.props module
- ddg.blender.render module
ImageFormatExtensionImageFormatExtension.BMPImageFormatExtension.PNGImageFormatExtension.IRISImageFormatExtension.JPEGImageFormatExtension.JPEG2000ImageFormatExtension.TARGAImageFormatExtension.TARGA_RAWImageFormatExtension.DPXImageFormatExtension.CINEONImageFormatExtension.OPEN_EXRImageFormatExtension.OPEN_EXR_MULTILAYERImageFormatExtension.HDRImageFormatExtension.TIFFImageFormatExtension.WEBP
set_world_background()set_film_transparency()setup_eevee_renderer()setup_cycles_renderer()set_render_stamp_note()set_render_output_images()render_frame()render_animation()
- ddg.blender.scene module
Module contents
- ddg.blender.convert(convertible, name, /, material=None, collection=None, bounding_box=(inf, inf, inf), curve_sampling=(100, 0.1), surface_sampling=(30, 0.1), subspace_size=100, curve_radius=0.015, point_radius=0.05, icosphere_subdivision_steps=3)[source]
Convert pyddg objects, points, curves and meshes to Blender objects.
- Parameters:
- convertible
This must be an instance of:
- `ddg.geometry.Subspace` of dimension <= 2 - `ddg.geometry.Quadric` of dimension <= 2 - `ddg.geometry.QuadricIntersection` of dimension_complex == 1 - `ddg.geometry.spheres.QuadricSphere` of dimension <= 2 - `ddg.indexedfaceset.IndexedFaceSet` with coordinate attribute "co" - `ddg.halfedge.Surface` with coordinate attribute "co" - `ddg.nets.SmoothCurve` - `ddg.nets.SmoothNet` - `ddg.nets.DiscreteCurve` - `ddg.nets.DiscreteNet` - `ddg.nets.PointNet` - `ddg.nets.EmptyNet` - `ddg.nets.NetCollection` of smooth or discrete nets of the same dimension - `ddg.arrays.Points` - `ddg.arrays.Curve` - `ddg.arrays.CurveList` - `ddg.arrays.Mesh`
- namestr
Sets
bobj.nameandbobj.data.nameto this value.- materialstr or bpy.types.Material (default=None)
The resulting Blender object is assigned this material if it isn’t
None.- collectionbpy.types.Collection (default=None)
The resulting Blender object is linked to this collection if it isn’t
None.- bounding_boxarray_like of shape (3,) of type float
(default=(np.inf, np.inf, np.inf)) Bounding box of the resulting blender object.
- curve_samplingtuple of an int and a float
(default=_default_curve_sampling) Determines the sample number and stepsize for curves
- surface_samplingtuple of an int and a float
(default=_default_surface_sampling) Determines the sample number and stepsize for surfaces
- subspace_sizefloat
(default=_default_subspace_size) Determines the size of subspaces
- curve_radiusfloat (default=_default_curve_radius)
Radius for curves, set as
bobj.data.bevel_depth- point_radiusfloat (default=_default_point_radius)
Radius of the sphere representing points
- icosphere_subdivision_stepsint (default=_default_icosphere_subdivision_steps)
Number of subdivision steps for the icosphere representing points
- Returns:
- bpy.types.Object
The
dataattribute is of typebpy.types.Curveifconvertiblerepresents a curve curve andbpy.types.Meshrepresents a point, points or a mesh.
Examples
>>> import bpy >>> import numpy as np >>> import ddg
To display a 2-dimensional subspace
>>> plane = ddg.geometry.subspace_from_affine_points( ... (0, 0, 0), (1, 0, 0), (0, 1, 0) ... ) >>> ddg.blender.convert(plane, "plane") bpy.data.objects['plane']
To display a quadric
>>> two_sheeted_hyperboloid = ddg.geometry.Quadric(np.diag([1, 1, -1, 1])) >>> ddg.blender.convert(two_sheeted_hyperboloid, "two sheeted hyperboloid") bpy.data.objects['two sheeted hyperboloid']
To display a curve represented by a discrete curve
>>> discrete_curve = ddg.nets.DiscreteCurve( ... lambda t: (np.cos(t), np.sin(t), t), (-10, 10) ... ) >>> ddg.blender.convert(discrete_curve, "discrete_curve") bpy.data.objects['discrete_curve']
To display a surface represented by a discrete net
>>> discrete_net = ddg.nets.DiscreteNet( ... lambda u, v: (u, v, np.cos(v)), ((-10, 10), (-10, 10)) ... ) >>> ddg.blender.convert(discrete_net, "discrete_net") bpy.data.objects['discrete_net']
To create a curve object manually
>>> curve = ddg.arrays.Curve([(0, 0, 0), (1, 0, 0)], False) >>> curve_object = ddg.blender.convert(curve, "Curve") >>> type(curve_object.data) <class 'bpy.types.Curve'> >>> curve_object.data.name 'Curve' >>> curve_object.name 'Curve'
To create a mesh object manually
>>> mesh = ddg.arrays.Mesh([(0, 0, 0), (1, 0, 0), (0, 1, 0)], [(0, 1, 2)]) >>> mesh_object = ddg.blender.convert(mesh, "Triangle") >>> type(mesh_object.data) <class 'bpy_types.Mesh'> >>> mesh_object.data.name 'Triangle' >>> mesh_object.name 'Triangle'
To create non-manifold meshes manually
>>> non_manifold_edges = np.array([(0, 3)]) >>> non_manifold_mesh = ddg.arrays.Mesh( ... [(0, 0, 0), (1, 0, 0), (0, 1, 0), (1, 1, 0)], ... [(0, 1, 2)], ... non_manifold_edges, ... ) >>> non_manifold_mesh_object = ddg.blender.convert( ... non_manifold_mesh, "Triangle with extra edge" ... ) >>> [tuple(e.vertices) for e in non_manifold_mesh_object.data.edges] [(1, 2), (0, 1), (0, 2), (0, 3)]
It is usually unnecessary to create the input arrays manually. The functions in
ddg.arraysconvert mostddgobjects into suitable input forddg.blender.convert.
- ddg.blender.convert_qsic(intersection_object, name, material=None, collection=None, bounding_box=(inf, inf, inf), sampling=(100, 0.1), subspace_size=100, curve_radius=0.015, point_radius=0.05, icosphere_subdivision_steps=3)[source]
Converts a ddg.geometry.QuadricIntersection object into a blender object containing the intersection curve of the two quadrics
- Parameters:
- intersection_objectddg.geometry.QuadricIntersection
The intersection to depict with attributes Q1, Q2 representing the quadrics that span it
- namestr
Sets
bobj.nameandbobj.data.nameto this value.- materialstr or bpy.types.Material (default=None)
The resulting Blender object is assigned this material if it isn’t
None.- collectionbpy.types.Collection (default=None)
The resulting Blender object is linked to this collection if it isn’t
None.- bounding_boxarray_like of shape (3,) of type float
(default=(np.inf, np.inf, np.inf)) Bounding box of the resulting blender object.
- samplingtuple of an int and a float
(default=_default_curve_sampling) Determines the sample number and stepsize for quadrics used to intersect
- subspace_sizefloat
(default=_default_subspace_size) Determines the size of subspaces
- curve_radiusfloat (default=_default_curve_radius)
Sets the bevel depth of the intersection curve to this value
- point_radiusfloat (default=_default_point_radius)
Radius of the sphere representing points
- icosphere_subdivision_stepsint (default=_default_icosphere_subdivision_steps)
Number of subdivision steps for the icosphere representing points
- Returns:
- bpy.types.Object
- ddg.blender.edges(convertible, name, /, radius=0.015, material=None, collection=None, curve_sampling=(100, 0.1), surface_sampling=(30, 0.1), subspace_size=100)[source]
Convert mesh to edges as Blender objects.
- Parameters:
- convertible
Object convertible to a ddg.array.Mesh
- namestr
Sets
bobj.nameandbobj.data.nameto this value.- radiusfloat (default=_default_curve_radius)
Sets the radius of the edges as
bobj.data.bevel_depth- materialstr or bpy.types.Material (default=None)
The resulting Blender object is assigned this material if it isn’t
None.- collectionbpy.types.Collection (default=None)
The resulting Blender object is linked to this collection if it isn’t
None.- curve_samplingtuple of an int and a float
(default=_default_curve_sampling) Determines the sample number and stepsize for curves
- surface_samplingtuple of an int and a float
(default=_default_surface_sampling) Determines the sample number and stepsize for surfaces
- subspace_sizefloat
(default=_default_subspace_size) Determines the size of subspaces
- Returns:
- bpy.types.Object
The
dataattribute is of type bpy.types.Mesh` represents the edges.
Examples
>>> import bpy >>> import numpy as np >>> import ddg
>>> mesh = ddg.arrays.convert(ddg.halfedge.dodecahedron()) >>> bobj = ddg.blender.edges(mesh, "Edges of Dodecahedron", radius=0.1) >>> bobj.data.bevel_depth 0.1...
- ddg.blender.scatter(convertible, point_mesh, name, /, material=None, collection=None, curve_sampling=(100, 0.1), surface_sampling=(30, 0.1), subspace_size=100)[source]
Put a mesh at each vertex position of convertible.
- Parameters:
- convertible
This must be an instance of:
- `ddg.geometry.Subspace` of dimension <= 2 - `ddg.geometry.Quadric` of dimension <= 2 - `ddg.geometry.spheres.QuadricSphere` of dimension <= 2 - `ddg.indexedfaceset.IndexedFaceSet` with coordinate attribute "co" - `ddg.halfedge.Surface` with coordinate attribute "co" - `ddg.nets.SmoothCurve` - `ddg.nets.SmoothNet` - `ddg.nets.DiscreteCurve` - `ddg.nets.DiscreteNet` - `ddg.nets.PointNet` - `ddg.nets.EmptyNet` - `ddg.nets.NetCollection` of smooth or discrete nets of the same dimension - `ddg.arrays.Points` - `ddg.arrays.Curve` - `ddg.arrays.CurveList` - `ddg.arrays.Mesh`
- point_mesh: ddg.arrays.Mesh
A mesh that will be used for each point.
- namestr
Sets
bobj.nameandbobj.data.nameto this value.- materialstr or bpy.types.Material (default=None)
The resulting Blender object is assigned this material if it isn’t
None.- collectionbpy.types.Collection (default=None)
The resulting Blender object is linked to this collection if it isn’t
None.- curve_samplingtuple of an int and a float
(default=_default_curve_sampling) Determines the sample number and stepsize for curves
- surface_samplingtuple of an int and a float
(default=_default_surface_sampling) Determines the sample number and stepsize for surfaces
- subspace_sizefloat
(default=_default_subspace_size) Determines the size of subspaces
- Returns:
- bpy.types.Object
The
dataattribute is of type bpy.types.Mesh` represents a point or points.
- Raises:
- TypeError
If
convertiblehas the wrong type- ValueError
If convertible cannot be converted to point/points.
Examples
>>> import bpy >>> import numpy as np >>> import ddg >>> points = ddg.arrays.Points([(1, 2, 3), (3, 4, 5)]) >>> cube = ddg.arrays.Mesh( ... [ ... (0, 0, 0), ... (0, 0, 1), ... (0, 1, 0), ... (0, 1, 1), ... (1, 0, 0), ... (1, 0, 1), ... (1, 1, 0), ... (1, 1, 1), ... ], ... [ ... (0, 1, 2, 3), ... (4, 5, 6, 7), ... (0, 1, 4, 5), ... (2, 3, 6, 7), ... (0, 2, 4, 6), ... (1, 3, 5, 7), ... ], ... ) >>> ddg.blender.scatter(points, cube, "cube_points") bpy.data.objects['cube_points']
- ddg.blender.vertices(convertible, name, /, radius=0.05, icosphere_subdivision_steps=3, material=None, collection=None, curve_sampling=(100, 0.1), surface_sampling=(30, 0.1), subspace_size=100)[source]
Convert pyddg objects and points to points as Blender objects.
- Parameters:
- convertible
This must be an instance of:
- `ddg.geometry.Subspace` of dimension <= 2 - `ddg.geometry.Quadric` of dimension <= 2 - `ddg.geometry.spheres.QuadricSphere` of dimension <= 2 - `ddg.indexedfaceset.IndexedFaceSet` with coordinate attribute "co" - `ddg.halfedge.Surface` with coordinate attribute "co" - `ddg.nets.SmoothCurve` - `ddg.nets.SmoothNet` - `ddg.nets.DiscreteCurve` - `ddg.nets.DiscreteNet` - `ddg.nets.PointNet` - `ddg.nets.EmptyNet` - `ddg.nets.NetCollection` of smooth or discrete nets of the same dimension - `ddg.arrays.Points` - `ddg.arrays.Curve` - `ddg.arrays.CurveList` - `ddg.arrays.Mesh`
- namestr
Sets
bobj.nameandbobj.data.nameto this value.- radius: float (default=_default_point_radius)
Radius of the icosphere mesh.
- icosphere_subdivision_steps: int (default=_default_icosphere_subdivision_steps)
Subdivision steps for the icosphere mesh.
- materialstr or bpy.types.Material (default=None)
The resulting Blender object is assigned this material if it isn’t
None.- collectionbpy.types.Collection (default=None)
The resulting Blender object is linked to this collection if it isn’t
None.- curve_samplingtuple of an int and a float
(default=_default_curve_sampling) Determines the sample number and stepsize for curves
- surface_samplingtuple of an int and a float
(default=_default_surface_sampling) Determines the sample number and stepsize for surfaces
- subspace_sizefloat
(default=_default_subspace_size) Determines the size of subspaces
- Returns:
- bpy.types.Object
The
dataattribute is of type bpy.types.Mesh` represents a point or points.
- Raises:
- TypeError
If
convertiblehas the wrong type- ValueError
If convertible cannot be converted to point/points.
Examples
>>> import bpy >>> import numpy as np >>> import ddg
>>> point = ddg.arrays.Points((1, 2, 3)) >>> ddg.blender.vertices(point, "one_point") bpy.data.objects['one_point']
>>> points = ddg.arrays.Points([(1, 2, 3), (3, 4, 5)]) >>> ddg.blender.vertices(points, "two_points") bpy.data.objects['two_points']
To change the radius of the visualized points
>>> ddg.blender.vertices(points, "radius_points", radius=1.0) bpy.data.objects['radius_points']