pub struct Object(/* private fields */);
Expand description
Implementations§
Source§impl Object
impl Object
pub fn new_camera( py: Python<'_>, location: [f32; 3], rotation: [f32; 3], ) -> BlResult<Self>
pub fn new_empty( py: Python<'_>, location: [f32; 3], rotation: [f32; 3], ) -> BlResult<Empty>
pub fn new_light( py: Python<'_>, type: LightType, location: [f32; 3], rotation: [f32; 3], ) -> BlResult<Self>
pub fn new_mesh( py: Python<'_>, location: [f32; 3], rotation: [f32; 3], ) -> BlResult<Self>
pub fn new_pointcloud( py: Python<'_>, location: [f32; 3], rotation: [f32; 3], ) -> BlResult<Self>
pub fn new_text( py: Python<'_>, location: [f32; 3], rotation: [f32; 3], ) -> BlResult<Self>
pub fn new_volume( py: Python<'_>, location: [f32; 3], rotation: [f32; 3], ) -> BlResult<Self>
pub fn from_name(name: &str) -> BlResult<Self>
pub fn from_active(py: Python<'_>) -> BlResult<Self>
pub fn set_active(&self, py: Python<'_>) -> BlResult<()>
pub fn delete(self, py: Python<'_>) -> BlResult<()>
pub fn object_type(&self, py: Python<'_>) -> BlResult<ObjectType>
pub fn translate( &mut self, py: Python<'_>, translation: [f32; 3], ) -> BlResult<()>
pub fn rotate_euler( &mut self, py: Python<'_>, rotation: [f32; 3], ) -> BlResult<()>
pub fn rotate_quaternion( &mut self, py: Python<'_>, rotation: Quaternion<f32>, ) -> BlResult<()>
pub fn resize(&mut self, py: Python<'_>, size: [f32; 3]) -> BlResult<()>
pub fn set_mode(&self, py: Python<'_>, mode: ObjectMode) -> BlResult<()>
pub fn set_origin( &self, py: Python<'_>, type: OriginType, center: OriginCenter, ) -> BlResult<()>
pub fn active_material(&self, py: Python<'_>) -> PyResult<Material>
pub fn set_active_material( &mut self, py: Python<'_>, value: &Material, ) -> PyResult<()>
pub fn active_material_index(&self, py: Python<'_>) -> PyResult<usize>
pub fn set_active_material_index( &mut self, py: Python<'_>, value: usize, ) -> PyResult<()>
pub fn active_shape_key<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn active_shape_key_index(&self, py: Python<'_>) -> PyResult<i16>
pub fn set_active_shape_key_index( &mut self, py: Python<'_>, value: i16, ) -> PyResult<()>
pub fn add_rest_position_attribute(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_add_rest_position_attribute( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn animation_data<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn animation_visualization<'py>( &'py self, py: Python<'py>, ) -> PyResult<&'py PyAny>
pub fn bound_box<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn collision<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn color(&self, py: Python<'_>) -> PyResult<[f32; 4]>
pub fn set_color(&mut self, py: Python<'_>, value: [f32; 4]) -> PyResult<()>
pub fn constraints<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn cycles<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn data<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn set_data(&mut self, py: Python<'_>, value: &PyAny) -> PyResult<()>
pub fn delta_location(&self, py: Python<'_>) -> PyResult<[f32; 3]>
pub fn set_delta_location( &mut self, py: Python<'_>, value: [f32; 3], ) -> PyResult<()>
pub fn delta_rotation_euler(&self, py: Python<'_>) -> PyResult<[f32; 3]>
pub fn set_delta_rotation_euler( &mut self, py: Python<'_>, value: [f32; 3], ) -> PyResult<()>
pub fn delta_rotation_quaternion(&self, py: Python<'_>) -> PyResult<[f32; 4]>
pub fn set_delta_rotation_quaternion( &mut self, py: Python<'_>, value: [f32; 4], ) -> PyResult<()>
pub fn delta_scale(&self, py: Python<'_>) -> PyResult<[f32; 3]>
pub fn set_delta_scale( &mut self, py: Python<'_>, value: [f32; 3], ) -> PyResult<()>
pub fn dimensions(&self, py: Python<'_>) -> PyResult<[f32; 3]>
pub fn set_dimensions( &mut self, py: Python<'_>, value: [f32; 3], ) -> PyResult<()>
pub fn display<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn display_bounds_type(&self, py: Python<'_>) -> PyResult<String>
pub fn set_display_bounds_type( &mut self, py: Python<'_>, value: &str, ) -> PyResult<()>
pub fn display_type(&self, py: Python<'_>) -> PyResult<String>
pub fn set_display_type(&mut self, py: Python<'_>, value: &str) -> PyResult<()>
pub fn empty_display_size(&self, py: Python<'_>) -> PyResult<f32>
pub fn set_empty_display_size( &mut self, py: Python<'_>, value: f32, ) -> PyResult<()>
pub fn empty_display_type<'py>( &'py self, py: Python<'py>, ) -> PyResult<&'py PyAny>
pub fn set_empty_display_type( &mut self, py: Python<'_>, value: &PyAny, ) -> PyResult<()>
pub fn empty_image_depth(&self, py: Python<'_>) -> PyResult<String>
pub fn set_empty_image_depth( &mut self, py: Python<'_>, value: &str, ) -> PyResult<()>
pub fn empty_image_offset<'py>( &'py self, py: Python<'py>, ) -> PyResult<&'py PyAny>
pub fn set_empty_image_offset( &mut self, py: Python<'_>, value: &PyAny, ) -> PyResult<()>
pub fn empty_image_side(&self, py: Python<'_>) -> PyResult<String>
pub fn set_empty_image_side( &mut self, py: Python<'_>, value: &str, ) -> PyResult<()>
pub fn face_maps<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn field<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn grease_pencil_modifiers<'py>( &'py self, py: Python<'py>, ) -> PyResult<&'py PyAny>
pub fn hide_render(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_hide_render(&mut self, py: Python<'_>, value: bool) -> PyResult<()>
pub fn hide_select(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_hide_select(&mut self, py: Python<'_>, value: bool) -> PyResult<()>
pub fn hide_viewport(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_hide_viewport(&mut self, py: Python<'_>, value: bool) -> PyResult<()>
pub fn image_user<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn instance_collection<'py>( &'py self, py: Python<'py>, ) -> PyResult<&'py PyAny>
pub fn set_instance_collection( &mut self, py: Python<'_>, value: &PyAny, ) -> PyResult<()>
pub fn instance_faces_scale(&self, py: Python<'_>) -> PyResult<f32>
pub fn set_instance_faces_scale( &mut self, py: Python<'_>, value: f32, ) -> PyResult<()>
pub fn instance_type(&self, py: Python<'_>) -> PyResult<String>
pub fn set_instance_type(&mut self, py: Python<'_>, value: &str) -> PyResult<()>
pub fn is_from_instancer(&self, py: Python<'_>) -> PyResult<bool>
pub fn is_from_set(&self, py: Python<'_>) -> PyResult<bool>
pub fn is_holdout(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_is_holdout(&mut self, py: Python<'_>, value: bool) -> PyResult<()>
pub fn is_instancer(&self, py: Python<'_>) -> PyResult<bool>
pub fn is_shadow_catcher(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_is_shadow_catcher( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn lightgroup(&self, py: Python<'_>) -> PyResult<String>
pub fn set_lightgroup(&mut self, py: Python<'_>, value: &str) -> PyResult<()>
pub fn lineart<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn location(&self, py: Python<'_>) -> PyResult<[f32; 3]>
pub fn set_location(&mut self, py: Python<'_>, value: [f32; 3]) -> PyResult<()>
pub fn lock_location<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn set_lock_location( &mut self, py: Python<'_>, value: &PyAny, ) -> PyResult<()>
pub fn lock_rotation<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn set_lock_rotation( &mut self, py: Python<'_>, value: &PyAny, ) -> PyResult<()>
pub fn lock_rotation_w<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn set_lock_rotation_w( &mut self, py: Python<'_>, value: &PyAny, ) -> PyResult<()>
pub fn lock_rotations_4d<'py>( &'py self, py: Python<'py>, ) -> PyResult<&'py PyAny>
pub fn set_lock_rotations_4d( &mut self, py: Python<'_>, value: &PyAny, ) -> PyResult<()>
pub fn lock_scale<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn set_lock_scale(&mut self, py: Python<'_>, value: &PyAny) -> PyResult<()>
pub fn material_slots<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn matrix_basis<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn set_matrix_basis( &mut self, py: Python<'_>, value: &PyAny, ) -> PyResult<()>
pub fn matrix_local<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn set_matrix_local( &mut self, py: Python<'_>, value: &PyAny, ) -> PyResult<()>
pub fn matrix_parent_inverse<'py>( &'py self, py: Python<'py>, ) -> PyResult<&'py PyAny>
pub fn set_matrix_parent_inverse( &mut self, py: Python<'_>, value: &PyAny, ) -> PyResult<()>
pub fn matrix_world<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn set_matrix_world( &mut self, py: Python<'_>, value: &PyAny, ) -> PyResult<()>
pub fn mode(&self, py: Python<'_>) -> PyResult<ContextMode>
pub fn modifiers(&self, py: Python<'_>) -> PyResult<ObjectModifiers>
pub fn motion_path<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn parent(&self, py: Python<'_>) -> PyResult<Self>
pub fn set_parent(&mut self, py: Python<'_>, value: &Self) -> PyResult<()>
pub fn parent_bone(&self, py: Python<'_>) -> PyResult<String>
pub fn set_parent_bone(&mut self, py: Python<'_>, value: &str) -> PyResult<()>
pub fn parent_type(&self, py: Python<'_>) -> PyResult<ObjectType>
pub fn parent_vertices<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn set_parent_vertices( &mut self, py: Python<'_>, value: &PyAny, ) -> PyResult<()>
pub fn particle_systems<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn pass_index(&self, py: Python<'_>) -> PyResult<i16>
pub fn set_pass_index(&mut self, py: Python<'_>, value: i16) -> PyResult<()>
pub fn pose<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn rigid_body<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn rigid_body_constraint<'py>( &'py self, py: Python<'py>, ) -> PyResult<&'py PyAny>
pub fn rotation_axis_angle(&self, py: Python<'_>) -> PyResult<[f32; 4]>
pub fn set_rotation_axis_angle( &mut self, py: Python<'_>, value: [f32; 4], ) -> PyResult<()>
pub fn rotation_euler(&self, py: Python<'_>) -> PyResult<[f32; 3]>
pub fn set_rotation_euler( &mut self, py: Python<'_>, value: [f32; 3], ) -> PyResult<()>
pub fn rotation_mode(&self, py: Python<'_>) -> PyResult<String>
pub fn set_rotation_mode(&mut self, py: Python<'_>, value: &str) -> PyResult<()>
pub fn rotation_quaternion(&self, py: Python<'_>) -> PyResult<[f32; 4]>
pub fn set_rotation_quaternion( &mut self, py: Python<'_>, value: [f32; 4], ) -> PyResult<()>
pub fn scale(&self, py: Python<'_>) -> PyResult<[f32; 3]>
pub fn set_scale(&mut self, py: Python<'_>, value: [f32; 3]) -> PyResult<()>
pub fn shader_effects<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn set_shader_effects( &mut self, py: Python<'_>, value: &PyAny, ) -> PyResult<()>
pub fn show_all_edges(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_show_all_edges( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn show_axis(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_show_axis(&mut self, py: Python<'_>, value: bool) -> PyResult<()>
pub fn show_bounds(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_show_bounds(&mut self, py: Python<'_>, value: bool) -> PyResult<()>
pub fn show_empty_image_only_axis_aligned( &self, py: Python<'_>, ) -> PyResult<bool>
pub fn set_show_empty_image_only_axis_aligned( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn show_empty_image_orthographic(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_show_empty_image_orthographic( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn show_empty_image_perspective(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_show_empty_image_perspective( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn show_in_front(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_show_in_front(&mut self, py: Python<'_>, value: bool) -> PyResult<()>
pub fn show_instancer_for_render(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_show_instancer_for_render( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn show_instancer_for_viewport(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_show_instancer_for_viewport( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn show_name(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_show_name(&mut self, py: Python<'_>, value: bool) -> PyResult<()>
pub fn show_only_shape_key(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_show_only_shape_key( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn show_texture_space(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_show_texture_space( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn show_transparent(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_show_transparent( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn show_wire(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_show_wire(&mut self, py: Python<'_>, value: bool) -> PyResult<()>
pub fn soft_body<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn track_axis<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn up_axis<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn use_camera_lock_parent(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_use_camera_lock_parent( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn use_dynamic_topology_sculpting(&self, py: Python<'_>) -> PyResult<bool>
pub fn use_empty_image_alpha(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_use_empty_image_alpha( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn use_grease_pencil_lights(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_use_grease_pencil_lights( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn use_instance_faces_scale(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_use_instance_faces_scale( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn use_instance_vertices_rotation(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_use_instance_vertices_rotation( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn use_mesh_mirror_x(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_use_mesh_mirror_x( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn use_mesh_mirror_y(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_use_mesh_mirror_y( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn use_mesh_mirror_z(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_use_mesh_mirror_z( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn use_shape_key_edit_mode(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_use_shape_key_edit_mode( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn use_simulation_cache(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_use_simulation_cache( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn vertex_groups<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
pub fn visible_camera(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_visible_camera( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn visible_diffuse(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_visible_diffuse( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn visible_glossy(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_visible_glossy( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn visible_shadow(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_visible_shadow( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn visible_transmission(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_visible_transmission( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn visible_volume_scatter(&self, py: Python<'_>) -> PyResult<bool>
pub fn set_visible_volume_scatter( &mut self, py: Python<'_>, value: bool, ) -> PyResult<()>
pub fn children(&self, py: Python<'_>) -> PyResult<Vec<Self>>
pub fn children_recursive(&self, py: Python<'_>) -> PyResult<Vec<Self>>
pub fn users_collection(&self, py: Python<'_>) -> PyResult<Vec<Collection>>
pub fn users_scene<'py>(&'py self, py: Python<'py>) -> PyResult<Vec<Scene<'py>>>
pub fn select_get( &self, py: Python<'_>, view_layer: Option<ViewLayer>, ) -> PyResult<bool>
pub fn select_set( &self, py: Python<'_>, state: bool, view_layer: Option<ViewLayer>, ) -> PyResult<()>
pub fn hide_get( &self, py: Python<'_>, view_layer: Option<ViewLayer>, ) -> PyResult<bool>
pub fn hide_set( &self, py: Python<'_>, state: bool, view_layer: Option<ViewLayer>, ) -> PyResult<()>
pub fn visible_get( &self, py: Python<'_>, view_layer: Option<ViewLayer>, viewport: Option<SpaceView3D<'_>>, ) -> PyResult<bool>
pub fn holdout_get( &self, py: Python<'_>, view_layer: Option<ViewLayer>, ) -> PyResult<bool>
pub fn indirect_only_get( &self, py: Python<'_>, view_layer: Option<ViewLayer>, ) -> PyResult<bool>
pub fn local_view_get( &self, py: Python<'_>, viewport: SpaceView3D<'_>, ) -> PyResult<bool>
pub fn local_view_set( &self, py: Python<'_>, viewport: SpaceView3D<'_>, state: bool, ) -> PyResult<()>
pub fn visible_in_viewport_get( &self, py: Python<'_>, viewport: SpaceView3D<'_>, ) -> PyResult<bool>
pub fn to_mesh(&self, py: Python<'_>) -> PyResult<Mesh>
pub fn to_mesh_clear(&self, py: Python<'_>) -> PyResult<()>
pub fn to_curve(&self, py: Python<'_>, apply_modifiers: bool) -> PyResult<Curve>
pub fn to_curve_clear(&self, py: Python<'_>) -> PyResult<()>
pub fn find_armature(&self, py: Python<'_>) -> PyResult<Self>
pub fn ray_cast( &self, py: Python<'_>, origin: [f32; 3], direction: [f32; 3], distance: f32, ) -> PyResult<(bool, [f32; 3], [f32; 3], i32)>
pub fn closest_point_on_mesh( &self, py: Python<'_>, origin: [f32; 3], distance: f32, ) -> PyResult<(bool, [f32; 3], [f32; 3], i32)>
pub fn is_modified( &self, py: Python<'_>, scene: Scene<'_>, settings: RenderVariant, ) -> PyResult<bool>
pub fn is_deform_modified( &self, py: Python<'_>, scene: Scene<'_>, settings: RenderVariant, ) -> PyResult<bool>
pub fn update_from_editmode(&self, py: Python<'_>) -> PyResult<bool>
pub fn cache_release(&self, py: Python<'_>) -> PyResult<()>
pub fn generate_gpencil_strokes( &self, py: Python<'_>, grease_pencil_object: &Self, use_collections: bool, scale_thickness: f32, sample: f32, ) -> PyResult<bool>
Source§impl Object
impl Object
pub fn new_mesh_primitive_circle( py: Python<'_>, vertices: u32, radius: f32, fill_type: &str, calc_uvs: bool, location: [f32; 3], rotation: [f32; 3], scale: [f32; 3], ) -> BlResult<Self>
pub fn new_mesh_primitive_cone( py: Python<'_>, vertices: u32, radius1: f32, radius2: f32, depth: f32, end_fill_type: &str, calc_uvs: bool, location: [f32; 3], rotation: [f32; 3], scale: [f32; 3], ) -> BlResult<Self>
pub fn new_mesh_primitive_cube( py: Python<'_>, size: f32, calc_uvs: bool, location: [f32; 3], rotation: [f32; 3], scale: [f32; 3], ) -> BlResult<Self>
pub fn new_mesh_primitive_cylinder( py: Python<'_>, vertices: u32, radius: f32, depth: f32, end_fill_type: &str, calc_uvs: bool, location: [f32; 3], rotation: [f32; 3], scale: [f32; 3], ) -> BlResult<Self>
pub fn new_mesh_primitive_grid( py: Python<'_>, x_subdivisions: u32, y_subdivisions: u32, size: f32, calc_uvs: bool, location: [f32; 3], rotation: [f32; 3], scale: [f32; 3], ) -> BlResult<Self>
pub fn new_mesh_primitive_ico_sphere( py: Python<'_>, subdivisions: u32, radius: f32, calc_uvs: bool, location: [f32; 3], rotation: [f32; 3], scale: [f32; 3], ) -> BlResult<Self>
pub fn new_mesh_primitive_monkey( py: Python<'_>, size: f32, calc_uvs: bool, location: [f32; 3], rotation: [f32; 3], scale: [f32; 3], ) -> BlResult<Self>
pub fn new_mesh_primitive_plane( py: Python<'_>, size: f32, calc_uvs: bool, location: [f32; 3], rotation: [f32; 3], scale: [f32; 3], ) -> BlResult<Self>
pub fn new_mesh_primitive_torus( py: Python<'_>, location: [f32; 3], rotation: [f32; 3], major_segments: u32, minor_segments: u32, mode: &str, major_radius: f32, minor_radius: f32, abso_major_rad: f32, abso_minor_rad: f32, generate_uvs: bool, ) -> BlResult<Self>
pub fn new_mesh_primitive_uv_sphere( py: Python<'_>, segments: u32, ring_count: u32, radius: f32, calc_uvs: bool, location: [f32; 3], rotation: [f32; 3], scale: [f32; 3], ) -> BlResult<Self>
Methods from Deref<Target = PyObject>§
Sourcepub fn as_ref<'py>(
&'py self,
_py: Python<'py>,
) -> &'py <T as PyTypeInfo>::AsRefTarget
pub fn as_ref<'py>( &'py self, _py: Python<'py>, ) -> &'py <T as PyTypeInfo>::AsRefTarget
Borrows a GIL-bound reference to the contained T
.
By binding to the GIL lifetime, this allows the GIL-bound reference to not require
Python<'py>
for any of its methods, which makes calling methods
on it more ergonomic.
For native types, this reference is &T
. For pyclasses, this is &PyCell<T>
.
Note that the lifetime of the returned reference is the shortest of &self
and
Python<'py>
.
Consider using Py::into_ref
instead if this poses a problem.
§Examples
Get access to &PyList
from Py<PyList>
:
Python::with_gil(|py| {
let list: Py<PyList> = PyList::empty(py).into();
let list: &PyList = list.as_ref(py);
assert_eq!(list.len(), 0);
});
Get access to &PyCell<MyClass>
from Py<MyClass>
:
#[pyclass]
struct MyClass {}
Python::with_gil(|py| {
let my_class: Py<MyClass> = Py::new(py, MyClass {}).unwrap();
let my_class_cell: &PyCell<MyClass> = my_class.as_ref(py);
assert!(my_class_cell.try_borrow().is_ok());
});
Sourcepub fn as_ptr(&self) -> *mut PyObject
pub fn as_ptr(&self) -> *mut PyObject
Returns the raw FFI pointer represented by self.
§Safety
Callers are responsible for ensuring that the pointer does not outlive self.
The reference is borrowed; callers should not decrease the reference count when they are finished with the pointer.
Sourcepub fn borrow<'py>(&'py self, py: Python<'py>) -> PyRef<'py, T>
pub fn borrow<'py>(&'py self, py: Python<'py>) -> PyRef<'py, T>
Immutably borrows the value T
.
This borrow lasts while the returned PyRef
exists.
Multiple immutable borrows can be taken out at the same time.
For frozen classes, the simpler get
is available.
Equivalent to self.as_ref(py).borrow()
-
see PyCell::borrow
.
§Examples
#[pyclass]
struct Foo {
inner: u8,
}
Python::with_gil(|py| -> PyResult<()> {
let foo: Py<Foo> = Py::new(py, Foo { inner: 73 })?;
let inner: &u8 = &foo.borrow(py).inner;
assert_eq!(*inner, 73);
Ok(())
})?;
§Panics
Panics if the value is currently mutably borrowed. For a non-panicking variant, use
try_borrow
.
Sourcepub fn borrow_mut<'py>(&'py self, py: Python<'py>) -> PyRefMut<'py, T>where
T: PyClass<Frozen = False>,
pub fn borrow_mut<'py>(&'py self, py: Python<'py>) -> PyRefMut<'py, T>where
T: PyClass<Frozen = False>,
Mutably borrows the value T
.
This borrow lasts while the returned PyRefMut
exists.
Equivalent to self.as_ref(py).borrow_mut()
-
see PyCell::borrow_mut
.
§Examples
#[pyclass]
struct Foo {
inner: u8,
}
Python::with_gil(|py| -> PyResult<()> {
let foo: Py<Foo> = Py::new(py, Foo { inner: 73 })?;
foo.borrow_mut(py).inner = 35;
assert_eq!(foo.borrow(py).inner, 35);
Ok(())
})?;
§Panics
Panics if the value is currently borrowed. For a non-panicking variant, use
try_borrow_mut
.
Sourcepub fn try_borrow<'py>(
&'py self,
py: Python<'py>,
) -> Result<PyRef<'py, T>, PyBorrowError>
pub fn try_borrow<'py>( &'py self, py: Python<'py>, ) -> Result<PyRef<'py, T>, PyBorrowError>
Attempts to immutably borrow the value T
, returning an error if the value is currently mutably borrowed.
The borrow lasts while the returned PyRef
exists.
This is the non-panicking variant of borrow
.
For frozen classes, the simpler get
is available.
Equivalent to self.as_ref(py).borrow_mut()
-
see PyCell::try_borrow
.
Sourcepub fn try_borrow_mut<'py>(
&'py self,
py: Python<'py>,
) -> Result<PyRefMut<'py, T>, PyBorrowMutError>where
T: PyClass<Frozen = False>,
pub fn try_borrow_mut<'py>(
&'py self,
py: Python<'py>,
) -> Result<PyRefMut<'py, T>, PyBorrowMutError>where
T: PyClass<Frozen = False>,
Attempts to mutably borrow the value T
, returning an error if the value is currently borrowed.
The borrow lasts while the returned PyRefMut
exists.
This is the non-panicking variant of borrow_mut
.
Equivalent to self.as_ref(py).try_borrow_mut()
-
see PyCell::try_borrow_mut
.
Sourcepub fn get(&self) -> &T
pub fn get(&self) -> &T
Provide an immutable borrow of the value T
without acquiring the GIL.
This is available if the class is frozen
and Sync
.
§Examples
use std::sync::atomic::{AtomicUsize, Ordering};
#[pyclass(frozen)]
struct FrozenCounter {
value: AtomicUsize,
}
let cell = Python::with_gil(|py| {
let counter = FrozenCounter { value: AtomicUsize::new(0) };
Py::new(py, counter).unwrap()
});
cell.get().value.fetch_add(1, Ordering::Relaxed);
Sourcepub fn is<U>(&self, o: &U) -> boolwhere
U: AsPyPointer,
pub fn is<U>(&self, o: &U) -> boolwhere
U: AsPyPointer,
Returns whether self
and other
point to the same object. To compare
the equality of two objects (the ==
operator), use eq
.
This is equivalent to the Python expression self is other
.
Sourcepub fn get_refcnt(&self, _py: Python<'_>) -> isize
pub fn get_refcnt(&self, _py: Python<'_>) -> isize
Gets the reference count of the ffi::PyObject
pointer.
Sourcepub fn clone_ref(&self, py: Python<'_>) -> Py<T>
pub fn clone_ref(&self, py: Python<'_>) -> Py<T>
Makes a clone of self
.
This creates another pointer to the same object, increasing its reference count.
You should prefer using this method over Clone
if you happen to be holding the GIL already.
§Examples
use pyo3::prelude::*;
use pyo3::types::PyDict;
Python::with_gil(|py| {
let first: Py<PyDict> = PyDict::new(py).into();
let second = Py::clone_ref(&first, py);
// Both point to the same object
assert!(first.is(&second));
});
Sourcepub fn is_none(&self, _py: Python<'_>) -> bool
pub fn is_none(&self, _py: Python<'_>) -> bool
Returns whether the object is considered to be None.
This is equivalent to the Python expression self is None
.
Sourcepub fn is_ellipsis(&self) -> bool
pub fn is_ellipsis(&self) -> bool
Returns whether the object is Ellipsis, e.g. ...
.
This is equivalent to the Python expression self is ...
.
Sourcepub fn is_true(&self, py: Python<'_>) -> Result<bool, PyErr>
pub fn is_true(&self, py: Python<'_>) -> Result<bool, PyErr>
Returns whether the object is considered to be true.
This is equivalent to the Python expression bool(self)
.
Sourcepub fn extract<'p, D>(&'p self, py: Python<'p>) -> Result<D, PyErr>where
D: FromPyObject<'p>,
pub fn extract<'p, D>(&'p self, py: Python<'p>) -> Result<D, PyErr>where
D: FromPyObject<'p>,
Extracts some type from the Python object.
This is a wrapper function around FromPyObject::extract()
.
Sourcepub fn getattr<N>(
&self,
py: Python<'_>,
attr_name: N,
) -> Result<Py<PyAny>, PyErr>
pub fn getattr<N>( &self, py: Python<'_>, attr_name: N, ) -> Result<Py<PyAny>, PyErr>
Retrieves an attribute value.
This is equivalent to the Python expression self.attr_name
.
If calling this method becomes performance-critical, the intern!
macro
can be used to intern attr_name
, thereby avoiding repeated temporary allocations of
Python strings.
§Example: intern!
ing the attribute name
#[pyfunction]
fn version(sys: Py<PyModule>, py: Python<'_>) -> PyResult<PyObject> {
sys.getattr(py, intern!(py, "version"))
}
Sourcepub fn setattr<N, V>(
&self,
py: Python<'_>,
attr_name: N,
value: V,
) -> Result<(), PyErr>
pub fn setattr<N, V>( &self, py: Python<'_>, attr_name: N, value: V, ) -> Result<(), PyErr>
Sets an attribute value.
This is equivalent to the Python expression self.attr_name = value
.
To avoid repeated temporary allocations of Python strings, the intern!
macro can be used to intern attr_name
.
§Example: intern!
ing the attribute name
#[pyfunction]
fn set_answer(ob: PyObject, py: Python<'_>) -> PyResult<()> {
ob.setattr(py, intern!(py, "answer"), 42)
}
Sourcepub fn call(
&self,
py: Python<'_>,
args: impl IntoPy<Py<PyTuple>>,
kwargs: Option<&PyDict>,
) -> Result<Py<PyAny>, PyErr>
pub fn call( &self, py: Python<'_>, args: impl IntoPy<Py<PyTuple>>, kwargs: Option<&PyDict>, ) -> Result<Py<PyAny>, PyErr>
Calls the object.
This is equivalent to the Python expression self(*args, **kwargs)
.
Sourcepub fn call1(
&self,
py: Python<'_>,
args: impl IntoPy<Py<PyTuple>>,
) -> Result<Py<PyAny>, PyErr>
pub fn call1( &self, py: Python<'_>, args: impl IntoPy<Py<PyTuple>>, ) -> Result<Py<PyAny>, PyErr>
Calls the object with only positional arguments.
This is equivalent to the Python expression self(*args)
.
Sourcepub fn call0(&self, py: Python<'_>) -> Result<Py<PyAny>, PyErr>
pub fn call0(&self, py: Python<'_>) -> Result<Py<PyAny>, PyErr>
Calls the object without arguments.
This is equivalent to the Python expression self()
.
Sourcepub fn call_method<N, A>(
&self,
py: Python<'_>,
name: N,
args: A,
kwargs: Option<&PyDict>,
) -> Result<Py<PyAny>, PyErr>
pub fn call_method<N, A>( &self, py: Python<'_>, name: N, args: A, kwargs: Option<&PyDict>, ) -> Result<Py<PyAny>, PyErr>
Calls a method on the object.
This is equivalent to the Python expression self.name(*args, **kwargs)
.
To avoid repeated temporary allocations of Python strings, the intern!
macro can be used to intern name
.
Sourcepub fn call_method1<N, A>(
&self,
py: Python<'_>,
name: N,
args: A,
) -> Result<Py<PyAny>, PyErr>
pub fn call_method1<N, A>( &self, py: Python<'_>, name: N, args: A, ) -> Result<Py<PyAny>, PyErr>
Calls a method on the object with only positional arguments.
This is equivalent to the Python expression self.name(*args)
.
To avoid repeated temporary allocations of Python strings, the intern!
macro can be used to intern name
.
Sourcepub fn call_method0<N>(
&self,
py: Python<'_>,
name: N,
) -> Result<Py<PyAny>, PyErr>
pub fn call_method0<N>( &self, py: Python<'_>, name: N, ) -> Result<Py<PyAny>, PyErr>
Calls a method on the object with no arguments.
This is equivalent to the Python expression self.name()
.
To avoid repeated temporary allocations of Python strings, the intern!
macro can be used to intern name
.
Sourcepub fn downcast<'p, T>(
&'p self,
py: Python<'p>,
) -> Result<&'p T, PyDowncastError<'p>>where
T: PyTryFrom<'p>,
pub fn downcast<'p, T>(
&'p self,
py: Python<'p>,
) -> Result<&'p T, PyDowncastError<'p>>where
T: PyTryFrom<'p>,
Downcast this PyObject
to a concrete Python type or pyclass.
Note that you can often avoid downcasting yourself by just specifying the desired type in function or method signatures. However, manual downcasting is sometimes necessary.
For extracting a Rust-only type, see Py::extract
.
§Example: Downcasting to a specific Python object
use pyo3::prelude::*;
use pyo3::types::{PyDict, PyList};
Python::with_gil(|py| {
let any: PyObject = PyDict::new(py).into();
assert!(any.downcast::<PyDict>(py).is_ok());
assert!(any.downcast::<PyList>(py).is_err());
});
§Example: Getting a reference to a pyclass
This is useful if you want to mutate a PyObject
that
might actually be a pyclass.
use pyo3::prelude::*;
#[pyclass]
struct Class {
i: i32,
}
Python::with_gil(|py| {
let class: PyObject = Py::new(py, Class { i: 0 }).unwrap().into_py(py);
let class_cell: &PyCell<Class> = class.downcast(py)?;
class_cell.borrow_mut().i += 1;
// Alternatively you can get a `PyRefMut` directly
let class_ref: PyRefMut<'_, Class> = class.extract(py)?;
assert_eq!(class_ref.i, 1);
Ok(())
})
Sourcepub unsafe fn downcast_unchecked<'p, T>(&'p self, py: Python<'p>) -> &'p Twhere
T: PyTryFrom<'p>,
pub unsafe fn downcast_unchecked<'p, T>(&'p self, py: Python<'p>) -> &'p Twhere
T: PyTryFrom<'p>,
Casts the PyObject to a concrete Python object type without checking validity.
§Safety
Callers must ensure that the type is valid or risk type confusion.
Sourcepub fn as_bytes<'a>(&'a self, _py: Python<'_>) -> &'a [u8] ⓘ
pub fn as_bytes<'a>(&'a self, _py: Python<'_>) -> &'a [u8] ⓘ
Gets the Python bytes as a byte slice. Because Python bytes are
immutable, the result may be used for as long as the reference to
self
is held, including when the GIL is released.
Sourcepub fn as_ref<'py>(&'py self, _py: Python<'py>) -> &'py PyIterator
pub fn as_ref<'py>(&'py self, _py: Python<'py>) -> &'py PyIterator
Borrows a GIL-bound reference to the PyIterator. By binding to the GIL lifetime, this
allows the GIL-bound reference to not require Python
for any of its methods.
Sourcepub fn as_ref<'py>(&'py self, _py: Python<'py>) -> &'py PyMapping
pub fn as_ref<'py>(&'py self, _py: Python<'py>) -> &'py PyMapping
Borrows a GIL-bound reference to the PyMapping. By binding to the GIL lifetime, this
allows the GIL-bound reference to not require Python
for any of its methods.
Sourcepub fn as_ref<'py>(&'py self, _py: Python<'py>) -> &'py PySequence
pub fn as_ref<'py>(&'py self, _py: Python<'py>) -> &'py PySequence
Borrows a GIL-bound reference to the PySequence. By binding to the GIL lifetime, this
allows the GIL-bound reference to not require Python
for any of its methods.
let seq: Py<PySequence> = PyList::empty(py).as_sequence().into();
let seq: &PySequence = seq.as_ref(py);
assert_eq!(seq.len().unwrap(), 0);
Trait Implementations§
Source§impl BpyID for Object
impl BpyID for Object
fn asset_data<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
fn is_embedded_data(&self, py: Python<'_>) -> PyResult<bool>
fn is_evaluated(&self, py: Python<'_>) -> PyResult<bool>
fn is_library_indirect(&self, py: Python<'_>) -> PyResult<bool>
fn is_missing(&self, py: Python<'_>) -> PyResult<bool>
fn is_runtime_data(&self, py: Python<'_>) -> PyResult<bool>
fn set_is_runtime_data(&mut self, py: Python<'_>, value: bool) -> PyResult<()>
fn library<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
fn library_weak_reference<'py>( &'py self, py: Python<'py>, ) -> PyResult<&'py PyAny>
fn name(&self, py: Python<'_>) -> PyResult<String>
fn set_name(&mut self, py: Python<'_>, value: &str) -> PyResult<()>
fn name_full(&self, py: Python<'_>) -> PyResult<String>
fn original<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
fn override_library<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
fn preview<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
fn tag(&self, py: Python<'_>) -> PyResult<bool>
fn set_tag(&mut self, py: Python<'_>, value: bool) -> PyResult<()>
fn use_extra_user(&self, py: Python<'_>) -> PyResult<bool>
fn set_use_extra_user(&mut self, py: Python<'_>, value: bool) -> PyResult<()>
fn use_fake_user(&self, py: Python<'_>) -> PyResult<bool>
fn set_use_fake_user(&mut self, py: Python<'_>, value: bool) -> PyResult<()>
fn users(&self, py: Python<'_>) -> PyResult<u32>
fn evaluated_get<'py>( &'py self, py: Python<'py>, depsgraph: &PyAny, ) -> PyResult<&'py PyAny>
fn copy<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
fn asset_mark(&self, py: Python<'_>) -> PyResult<()>
fn asset_clear(&self, py: Python<'_>) -> PyResult<()>
fn asset_generate_preview(&self, py: Python<'_>) -> PyResult<()>
fn override_create<'py>( &'py self, py: Python<'py>, remap_local_usages: bool, ) -> PyResult<&'py PyAny>
fn override_hierarchy_create<'py>( &'py self, py: Python<'py>, scene: Scene<'_>, view_layer: ViewLayer, reference: Option<impl BpyID>, do_fully_editable: bool, ) -> PyResult<&'py PyAny>
fn override_template_create(&self, py: Python<'_>) -> PyResult<()>
fn user_clear(&self, py: Python<'_>) -> PyResult<()>
fn user_remap(&self, py: Python<'_>, new_id: impl BpyID) -> PyResult<()>
fn make_local<'py>( &'py self, py: Python<'py>, clear_proxy: bool, ) -> PyResult<&'py PyAny>
fn user_of_id(&self, py: Python<'_>, id: impl BpyID) -> PyResult<u32>
fn animation_data_create<'py>( &'py self, py: Python<'py>, ) -> PyResult<&'py PyAny>
fn animation_data_clear(&self, py: Python<'_>) -> PyResult<()>
fn update_tag(&self, py: Python<'_>, refresh: HashSet<String>) -> PyResult<()>
fn preview_ensure<'py>(&'py self, py: Python<'py>) -> PyResult<&'py PyAny>
Source§impl FromPyObject<'_> for Object
impl FromPyObject<'_> for Object
Source§impl ToPyObject for Object
impl ToPyObject for Object
Source§impl TryFrom<&Object> for GreasePencil
impl TryFrom<&Object> for GreasePencil
Source§impl TryFrom<&Object> for LightProbe
impl TryFrom<&Object> for LightProbe
Source§impl TryFrom<&Object> for PointCloud
impl TryFrom<&Object> for PointCloud
Source§impl TryFrom<Object> for Empty
impl TryFrom<Object> for Empty
Source§impl TryFrom<Object> for GreasePencil
impl TryFrom<Object> for GreasePencil
Source§impl TryFrom<Object> for LightProbe
impl TryFrom<Object> for LightProbe
Source§impl TryFrom<Object> for PointCloud
impl TryFrom<Object> for PointCloud
Auto Trait Implementations§
impl Freeze for Object
impl !RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnwindSafe for Object
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.