bpy_struct

subclasses — AOV, AOVs, ActionFCurves, ActionGroup, ActionGroups, ActionPoseMarkers, Addon, AddonPreferences, Addons, AlembicObjectPath, AlembicObjectPaths, AnimData, AnimDataDrivers, AnimViz, AnimVizMotionPaths, AnyType, Area, AreaSpaces, ArmatureBones, ArmatureConstraintTargets, ArmatureEditBones, AssetMetaData, AssetTag, AssetTags, Attribute, AttributeGroup, BakeSettings, BezierSplinePoint, BlendData, BlendDataActions, BlendDataArmatures, BlendDataBrushes, BlendDataCacheFiles, BlendDataCameras, BlendDataCollections, BlendDataCurves, BlendDataFonts, BlendDataGreasePencils, BlendDataImages, BlendDataLattices, BlendDataLibraries, BlendDataLights, BlendDataLineStyles, BlendDataMasks, BlendDataMaterials, BlendDataMeshes, BlendDataMetaBalls, BlendDataMovieClips, BlendDataNodeTrees, BlendDataObjects, BlendDataPaintCurves, BlendDataPalettes, BlendDataParticles, BlendDataProbes, BlendDataScenes, BlendDataScreens, BlendDataSounds, BlendDataSpeakers, BlendDataTexts, BlendDataTextures, BlendDataVolumes, BlendDataWindowManagers, BlendDataWorkSpaces, BlendDataWorlds, BlenderRNA, BoidRule, BoidSettings, BoidState, Bone, BoneGroup, BoneGroups, BoolAttributeValue, BrushCapabilities, BrushCapabilitiesImagePaint, BrushCapabilitiesSculpt, BrushCapabilitiesVertexPaint, BrushCapabilitiesWeightPaint, BrushGpencilSettings, ByteColorAttributeValue, CameraBackgroundImage, CameraBackgroundImages, CameraDOFSettings, CameraStereoData, ChannelDriverVariables, ChildParticle, ClothCollisionSettings, ClothSettings, ClothSolverResult, CollectionChildren, CollectionObjects, CollisionSettings, ColorManagedDisplaySettings, ColorManagedInputColorspaceSettings, ColorManagedSequencerColorspaceSettings, ColorManagedViewSettings, ColorMapping, ColorRamp, ColorRampElement, ColorRampElements, CompositorNodeOutputFileFileSlots, CompositorNodeOutputFileLayerSlots, ConsoleLine, Constraint, ConstraintTarget, ConstraintTargetBone, Context, CryptomatteEntry, CurveMap, CurveMapPoint, CurveMapPoints, CurveMapping, CurvePaintSettings, CurveProfile, CurveProfilePoint, CurveProfilePoints, CurveSplines, Depsgraph, DepsgraphObjectInstance, DepsgraphUpdate, DisplaySafeAreas, DopeSheet, Driver, DriverTarget, DriverVariable, DynamicPaintBrushSettings, DynamicPaintCanvasSettings, DynamicPaintSurface, DynamicPaintSurfaces, EditBone, EffectorWeights, EnumPropertyItem, Event, FCurve, FCurveKeyframePoints, FCurveModifiers, FCurveSample, FFmpegSettings, FModifier, FModifierEnvelopeControlPoint, FModifierEnvelopeControlPoints, FaceMap, FaceMaps, FieldSettings, FileBrowserFSMenuEntry, FileSelectEntry, FileSelectIDFilter, FileSelectParams, Float2AttributeValue, FloatAttributeValue, FloatColorAttributeValue, FloatVectorAttributeValue, FluidDomainSettings, FluidDomainVertexVelocity, FluidEffectorSettings, FluidFlowSettings, FreestyleLineSet, FreestyleModuleSettings, FreestyleModules, FreestyleSettings, Function, GPencilEditCurve, GPencilEditCurvePoint, GPencilFrame, GPencilFrames, GPencilInterpolateSettings, GPencilLayer, GPencilLayerMask, GPencilSculptGuide, GPencilSculptSettings, GPencilStroke, GPencilStrokePoint, GPencilStrokePoints, GPencilStrokes, GPencilTriangle, Gizmo, GizmoGroup, GizmoGroupProperties, GizmoProperties, Gizmos, GpencilModifier, GpencilVertexGroupElement, GreasePencilGrid, GreasePencilLayers, GreasePencilMaskLayers, Header, Histogram, ID, IDMaterials, IDOverrideLibrary, IDOverrideLibraryProperties, IDOverrideLibraryProperty, IDOverrideLibraryPropertyOperation, IDOverrideLibraryPropertyOperations, IDPropertyWrapPtr, IKParam, ImageFormatSettings, ImagePackedFile, ImagePreview, ImageUser, IntAttributeValue, KeyConfig, KeyConfigPreferences, KeyConfigurations, KeyMap, KeyMapItem, KeyMapItems, KeyMaps, Keyframe, KeyingSet, KeyingSetInfo, KeyingSetPath, KeyingSetPaths, KeyingSets, KeyingSetsAll, LatticePoint, LayerCollection, LayerObjects, LineStyleAlphaModifiers, LineStyleColorModifiers, LineStyleGeometryModifiers, LineStyleModifier, LineStyleTextureSlots, LineStyleThicknessModifiers, Linesets, LoopColors, Macro, MaskLayer, MaskLayers, MaskParent, MaskSpline, MaskSplinePoint, MaskSplinePointUW, MaskSplinePoints, MaskSplines, MaterialGPencilStyle, MaterialLineArt, MaterialSlot, Menu, MeshCacheVertexVelocity, MeshEdge, MeshEdges, MeshFaceMap, MeshFaceMapLayer, MeshFaceMapLayers, MeshLoop, MeshLoopColor, MeshLoopColorLayer, MeshLoopTriangle, MeshLoopTriangles, MeshLoops, MeshPaintMaskLayer, MeshPaintMaskProperty, MeshPolygon, MeshPolygonFloatProperty, MeshPolygonFloatPropertyLayer, MeshPolygonIntProperty, MeshPolygonIntPropertyLayer, MeshPolygonStringProperty, MeshPolygonStringPropertyLayer, MeshPolygons, MeshSkinVertex, MeshSkinVertexLayer, MeshStatVis, MeshUVLoop, MeshUVLoopLayer, MeshVertColor, MeshVertColorLayer, MeshVertex, MeshVertexFloatProperty, MeshVertexFloatPropertyLayer, MeshVertexIntProperty, MeshVertexIntPropertyLayer, MeshVertexStringProperty, MeshVertexStringPropertyLayer, MeshVertices, MetaBallElements, MetaElement, Modifier, MotionPath, MotionPathVert, MovieClipProxy, MovieClipScopes, MovieClipUser, MovieReconstructedCamera, MovieTracking, MovieTrackingCamera, MovieTrackingDopesheet, MovieTrackingMarker, MovieTrackingMarkers, MovieTrackingObject, MovieTrackingObjectPlaneTracks, MovieTrackingObjectTracks, MovieTrackingObjects, MovieTrackingPlaneMarker, MovieTrackingPlaneMarkers, MovieTrackingPlaneTrack, MovieTrackingPlaneTracks, MovieTrackingReconstructedCameras, MovieTrackingReconstruction, MovieTrackingSettings, MovieTrackingStabilization, MovieTrackingTrack, MovieTrackingTracks, NlaStrip, NlaStripFCurves, NlaStrips, NlaTrack, NlaTracks, Node, NodeInputs, NodeInstanceHash, NodeInternalSocketTemplate, NodeLink, NodeLinks, NodeOutputFileSlotFile, NodeOutputFileSlotLayer, NodeOutputs, NodeSocket, NodeSocketInterface, NodeTreeInputs, NodeTreeOutputs, NodeTreePath, Nodes, ObjectBase, ObjectConstraints, ObjectDisplay, ObjectGpencilModifiers, ObjectLineArt, ObjectModifiers, ObjectShaderFx, Operator, OperatorMacro, OperatorOptions, OperatorProperties, PackedFile, Paint, PaintToolSlot, PaletteColor, PaletteColors, Panel, Particle, ParticleBrush, ParticleDupliWeight, ParticleEdit, ParticleHairKey, ParticleKey, ParticleSettingsTextureSlots, ParticleSystem, ParticleSystems, ParticleTarget, PathCompare, PathCompareCollection, PointCache, PointCacheItem, PointCaches, PolygonFloatProperties, PolygonIntProperties, PolygonStringProperties, Pose, PoseBone, PoseBoneConstraints, Preferences, PreferencesEdit, PreferencesExperimental, PreferencesFilePaths, PreferencesInput, PreferencesKeymap, PreferencesSystem, PreferencesView, Property, PropertyGroup, PropertyGroupItem, Region, RegionView3D, RenderEngine, RenderLayer, RenderPass, RenderPasses, RenderResult, RenderSettings, RenderSlot, RenderSlots, RenderView, RenderViews, RigidBodyConstraint, RigidBodyObject, RigidBodyWorld, SPHFluidSettings, SceneDisplay, SceneEEVEE, SceneGpencil, SceneObjects, SceneRenderView, Scopes, Sequence, SequenceColorBalanceData, SequenceCrop, SequenceEditor, SequenceElement, SequenceElements, SequenceModifier, SequenceModifiers, SequenceProxy, SequenceTransform, SequencerToolSettings, SequencesMeta, SequencesTopLevel, ShaderFx, ShapeKey, ShapeKeyBezierPoint, ShapeKeyCurvePoint, ShapeKeyPoint, SoftBodySettings, Space, SpaceImageOverlay, SpaceNodeEditorPath, SpaceUVEditor, Spline, SplineBezierPoints, SplinePoint, SplinePoints, SpreadsheetContext, SpreadsheetContextPath, Stereo3dDisplay, Stereo3dFormat, StringAttributeValue, Struct, StudioLight, StudioLights, TexMapping, TexPaintSlot, TextBox, TextCharacterFormat, TextLine, TextureSlot, Theme, ThemeBoneColorSet, ThemeClipEditor, ThemeCollectionColor, ThemeConsole, ThemeDopeSheet, ThemeFileBrowser, ThemeFontStyle, ThemeGradientColors, ThemeGraphEditor, ThemeImageEditor, ThemeInfo, ThemeNLAEditor, ThemeNodeEditor, ThemeOutliner, ThemePanelColors, ThemePreferences, ThemeProperties, ThemeSequenceEditor, ThemeSpaceGeneric, ThemeSpaceGradient, ThemeSpaceListGeneric, ThemeSpreadsheet, ThemeStatusBar, ThemeStyle, ThemeTextEditor, ThemeTopBar, ThemeUserInterface, ThemeView3D, ThemeWidgetColors, ThemeWidgetStateColors, TimelineMarker, TimelineMarkers, Timer, ToolSettings, TransformOrientation, TransformOrientationSlot, UDIMTile, UDIMTiles, UILayout, UIList, UIPieMenu, UIPopover, UIPopupMenu, UVLoopLayers, UVProjector, UnifiedPaintSettings, UnitSettings, UnknownType, UserAssetLibrary, UserSolidLight, VertColors, VertexFloatProperties, VertexGroup, VertexGroupElement, VertexGroups, VertexIntProperties, VertexStringProperties, View2D, View3DCursor, View3DOverlay, View3DShading, ViewLayer, ViewLayerEEVEE, ViewLayers, VolumeDisplay, VolumeGrid, VolumeGrids, VolumeRender, WalkNavigation, Window, WorkSpaceTool, WorldLighting, WorldMistSettings, XrSessionSettings, XrSessionState, wmOwnerID, wmOwnerIDs, wmTools

