This script demonstrates basic operations on object like creating new object, placing it into scene, selecting it and making it active.
import bpy
from mathutils import Matrix
scene = bpy.context.scene
# Create new lamp datablock
lamp_data = bpy.data.lamps.new(name="New Lamp", type='POINT')
# Create new object with our lamp datablock
lamp_object = bpy.data.objects.new(name="New Lamp", object_data=lamp_data)
# Link lamp object to the scene so it'll appear in this scene
scene.objects.link(lamp_object)
# Place lamp to a specified location
lamp_object.location = (5.0, 5.0, 5.0)
# And finally select it make active
lamp_object.select = True
scene.objects.active = lamp_object
base classes — bpy_struct, ID
Object datablock defining an object in a scene
Index of active material slot
Type : | int in [0, inf], default 0 |
---|
Current shape key index
Type : | int in [-32768, 32767], default 0 |
---|
Object’s bounding box in object-space coordinates, all values are -1.0 when not available
Type : | float array of 24 items in [-inf, inf], default (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (readonly) |
---|
Settings for using the object as a collider in physics simulation
Type : | CollisionSettings, (readonly) |
---|
Object color and alpha, used when faces have the ObColor mode enabled
Type : | float array of 4 items in [-inf, inf], default (0.0, 0.0, 0.0, 0.0) |
---|
Constraints affecting the transformation of the object
Type : | ObjectConstraints bpy_prop_collection of Constraint, (readonly) |
---|
Cycles visibility settings
Type : | CyclesVisibilitySettings, (readonly) |
---|
Extra translation added to the location of the object
Type : | float array of 3 items in [-inf, inf], default (0.0, 0.0, 0.0) |
---|
Extra rotation added to the rotation of the object (when using Euler rotations)
Type : | float array of 3 items in [-inf, inf], default (0.0, 0.0, 0.0) |
---|
Extra rotation added to the rotation of the object (when using Quaternion rotations)
Type : | float array of 4 items in [-inf, inf], default (1.0, 0.0, 0.0, 0.0) |
---|
Extra scaling added to the scale of the object
Type : | float array of 3 items in [-inf, inf], default (1.0, 1.0, 1.0) |
---|
Absolute bounding box dimensions of the object
Type : | float array of 3 items in [-inf, inf], default (0.0, 0.0, 0.0) |
---|
Object boundary display type
Type : | enum in [‘BOX’, ‘SPHERE’, ‘CYLINDER’, ‘CONE’], default ‘BOX’ |
---|
Maximum draw type to display object with in viewport
Type : | enum in [‘BOUNDS’, ‘WIRE’, ‘SOLID’, ‘TEXTURED’], default ‘BOUNDS’ |
---|
Scale the DupliFace objects
Type : | float in [0.001, 10000], default 0.0 |
---|
End frame for DupliFrames
Type : | int in [-300000, 300000], default 0 |
---|
Recurring frames to exclude from the Dupliframes
Type : | int in [0, 300000], default 0 |
---|
Number of frames to use between DupOff frames
Type : | int in [0, 300000], default 0 |
---|
Start frame for DupliFrames
Type : | int in [-300000, 300000], default 0 |
---|
Object duplis
Type : | bpy_prop_collection of DupliObject, (readonly) |
---|
If not None, object duplication method to use
Type : | enum in [‘NONE’, ‘FRAMES’, ‘VERTS’, ‘FACES’, ‘GROUP’], default ‘NONE’ |
---|
Size of display for empties in the viewport
Type : | float in [0.0001, 1000], default 0.0 |
---|
Viewport display style for empties
Type : | enum in [‘PLAIN_AXES’, ‘ARROWS’, ‘SINGLE_ARROW’, ‘CIRCLE’, ‘CUBE’, ‘SPHERE’, ‘CONE’, ‘IMAGE’], default ‘PLAIN_AXES’ |
---|
Origin offset distance
Type : | float array of 2 items in [-inf, inf], default (0.0, 0.0) |
---|
Settings for using the object as a field in physics simulation
Type : | FieldSettings, (readonly) |
---|
Game engine related settings for the object
Type : | GameObjectSettings, (readonly, never None) |
---|
Grease Pencil datablock
Type : | GreasePencil |
---|
Restrict visibility in the viewport
Type : | boolean, default False |
---|
Restrict renderability
Type : | boolean, default False |
---|
Restrict selection in the viewport
Type : | boolean, default False |
---|
Type : | boolean, default False, (readonly) |
---|
Layers the object is on
Type : | boolean array of 20 items, default (False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False) |
---|
3D local view layers the object is on
Type : | boolean array of 8 items, default (False, False, False, False, False, False, False, False), (readonly) |
---|
Location of the object
Type : | float array of 3 items in [-inf, inf], default (0.0, 0.0, 0.0) |
---|
Lock editing of location in the interface
Type : | boolean array of 3 items, default (False, False, False) |
---|
Lock editing of rotation in the interface
Type : | boolean array of 3 items, default (False, False, False) |
---|
Lock editing of ‘angle’ component of four-component rotations in the interface
Type : | boolean, default False |
---|
Lock editing of four component rotations by components (instead of as Eulers)
Type : | boolean, default False |
---|
Lock editing of scale in the interface
Type : | boolean array of 3 items, default (False, False, False) |
---|
Material slots in the object
Type : | bpy_prop_collection of MaterialSlot, (readonly) |
---|
Matrix access to location, rotation and scale (including deltas), before constraints and parenting are applied
Type : | float array of 16 items in [-inf, inf], default (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) |
---|
Parent relative transformation matrix
Type : | float array of 16 items in [-inf, inf], default (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) |
---|
Inverse of object’s parent matrix at time of parenting
Type : | float array of 16 items in [-inf, inf], default (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) |
---|
Worldspace transformation matrix
Type : | float array of 16 items in [-inf, inf], default (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) |
---|
Object interaction mode
Type : | enum in [‘OBJECT’, ‘EDIT’, ‘SCULPT’, ‘VERTEX_PAINT’, ‘WEIGHT_PAINT’, ‘TEXTURE_PAINT’, ‘PARTICLE_EDIT’, ‘POSE’], default ‘OBJECT’, (readonly) |
---|
Modifiers affecting the geometric data of the object
Type : | ObjectModifiers bpy_prop_collection of Modifier, (readonly) |
---|
Motion Path for this element
Type : | MotionPath, (readonly) |
---|
Name of parent bone in case of a bone parenting relation
Type : | string, default “”, (never None) |
---|
Type of parent relation
Type : | enum in [‘OBJECT’, ‘CURVE’, ‘KEY’, ‘ARMATURE’, ‘LATTICE’, ‘VERTEX’, ‘VERTEX_3’, ‘BONE’], default ‘OBJECT’ |
---|
Indices of vertices in case of a vertex parenting relation
Type : | int array of 3 items in [0, inf], default (0, 0, 0) |
---|
Particle systems emitted from the object
Type : | ParticleSystems bpy_prop_collection of ParticleSystem, (readonly) |
---|
Index number for the IndexOB render pass
Type : | int in [0, 32767], default 0 |
---|
Angle of Rotation for Axis-Angle rotation representation
Type : | float array of 4 items in [-inf, inf], default (0.0, 0.0, 1.0, 0.0) |
---|
Rotation in Eulers
Type : | float array of 3 items in [-inf, inf], default (0.0, 0.0, 0.0) |
---|
Type : | enum in [‘QUATERNION’, ‘XYZ’, ‘XZY’, ‘YXZ’, ‘YZX’, ‘ZXY’, ‘ZYX’, ‘AXIS_ANGLE’], default ‘QUATERNION’ |
---|
Rotation in Quaternions
Type : | float array of 4 items in [-inf, inf], default (1.0, 0.0, 0.0, 0.0) |
---|
Scaling of the object
Type : | float array of 3 items in [-inf, inf], default (1.0, 1.0, 1.0) |
---|
Object selection state
Type : | boolean, default False |
---|
Display the object’s origin and axes
Type : | boolean, default False |
---|
Display the object’s bounds
Type : | boolean, default False |
---|
Display the object’s name
Type : | boolean, default False |
---|
Always show the current Shape for this Object
Type : | boolean, default False |
---|
Display the object’s texture space
Type : | boolean, default False |
---|
Display material transparency in the object (unsupported for duplicator drawing)
Type : | boolean, default False |
---|
Add the object’s wireframe over solid drawing
Type : | boolean, default False |
---|
Make the object draw in front of others (unsupported for duplicator drawing)
Type : | boolean, default False |
---|
Delay in the parent relationship
Type : | float in [-300000, 300000], default 0.0 |
---|
Settings for soft body simulation
Type : | SoftBodySettings, (readonly) |
---|
Axis that points in ‘forward’ direction (applies to DupliFrame when parent ‘Follow’ is enabled)
Type : | enum in [‘POS_X’, ‘POS_Y’, ‘POS_Z’, ‘NEG_X’, ‘NEG_Y’, ‘NEG_Z’], default ‘POS_X’ |
---|
Type of Object
Type : | enum in [‘MESH’, ‘CURVE’, ‘SURFACE’, ‘META’, ‘FONT’, ‘ARMATURE’, ‘LATTICE’, ‘EMPTY’, ‘CAMERA’, ‘LAMP’, ‘SPEAKER’], default ‘EMPTY’, (readonly) |
---|
Axis that points in the upward direction (applies to DupliFrame when parent ‘Follow’ is enabled)
Type : | enum in [‘X’, ‘Y’, ‘Z’], default ‘X’ |
---|
Scale dupli based on face size
Type : | boolean, default False |
---|
Set dupliframes to use the current frame instead of parent curve’s evaluation time
Type : | boolean, default False |
---|
Rotate dupli according to vertex normal
Type : | boolean, default False |
---|
Apply shape keys in edit mode (for Meshes only)
Type : | boolean, default False |
---|
Create a delay in the parent relationship (beware: this isn’t renderfarm safe and may be invalid after jumping around the timeline)
Type : | boolean, default False |
---|
Vertex groups of the object
Type : | VertexGroups bpy_prop_collection of VertexGroup, (readonly) |
---|
All the children of this object (readonly)
The groups this object is in (readonly)
The scenes this object is in (readonly)
Create a Mesh datablock with modifiers applied
Parameters: |
|
---|---|
Returns: | Mesh created from object, remove it if it is only used for export |
Return type: |
Create a list of dupli objects for this object, needs to be freed manually with free_dupli_list to restore the objects real matrix and layers
Parameters: |
|
---|
Free the list of dupli objects
Find armature influencing this object as a parent or via a modifier
Returns: | Armature object influencing this object or NULL |
---|---|
Return type: | Object |
Add shape key to an object
Parameters: |
|
---|---|
Returns: | New shape keyblock |
Return type: |
Cast a ray onto in object space
Return (location, normal, index): | |
---|---|
location, The hit location of this ray cast, float array of 3 items in [-inf, inf] normal, The face normal at the ray cast hit location, float array of 3 items in [-inf, inf] index, The face index, -1 when no intersection is found, int in [-inf, inf] |
Find the nearest point on the object
Return (location, normal, index): | |
---|---|
location, The location on the object closest to the point, float array of 3 items in [-inf, inf] normal, The face normal at the closest point, float array of 3 items in [-inf, inf] index, The face index, -1 when no closest point is found, int in [-inf, inf] |
Determine if object is visible in a given scene
Returns: | Object visibility |
---|---|
Return type: | boolean |
Determine if this object is modified from the base mesh data
Parameters: | settings (enum in [‘PREVIEW’, ‘RENDER’]) – Modifier settings to apply
|
---|---|
Returns: | Object visibility |
Return type: | boolean |
Determine if this object is modified by a deformation from the base mesh data
Parameters: | settings (enum in [‘PREVIEW’, ‘RENDER’]) – Modifier settings to apply
|
---|---|
Returns: | Object visibility |
Return type: | boolean |
Returns a string for derived mesh data
Parameters: | type (enum in [‘SOURCE’, ‘DEFORM’, ‘FINAL’]) – Modifier settings to apply
|
---|---|
Returns: | result |
Return type: | string, (never None) |
Inherited Properties
Inherited Functions
|
References