Skip to content

Objects

3DBubble edited this page Oct 29, 2020 · 15 revisions

Objects

Selection and Object Management

create_object(name, col)

Created an empty object with the appropriate name. If col is provided, it will link the new object to that collection, otherwise it will link it to the active collection. Returns a reference to the newly created object.

Parameters :

  • name* (String | Reference) : Name of object
  • col (String | Reference) : Collection to be linked to

Returns : Object

copy_object(tocopy, col)

Copies the provided tocopy object and places the new copy in the col collection. If the destination collection is not provided then it will put the new copy in the selected collection.

Parameters :

  • tocopy* (String | Reference) : Object to be copied
  • col (String | Reference) : Collection to be linked to

Returns : Copied Object

Convenience functions :

  • duplicate_objects(tocopy, col)

get_active_object()

Returns a reference to the active object in the scene. This is the equivalent of calling bpy.context.active_object.

Returns : Object

Convenience functions :

  • active_object()
  • get_selected_object()
  • selected_object()
  • ao()

get_selected_objects()

Returns a list of all selected objects, contained within bpy.context.selected_objects.

Returns : Object List

Convenience functions :

  • so()
  • selected_objects()

get_all_objects()

Returns a list of all objects in the file, provided by bpy.data.objects.

Returns : Object List

Convenience functions :

  • get_list_of_objects()

select_object(ref, make_active)

Takes the provided ref object and makes sure it is selected. If make_active is given True, then the object being selected will be made the actively selected object.

Parameters :

  • ref* (String | Reference) : Name or reference of object
  • make_active (boolean) : If true then object being selected will be made the active object. True by default

select_all_objects(col)

Selects all objects in the scene. If col collection is provided, then it will only select the objects contained inside of that collection.

Parameters :

  • col (String | Reference) : Collection reference to select objects from

deselect_object(ref)

Deselects the provided ref object. Works only on single object

Parameters :

  • ref* (String | Reference) : Name or reference of object

deselect_all_objects()

Deselects every object that is currently selected.

delete_selected_objects()

Deletes all objects that are selected, the equivalent of calling bpy.ops.object.delete().

delete_object(ref)

Deletes the provided ref object. Will delete active object if ref not provided.

Parameters :

  • ref (String | Reference) : Name or reference of object

delete_objects(objlist)

Takes a list of objects (objlist), deletes all of them.

Parameters :

  • objlist* (List) : List of names or references of object

instance_object(ref, newname, col)

Creates an instance of the ref object, gives it the name newname and moves it to the col collection (if provided).

Parameters :

  • ref* (String | Reference) : Name or reference of object
  • newname (String) : Name of new object
  • col* (String | Reference) : Name or reference to collection

Returns : Object

get_object(ref)

Get the ref object (can also be string name) and return a reference to it. Works on single object. For multiple objects, use get_objects(). Will provide active object if reference not provided.

Parameters :

  • ref* (String | Reference) : Name or reference of object

Returns : Object

Convenience functions :

  • get_obj(ref)

get_objects(ref)

Get reference to the list of objects. Will return a list of objects even if single object reference is passed. ref can be None, object, string name, list of names or list of objects. Will provide list of all selected objects if reference is not provided.

Parameters :

  • ref (String | Reference | List) : Name or reference of object/s

Returns : Object List

Convenience functions :

  • get_objs(ref)

get_median_point_of_objects(objs)

Will return the vector location of median point from all the list of objects. objs should be first passed through get_objects() to reduce errors.

Parameters :

  • objs (List) : List of objects

Returns : Vector Location

object_exists(ref)

Returns a true or false value depending on if the ref object exists.

Parameters :

  • ref* (String | Reference) : Name or reference of object

Returns : boolean

rename_object(obj, newname)

Renames the obj object to newname.

Parameters :

  • obj* (String | Reference) : Name or reference of object
  • newname* (String) : New name

Returns : None | False

get_parent(ref)

Returns the parent of the ref object.

Parameters :

  • ref (String | Reference) : Name or reference of object

Returns : Object

get_children(ref)

Returns the children of the ref object.

Parameters :

  • ref (String | Reference) : Name or reference of object

Returns : Object list

set_parent(child, parent)

Sets parent to be the parent object of child.

Parameters :

  • child (String | Reference) : Name or reference of child object
  • parent (String | Reference) : Name or reference of parent object

clear_parent(ref, keep_location)

Clears the parent of the ref object. keep_location decides whether to maintain the global position of the object.

Parameters :

  • ref (String | Reference) : Name or reference of object
  • keep_location (boolean) : If object should retain its location. True by default

get_bounding_box(ref)

Returns the bounding box of an object.

Parameters :

  • ref (String | Reference) : Name or reference of object

Returns : Bounding box

get_bounding_box_corners(ref)

Returns the global coordinates of the corners of the bounding box of an object.

Parameters :

  • ref (String | Reference) : Name or reference of object

Returns : Vector list


Conversions

convert_to_mesh(ref)

Converts the given ref object to a mesh type.

Parameters :

  • ref* (String | Reference) : Name or reference of object

convert_to_grease_pencil(ref)

Converts the given ref object to a grease pencil type.

Parameters :

  • ref* (String | Reference) : Name or reference of object