class bpy.types.bpy_struct

built-in base class for all classes in bpy.types.

Note

Note that bpy.types.bpy_struct is not actually available from within Blender, it only exists for the purpose of documentation.

as_pointer()

Returns the memory address which holds a pointer to Blender’s internal data

Returns

int (memory address).

Return type

int

Note

This is intended only for advanced script writers who need to pass blender data to their own C/Python modules.

driver_add(path, index=- 1)

Adds driver(s) to the given property

Parameters
  • path (string) – path to the property to drive, analogous to the fcurve’s data path.

  • index (int) – array index of the property drive. Defaults to -1 for all indices or a single channel if the property is not an array.

Returns

The driver(s) added.

Return type

bpy.types.FCurve or list if index is -1 with an array property.

driver_remove(path, index=- 1)

Remove driver(s) from the given property

Parameters
  • path (string) – path to the property to drive, analogous to the fcurve’s data path.

  • index (int) – array index of the property drive. Defaults to -1 for all indices or a single channel if the property is not an array.

Returns

Success of driver removal.

Return type

boolean

get(key, default=None)

Returns the value of the custom property assigned to key or default when not found (matches Python’s dictionary function of the same name).

Parameters
  • key (string) – The key associated with the custom property.

  • default (Undefined) – Optional argument for the value to return if key is not found.

