def createRigidBody(self, **kwargs):

        shape_type = kwargs['shape_type']
        location = kwargs['location']
        rotation = kwargs['rotation']
        size = kwargs['size']
        dynamics_type = kwargs['dynamics_type']
        collision_group_number = kwargs.get('collision_group_number')
        collision_group_mask = kwargs.get('collision_group_mask')
        name = kwargs.get('name')
        name_e = kwargs.get('name_e')
        bone = kwargs.get('bone')

        friction = kwargs.get('friction')
        mass = kwargs.get('mass')
        angular_damping = kwargs.get('angular_damping')
        linear_damping = kwargs.get('linear_damping')
        bounce = kwargs.get('bounce')

        if shape_type == rigid_body.SHAPE_SPHERE:
            bpy.ops.mesh.primitive_uv_sphere_add(
                segments=16,
                ring_count=8,
                size=1,
                view_align=False,
                enter_editmode=False
                )
            size = mathutils.Vector([1,1,1]) * size[0]
            rigid_type = 'SPHERE'
            bpy.ops.object.shade_smooth()
        elif shape_type == rigid_body.SHAPE_BOX:
            bpy.ops.mesh.primitive_cube_add(
                view_align=False,
                enter_editmode=False
                )
            size = mathutils.Vector(size)
            rigid_type = 'BOX'
        elif shape_type == rigid_body.SHAPE_CAPSULE:
            obj = bpyutils.makeCapsule(radius=size[0], height=size[1])
            size = mathutils.Vector([1,1,1])
            rigid_type = 'CAPSULE'
            with bpyutils.select_object(obj):
                bpy.ops.object.shade_smooth()
        else:
            raise ValueError('Unknown shape type: %s'%(str(shape_type)))

        obj = bpy.context.active_object
        bpy.ops.rigidbody.object_add(type='ACTIVE')
        obj.location = location
        obj.rotation_mode = 'YXZ'
        obj.rotation_euler = rotation
        obj.scale = size
        obj.hide_render = True
        obj.mmd_type = 'RIGID_BODY'

        obj.mmd_rigid.shape = rigid_type
        obj.mmd_rigid.type = str(dynamics_type)
        obj.draw_type = 'WIRE'
        obj.show_wire = True

        with bpyutils.select_object(obj):
            bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)

        if collision_group_number is not None:
            obj.data.materials.append(RigidBodyMaterial.getMaterial(collision_group_number))
            obj.mmd_rigid.collision_group_number = collision_group_number
            obj.draw_type = 'SOLID'
            obj.show_transparent = True
        if collision_group_mask is not None:
            obj.mmd_rigid.collision_group_mask = collision_group_mask
        if name is not None:
            obj.name = name
            obj.mmd_rigid.name = name
        if name_e is not None:
            obj.mmd_rigid.name_e = name_e

        obj.rigid_body.collision_shape = rigid_type
        rb = obj.rigid_body
        if friction is not None:
            rb.friction = friction
        if mass is not None:
            rb.mass = mass
        if angular_damping is not None:
            rb.angular_damping = angular_damping
        if linear_damping is not None:
            rb.linear_damping = linear_damping
        if bounce:
            rb.restitution = bounce

        constraint = obj.constraints.new('CHILD_OF')
        constraint.target = self.armature()
        if bone is not None and bone != '':
            constraint.subtarget = bone
        constraint.name = 'mmd_tools_rigid_parent'
        constraint.mute = True

        obj.parent = self.rigidGroupObject()
        obj.select = False
        self.__root.mmd_root.is_built = False
        return obj
Create a object for MMD rigid body dynamics.
dataset/ETHPy150Open sugiany/blender_mmd_tools/mmd_tools/core/model.py/Model.createRigidBody