bnp.objects.obj

any2np(obj, dtype=np.float32, **kwargs) → np.ndarray

Convert any objects in Blender to np.ndarray at current frame.

Parameters:
  • obj – any object such as mathutils.Vector, mathutils.Matrix, bpy.types.Object, bpy.types.Mesh or str (name of an object in the Scene)
  • dtype – dtype
  • kwargs – other attrs
Returns:

np.ndarray

obj2np(obj: bpy.types.Object, dtype=np.float32, apply_modifier=False, frame=bpy.context.scene.frame_current, geo_type="position", is_local=False, as_homogeneous=False, mode="dynamic") → np.ndarray

Convert a bpy.types.Object which have a mesh to np.ndarray at current frame. If obj.data == bpy.types.Mesh, this method calls mesh2np or armature2np.

Parameters:
  • obj (bpy.types.Object) – object which have a mesh
  • dtype – dtype
  • apply_modifier (bool) – whether to apply modifiers
  • frame (int) – frame when you want to get matrices
  • geo_type (str) – “position” or “normal”. This is used when obj.data == bpy.types.Mesh.
  • is_local (bool) – whether to get positions as local coordinates. This is used when obj.data == bpy.types.Mesh.
  • as_homogeneous (bool) – whether to get positions as homogeneous or not. This is used when obj.data == bpy.types.Mesh.
  • mode (str) – “head”, “tail”, “length”, “rest”, “dynamic”. This is used when obj.data == bpy.types.Armature.
Returns:

np.ndarray

objname2np(obj_name: str, dtype=np.float32, apply_modifier=False, frame=bpy.context.scene.frame_current, geo_type="position", is_local=False, as_homogeneous=False, mode="dynamic") → np.ndarray

Get bpy.types.Object in the Scene which have a mesh and convert it to np.ndarray at current frame. This method calls obj2np.

Parameters:
  • obj_name (str) – object name in the Scene
  • dtype – dtype
  • apply_modifier (bool) – whether to apply modifiers
  • frame (int) – frame when you want to get matrices
  • geo_type (str) – “position” or “normal”. This is used when obj.data == bpy.types.Mesh.
  • is_local (bool) – whether to get positions as local coordinates. This is used when obj.data == bpy.types.Mesh.
  • as_homogeneous (bool) – whether to get positions as homogeneous or not. This is used when obj.data == bpy.types.Mesh.
  • mode (str) – “head”, “tail”, “length”, “rest”, “dynamic”. This is used when obj.data == bpy.types.Armature.
Returns:

np.ndarray