Note

Only the bpy.types.ID, bpy.types.Bone and bpy.types.PoseBone classes support custom properties.

is_property_hidden(property)

Check if a property is hidden.

Returns

True when the property is hidden.

Return type

boolean

is_property_overridable_library(property)

Check if a property is overridable.

Returns

True when the property is overridable.

Return type

boolean

is_property_readonly(property)

Check if a property is readonly.

Returns

True when the property is readonly (not writable).

Return type

boolean

is_property_set(property, ghost=True)

Check if a property is set, use for testing operator properties.

Parameters

ghost (boolean) –

Used for operators that re-run with previous settings. In this case the property is not marked as set, yet the value from the previous execution is used.

In rare cases you may want to set this option to false.

Returns

True when the property has been set.

Return type

boolean

Note

Properties defined at run-time store the values of the properties as custom-properties.

This method checks if the underlying data exists, causing the property to be considered set.

A common pattern for operators is to calculate a value for the properties that have not had their values explicitly set by the caller (where the caller could be a key-binding, menu-items or Python script for example).

In the case of executing operators multiple times, values are re-used from the previous execution.

For example: subdividing a mesh with a smooth value of 1.0 will keep using that value on subsequent calls to subdivision, unless the operator is called with that property set to a different value.

This behavior can be disabled using the SKIP_SAVE option when the property is declared (see: bpy.props).