convert_to_curve(ref)

Converts the given ref object to a curve type.

Parameters :

  • ref* (String | Reference) : Name or reference of object

Select All Types

select_all_meshes()

The equivalent of calling bpy.ops.object.select_by_type(type='MESH').

select_all_curves()

The equivalent of calling bpy.ops.object.select_by_type(type='CURVE').

select_all_surfaces()

The equivalent of calling bpy.ops.object.select_by_type(type='SURFACE').

select_all_metas()

The equivalent of calling bpy.ops.object.select_by_type(type='META').

select_all_text()

The equivalent of calling bpy.ops.object.select_by_type(type='FONT').

select_all_hair()

The equivalent of calling bpy.ops.object.select_by_type(type='HAIR').

select_all_point_clouds()

The equivalent of calling bpy.ops.object.select_by_type(type='POINTCLOUD').

select_all_volumes()

The equivalent of calling bpy.ops.object.select_by_type(type='VOLUME').

select_all_armatures()

The equivalent of calling bpy.ops.object.select_by_type(type='ARMATURE).

select_all_lattices()

The equivalent of calling bpy.ops.object.select_by_type(type='LATTICE').

select_all_empties()

The equivalent of calling bpy.ops.object.select_by_type(type='EMPTY').

select_all_grease_pencils()

The equivalent of calling bpy.ops.object.select_by_type(type='GPENCIL').

select_all_cameras()

The equivalent of calling bpy.ops.object.select_by_type(type='CAMERA').

select_all_speakers()

The equivalent of calling bpy.ops.object.select_by_type(type='SPEAKER').

select_all_light_probes()

The equivalent of calling bpy.ops.object.select_by_type(type='LIGHT_PROBE').

invert_selection()

The equivalent of calling bpy.ops.object.select_all(action='INVERT').

get_objects_with_modifiers()

Returns a list of all objects that have modifiers attached to them.

Returns : Object list

select_objects_with_modifiers()

Finds all objects with modifiers and sets their selection state to true.


Primitives - Meshes

create_plane()

Creates and returns a plane object.

Returns : Object

create_cube()

Creates and returns a cube object.

Returns : Object

create_circle()

Creates and returns a circle object.

Returns : Object

create_cylinder()

Creates and returns a cylinder object.

Returns : Object

create_uv_sphere()

Creates and returns a uv-sphere object.

Returns : Object

Convenience functions :

  • create_sphere()

create_ico_sphere()

Creates and returns an ico-sphere object.

Returns : Object

create_cone()

Creates and returns a cone object.

Returns : Object

create_torus()

Creates and returns a torus object.

Returns : Object

create_grid()

Creates and returns a grid object.

Returns : Object

create_suzanne()

Creates and returns a suzanne object.

Returns : Object

Convenience functions :

  • create_monkey()

Primitives - Curves

create_bezier_curve()

Creates and returns a bezier curve object.

Returns : Object

Convenience functions :

  • create_bezier

create_circle_curve()

Creates and returns a circle curve object.

Returns : Object

create_nurbs_curve()

Creates and returns a nurbs curve object.

Returns : Object

create_nurbs_circle()

Creates and returns a nurbs curve circle object.

Returns : Object

create_nurbs_path()

Creates and returns a nurbs curve path object.

Returns : Object

Convenience functions :

  • create_path()

Primitives - Surface

create_nurbs_curve_surface()

Creates and returns a nurbs curve surface object.

Returns : Object

Convenience functions :

  • create_curve_surface()

create_nurbs_circle_surface()

Creates and returns a nurbs circle surface object.

Returns : Object

Convenience functions :

  • create_circle_surface()

create_nurbs_surface()

Creates and returns a nurbs surface object.

Returns : Object

create_nurbs_cylinder_surface

Creates and returns a nurbs cylinder surface object.

Returns : Object

Convenience functions :

  • create_cylinder_surface

create_nurbs_sphere_surface()

Creates and returns a nurbs sphere surface object.

Returns : Object

Convenience functions:

  • create_sphere_surface

create_nurbs_torus_surface()

Creates and returns a nurbs torus surface object.

Returns : Object

Convenience functions :

  • create_torus_surface()

Primitives - Metaball

create_metaball()

Creates and returns a metaball object.

Returns : Object

create_metaball_capsule()

Creates and returns a metaball capsule object.

Returns : Object

create_metaball_plane()

Creates and returns a metaball plane object.

Returns : Object

create_metaball_ellipsoid()

Creates and returns a metaball ellipsoid object.

Returns : Object

create_metaball_cube()

Creates and returns a metaball cube object.

Returns : Object


Primitives - Text

create_text_object()

Creates and returns a text object.

Convenience functions:

  • create_text()

Shading

shade_object_smooth(ref)

Parameters :

  • ref* (String | Reference) : Name or reference of object

Convenience functions :

  • shade_smooth(ref)

shade_object_flat(ref)

Parameters :

  • ref* (String | Reference) : Name or reference of object

Convenience functions :

  • shade_flat(ref)

set_smooth_angle(ref, degrees)

Check auuto smooth option and set angle limit to degrees

Parameters :

  • ref* (String | Reference) : Name or reference of object
  • degrees (int) : auto smooth angle. 60 by default
Clone this wiki locally