ddg.visualization.blender.object module
Collection of utility functions dealing with Blender objects
Most of the methods come in two flavors add_ and create_
The create methods can be used to create objects containing meshes without linking it to a scene. The corresponding add methods create the objects containing the meshes first and also link it to the scene of the current context.
- ddg.visualization.blender.object.from_data(data, name, parent=None, matrix=array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), link=True, collection=None)[source]
Create an object containing a mesh, optionally it links the created objected to the given collection.
- Parameters:
- databpy.data
data to be wrapped in the object
- namestr
name of the newly created object
- parentbpy.types.Object (default=None)
parent of the newly created object
- matrixnp.ndarray, (default=np.eye(4))
local transformation of the object
- link: bool, (default=True)
True if object should be linked to collection
- collectionbpy.types.Collection, (default=None)
collection to link the object to, if not given or None, the object will be linked to bpy.context.scene.collection
- Returns
- ——-
- bpy.types.Object
object that was created with given data
- ddg.visualization.blender.object.add_joined(objects, name=None, keep_original=True, parent=None, matrix=array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), collection=None, remove_doubles=False)[source]
- ddg.visualization.blender.object.add_intersection_curve(ob1, ob2, name='IntersectionCurve', collection=None, convert_to_curve=True)[source]
Intersects to given objects. Warning: Your Edit mode needs to be set to select vertices, not edges or faces!
- Parameters:
- ob1: bpy.types.Object
First object to intersect
- ob2: bpy.types.Object
Second object to intersect
- name: str, optional
Name of the intersection object default = IntersectionCurve
- collection: bpy.types.Collection, optional
Collection to add the newly created object to default = collection of ob1
- convert_to_curve: Bool, optional
Determines whether the created object is converted to a curve default = True
- Returns:
- bpy.types.Curve of bpy.types.Object
- ddg.visualization.blender.object.set_matrix_world(bobj, matrix)[source]
Set the matrix_world of bobj to matrix.
- Parameters:
- mnumpy.ndarray or mathutils.Matrix
4x4 matrix.
- ddg.visualization.blender.object.matrix_to_obj_trafo(m)[source]
Given a matrix, return a function taking an object as parameter and applying the transformation corresponding to the matrix to it.
- Parameters:
- mnumpy.ndarray or mathutils.Matrix
4x4 matrix.
- ddg.visualization.blender.object.create_duplicate_linked(bobj, transformations, use_blender_operator=False, collection=None)[source]
Function creating linked duplicates of object and applying a transformation on each of them.
- Parameters:
- bobjbpy.types.Object
Blender object to duplicate.
- transformationslist
List of 4x4 matrices corresponding to the transformations.
- use_blender_operatorbool, default=False
False : simulate the duplicate linked using bpy. True : use the “duplicate” operator of blender.
- collectionbpy.types.Collection, optional
Collection in which to add the created duplicates. If not given, add to the collection of the original object.
- Returns:
- duplicateslist
A list of blender objects : the created linked duplicates.
- ddg.visualization.blender.object.look_at_point(obj, point, obj_front=(0, -1, 0), obj_up=(0, 0, 1), world_up=(0, 0, 1), distance=None)[source]
Rotates an object such that it looks at the given point.
If a distance is given the object is additionally translated along the viewing direction to match the given distance to the point. If no distance is given the camera remains at its position.
The default directions are set to fit the Suzanne object.
- Parameters:
- obj: bpy.types.Object
Blenders object to move.
- point: iterable of 3 floats
Point of reference to turn object.
- obj_front: iterable of 3 floats, default=(0,-1,0)
Viewing direction of the object in the object space. That is the direction in which the object is looking in the object space.
- obj_up: iterable of 3 floats, default=(0,0,1)
Up direction of the object in the object space. That is where the top is situed in the object space.
- world_up: iterable of 3 floats, default=(0,0,1)
Where the up direction should end up.
- distance: float, default=None
Distance the object should have from the point.
- Raises:
- ValueError
If the object is located a the target point.