The ghost argument allows detecting how a value from a previous execution is handled.

  • When true: The property is considered unset even if the value from a previous call is used.

  • When false: The existence of any values causes is_property_set to return true.

While this argument should typically be omitted, there are times when it’s important to know if a value is anything besides the default.

For example, the previous value may have been scaled by the scene’s unit scale. In this case scaling the value multiple times would cause problems, so the ghost argument should be false.

items()

Returns the items of this objects custom properties (matches Python’s dictionary function of the same name).

Returns

custom property key, value pairs.

Return type

list of key, value tuples

Note

Only the bpy.types.ID, bpy.types.Bone and bpy.types.PoseBone classes support custom properties.

keyframe_delete(data_path, index=- 1, frame=bpy.context.scene.frame_current, group='')

Remove a keyframe from this properties fcurve.

Parameters
  • data_path (string) – path to the property to remove a key, analogous to the fcurve’s data path.

  • index (int) – array index of the property to remove a key. Defaults to -1 removing all indices or a single channel if the property is not an array.

  • frame (float) – The frame on which the keyframe is deleted, defaulting to the current frame.

  • group (str) – The name of the group the F-Curve should be added to if it doesn’t exist yet.

Returns

Success of keyframe deletion.

Return type

boolean

keyframe_insert(data_path, index=- 1, frame=bpy.context.scene.frame_current, group='', options=set())

Insert a keyframe on the property given, adding fcurves and animation data when necessary.

Parameters
  • data_path (string) – path to the property to key, analogous to the fcurve’s data path.

  • index (int) – array index of the property to key. Defaults to -1 which will key all indices or a single channel if the property is not an array.

  • frame (float) – The frame on which the keyframe is inserted, defaulting to the current frame.

  • group (str) – The name of the group the F-Curve should be added to if it doesn’t exist yet.

  • options

    Optional set of flags:

    • INSERTKEY_NEEDED Only insert keyframes where they’re needed in the relevant F-Curves.

    • INSERTKEY_VISUAL Insert keyframes based on ‘visual transforms’.

    • INSERTKEY_XYZ_TO_RGB Color for newly added transformation F-Curves (Location, Rotation, Scale) is based on the transform axis.

    • INSERTKEY_REPLACE Only replace already existing keyframes.

    • INSERTKEY_AVAILABLE Only insert into already existing F-Curves.

    • INSERTKEY_CYCLE_AWARE Take cyclic extrapolation into account (Cycle-Aware Keying option).

Returns

Success of keyframe insertion.

Return type

boolean

This is the most simple example of inserting a keyframe from python.

import bpy

obj = bpy.context.object

# set the keyframe at frame 1
obj.location = (3.0, 4.0, 10.0)
obj.keyframe_insert(data_path="location", frame=1)

Note that when keying data paths which contain nested properties this must be done from the ID subclass, in this case the Armature rather than the bone.

import bpy
from bpy.props import (
    FloatProperty,
    PointerProperty,
)


# Define a nested property.
class MyPropGroup(bpy.types.PropertyGroup):
    nested: FloatProperty(name="Nested", default=0.0)


# Register it so its available for all bones.
bpy.utils.register_class(MyPropGroup)
bpy.types.Bone.my_prop = PointerProperty(
    type=MyPropGroup,
    name="MyProp",
)

# Get a bone.
obj = bpy.data.objects["Armature"]
arm = obj.data

# Set the keyframe at frame 1.
arm.bones["Bone"].my_prop.nested = 10
arm.keyframe_insert(
    data_path='bones["Bone"].my_prop.nested',
    frame=1,
    group="Nested Group",
)
keys()

Returns the keys of this objects custom properties (matches Python’s dictionary function of the same name).

Returns

custom property keys.

Return type

list of strings

Note

Only the bpy.types.ID, bpy.types.Bone and bpy.types.PoseBone classes support custom properties.

path_from_id(property='')

Returns the data path from the ID to this object (string).

Parameters

property (string) – Optional property name which can be used if the path is to a property of this object.

Returns

The path from bpy.types.bpy_struct.id_data to this struct and property (when given).

Return type

str

path_resolve(path, coerce=True)

Returns the property from the path, raise an exception when not found.

Parameters
  • path (string) – path which this property resolves.

  • coerce (boolean) – optional argument, when True, the property will be converted into its Python representation.

pop(key, default=None)

Remove and return the value of the custom property assigned to key or default when not found (matches Python’s dictionary function of the same name).

Parameters
  • key (string) – The key associated with the custom property.

  • default (Undefined) – Optional argument for the value to return if key is not found.

Note

Only the bpy.types.ID, bpy.types.Bone and bpy.types.PoseBone classes support custom properties.

property_overridable_library_set(property, overridable)

Define a property as overridable or not (only for custom properties!).

Returns

True when the overridable status of the property was successfully set.

Return type

boolean

property_unset(property)

Unset a property, will use default value afterward.

type_recast()

Return a new instance, this is needed because types such as textures can be changed at runtime.

Returns

a new instance of this object with the type initialized again.

Return type

subclass of bpy.types.bpy_struct

values()

Returns the values of this objects custom properties (matches Python’s dictionary function of the same name).

Returns

custom property values.

Return type

list

Note

Only the bpy.types.ID, bpy.types.Bone and bpy.types.PoseBone classes support custom properties.

id_data

The bpy.types.ID object this datablock is from or None, (not available for all data types)