blr/types/objects/
object.rs

1use crate::{
2    bpy,
3    enums::{
4        Alignment, ContextMode, LightType, ObjectMode, ObjectType, OriginCenter, OriginType,
5        RenderVariant,
6    },
7    result::Result,
8    scene::{Scene, SpaceView3D, ViewLayer},
9    types::{
10        collections::ObjectModifiers, BpyID, Collection, CollectionImpl, Curve, Empty, Material,
11        Mesh,
12    },
13};
14use derive_more::{Deref, DerefMut, Display};
15// TODO: Remove nalgebra dependency
16use nalgebra::Quaternion;
17use pyo3::{intern, PyAny, PyObject, Python};
18use pyo3_macros_more::bind_python;
19
20/// Wrapper for <https://docs.blender.org/api/latest/bpy.types.Object.html>
21#[repr(transparent)]
22#[derive(Clone, Debug, Deref, DerefMut, Display)]
23pub struct Object(PyObject);
24
25impl BpyID for Object {}
26
27impl Object {
28    pub fn new_camera(py: Python, location: [f32; 3], rotation: [f32; 3]) -> Result<Self> {
29        Self::force_object_mode(py)?;
30        bpy::ops::object::camera_add(
31            py,
32            false,
33            Alignment::World,
34            location,
35            rotation,
36            [1.0, 1.0, 1.0],
37        )?;
38        Ok(bpy::context::active_object(py)?)
39    }
40
41    pub fn new_empty(py: Python, location: [f32; 3], rotation: [f32; 3]) -> Result<Empty> {
42        Self::force_object_mode(py)?;
43        bpy::ops::object::empty_add(
44            py,
45            "PLAIN_AXES",
46            1.0,
47            Alignment::World,
48            location,
49            rotation,
50            [1.0, 1.0, 1.0],
51        )?;
52        Ok(Empty(bpy::context::active_object(py)?))
53    }
54
55    pub fn new_light(
56        py: Python,
57        r#type: LightType,
58        location: [f32; 3],
59        rotation: [f32; 3],
60    ) -> Result<Self> {
61        Self::force_object_mode(py)?;
62        bpy::ops::object::light_add(
63            py,
64            r#type,
65            1.0,
66            Alignment::World,
67            location,
68            rotation,
69            [1.0, 1.0, 1.0],
70        )?;
71        Ok(bpy::context::active_object(py)?)
72    }
73
74    pub fn new_mesh(py: Python, location: [f32; 3], rotation: [f32; 3]) -> Result<Self> {
75        Self::force_object_mode(py)?;
76        bpy::ops::object::add(
77            py,
78            1.0,
79            ObjectType::Mesh,
80            false,
81            Alignment::World,
82            location,
83            rotation,
84            [1.0, 1.0, 1.0],
85        )?;
86        Ok(bpy::context::active_object(py)?)
87    }
88
89    pub fn new_pointcloud(py: Python, location: [f32; 3], rotation: [f32; 3]) -> Result<Self> {
90        Self::force_object_mode(py)?;
91        bpy::ops::object::pointcloud_add(
92            py,
93            Alignment::World,
94            location,
95            rotation,
96            [1.0, 1.0, 1.0],
97        )?;
98        Ok(bpy::context::active_object(py)?)
99    }
100
101    pub fn new_text(py: Python, location: [f32; 3], rotation: [f32; 3]) -> Result<Self> {
102        Self::force_object_mode(py)?;
103        bpy::ops::object::text_add(
104            py,
105            1.0,
106            false,
107            Alignment::World,
108            location,
109            rotation,
110            [1.0, 1.0, 1.0],
111        )?;
112        Ok(bpy::context::active_object(py)?)
113    }
114
115    pub fn new_volume(py: Python, location: [f32; 3], rotation: [f32; 3]) -> Result<Self> {
116        Self::force_object_mode(py)?;
117        bpy::ops::object::volume_add(py, Alignment::World, location, rotation, [1.0, 1.0, 1.0])?;
118        Ok(bpy::context::active_object(py)?)
119    }
120
121    pub fn from_name(name: &str) -> Result<Self> {
122        Ok(Python::with_gil(|py| {
123            bpy::data::objects(py)?.get(py, name)
124        })?)
125    }
126
127    pub fn from_active(py: Python) -> Result<Self> {
128        Ok(bpy::context::active_object(py)?)
129    }
130
131    pub fn set_active(&self, py: Python) -> Result<()> {
132        bpy::context::view_layer(py)?.objects(py)?.setattr(
133            py,
134            intern!(py, "active"),
135            self.as_ref(py),
136        )?;
137        Ok(())
138    }
139
140    pub fn delete(self, py: Python) -> Result<()> {
141        let objects = bpy::data::objects(py)?;
142        Ok(objects.remove(py, &self, true, true, true)?)
143    }
144
145    pub fn object_type(&self, py: Python) -> Result<ObjectType> {
146        Ok(self.getattr(py, intern!(py, "type"))?.extract(py)?)
147    }
148
149    pub fn translate(&mut self, py: Python, translation: [f32; 3]) -> Result<()> {
150        let mut location = self.location(py)?;
151        location
152            .iter_mut()
153            .zip(translation)
154            .for_each(|(location, translation)| *location += translation);
155        Ok(self.set_location(py, location)?)
156    }
157
158    pub fn rotate_euler(&mut self, py: Python, rotation: [f32; 3]) -> Result<()> {
159        let mut orientation = self.rotation_euler(py)?;
160        orientation
161            .iter_mut()
162            .zip(rotation)
163            .for_each(|(orientation, rotation)| *orientation += rotation);
164        Ok(self.set_rotation_euler(py, orientation)?)
165    }
166
167    pub fn rotate_quaternion(&mut self, py: Python, rotation: Quaternion<f32>) -> Result<()> {
168        let orientation = self.rotation_quaternion(py)?;
169        let mut orientation = Quaternion::new(
170            orientation[0],
171            orientation[1],
172            orientation[2],
173            orientation[3],
174        );
175        orientation *= rotation;
176        Ok(self.set_rotation_quaternion(
177            py,
178            [orientation.w, orientation.i, orientation.j, orientation.k],
179        )?)
180    }
181
182    pub fn resize(&mut self, py: Python, size: [f32; 3]) -> Result<()> {
183        let mut scale = self.scale(py)?;
184        scale
185            .iter_mut()
186            .zip(size)
187            .for_each(|(scale, size)| *scale *= size);
188        Ok(self.set_scale(py, scale)?)
189    }
190
191    pub fn set_mode(&self, py: Python, mode: ObjectMode) -> Result<()> {
192        self.set_active(py)?;
193        Ok(bpy::ops::object::mode_set(py, mode, false)?)
194    }
195
196    pub fn set_origin(&self, py: Python, r#type: OriginType, center: OriginCenter) -> Result<()> {
197        self.set_active(py)?;
198        Ok(bpy::ops::object::origin_set(py, r#type, center)?)
199    }
200
201    pub(crate) fn force_object_mode(py: Python) -> Result<()> {
202        let obj = Self::from_active(py)?;
203        if !obj.is_none(py) {
204            obj.set_mode(py, ObjectMode::Object)?;
205        }
206        Ok(())
207    }
208
209    bind_python! { self.active_material => pub fn active_material(&self, py: Python) -> Result<Material> }
210    bind_python! { self.active_material = pub fn set_active_material(&mut self, py: Python, value: &Material) }
211    bind_python! { self.active_material_index => pub fn active_material_index(&self, py: Python) -> Result<usize> }
212    bind_python! { self.active_material_index = pub fn set_active_material_index(&mut self, py: Python, value: usize) }
213    bind_python! { self.active_shape_key => pub fn active_shape_key<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
214    bind_python! { self.active_shape_key_index => pub fn active_shape_key_index(&self, py: Python) -> Result<i16> }
215    bind_python! { self.active_shape_key_index = pub fn set_active_shape_key_index(&mut self, py: Python, value: i16) }
216    bind_python! { self.add_rest_position_attribute => pub fn add_rest_position_attribute(&self, py: Python) -> Result<bool> }
217    bind_python! { self.add_rest_position_attribute = pub fn set_add_rest_position_attribute(&mut self, py: Python, value: bool) }
218    bind_python! { self.animation_data => pub fn animation_data<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
219    bind_python! { self.animation_visualization => pub fn animation_visualization<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
220    bind_python! { self.bound_box => pub fn bound_box<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
221    bind_python! { self.collision => pub fn collision<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
222    bind_python! { self.color => pub fn color(&self, py: Python) -> Result<[f32; 4]> }
223    bind_python! { self.color = pub fn set_color(&mut self, py: Python, value: [f32; 4]) }
224    bind_python! { self.constraints => pub fn constraints<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
225    bind_python! { self.cycles => pub fn cycles<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
226    bind_python! { self.data => pub fn data<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
227    bind_python! { self.data = pub fn set_data(&mut self, py: Python, value: &PyAny) }
228    bind_python! { self.delta_location => pub fn delta_location(&self, py: Python) -> Result<[f32; 3]> }
229    bind_python! { self.delta_location = pub fn set_delta_location(&mut self, py: Python, value: [f32; 3]) }
230    bind_python! { self.delta_rotation_euler => pub fn delta_rotation_euler(&self, py: Python) -> Result<[f32; 3]> }
231    bind_python! { self.delta_rotation_euler = pub fn set_delta_rotation_euler(&mut self, py: Python, value: [f32; 3]) }
232    bind_python! { self.delta_rotation_quaternion => pub fn delta_rotation_quaternion(&self, py: Python) -> Result<[f32; 4]> }
233    bind_python! { self.delta_rotation_quaternion = pub fn set_delta_rotation_quaternion(&mut self, py: Python, value: [f32; 4]) }
234    bind_python! { self.delta_scale => pub fn delta_scale(&self, py: Python) -> Result<[f32; 3]> }
235    bind_python! { self.delta_scale = pub fn set_delta_scale(&mut self, py: Python, value: [f32; 3]) }
236    bind_python! { self.dimensions => pub fn dimensions(&self, py: Python) -> Result<[f32; 3]> }
237    bind_python! { self.dimensions = pub fn set_dimensions(&mut self, py: Python, value: [f32; 3]) }
238    bind_python! { self.display => pub fn display<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
239    bind_python! { self.display_bounds_type => pub fn display_bounds_type(&self, py: Python) -> Result<String> }
240    bind_python! { self.display_bounds_type = pub fn set_display_bounds_type(&mut self, py: Python, value: &str) }
241    bind_python! { self.display_type => pub fn display_type(&self, py: Python) -> Result<String> }
242    bind_python! { self.display_type = pub fn set_display_type(&mut self, py: Python, value: &str) }
243    bind_python! { self.empty_display_size => pub fn empty_display_size(&self, py: Python) -> Result<f32> }
244    bind_python! { self.empty_display_size = pub fn set_empty_display_size(&mut self, py: Python, value: f32) }
245    bind_python! { self.empty_display_type => pub fn empty_display_type<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
246    bind_python! { self.empty_display_type = pub fn set_empty_display_type(&mut self, py: Python, value: &PyAny) }
247    bind_python! { self.empty_image_depth => pub fn empty_image_depth(&self, py: Python) -> Result<String> }
248    bind_python! { self.empty_image_depth = pub fn set_empty_image_depth(&mut self, py: Python, value: &str) }
249    bind_python! { self.empty_image_offset => pub fn empty_image_offset<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
250    bind_python! { self.empty_image_offset = pub fn set_empty_image_offset(&mut self, py: Python, value: &PyAny) }
251    bind_python! { self.empty_image_side => pub fn empty_image_side(&self, py: Python) -> Result<String> }
252    bind_python! { self.empty_image_side = pub fn set_empty_image_side(&mut self, py: Python, value: &str) }
253    bind_python! { self.face_maps => pub fn face_maps<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
254    bind_python! { self.field => pub fn field<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
255    bind_python! { self.grease_pencil_modifiers => pub fn grease_pencil_modifiers<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
256    bind_python! { self.hide_render => pub fn hide_render(&self, py: Python) -> Result<bool> }
257    bind_python! { self.hide_render = pub fn set_hide_render(&mut self, py: Python, value: bool) }
258    bind_python! { self.hide_select => pub fn hide_select(&self, py: Python) -> Result<bool> }
259    bind_python! { self.hide_select = pub fn set_hide_select(&mut self, py: Python, value: bool) }
260    bind_python! { self.hide_viewport => pub fn hide_viewport(&self, py: Python) -> Result<bool> }
261    bind_python! { self.hide_viewport = pub fn set_hide_viewport(&mut self, py: Python, value: bool) }
262    bind_python! { self.image_user => pub fn image_user<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
263    bind_python! { self.instance_collection => pub fn instance_collection<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
264    bind_python! { self.instance_collection = pub fn set_instance_collection(&mut self, py: Python, value: &PyAny) }
265    bind_python! { self.instance_faces_scale => pub fn instance_faces_scale(&self, py: Python) -> Result<f32> }
266    bind_python! { self.instance_faces_scale = pub fn set_instance_faces_scale(&mut self, py: Python, value: f32) }
267    bind_python! { self.instance_type => pub fn instance_type(&self, py: Python) -> Result<String> }
268    bind_python! { self.instance_type = pub fn set_instance_type(&mut self, py: Python, value: &str) }
269    bind_python! { self.is_from_instancer => pub fn is_from_instancer(&self, py: Python) -> Result<bool> }
270    bind_python! { self.is_from_set => pub fn is_from_set(&self, py: Python) -> Result<bool> }
271    bind_python! { self.is_holdout => pub fn is_holdout(&self, py: Python) -> Result<bool> }
272    bind_python! { self.is_holdout = pub fn set_is_holdout(&mut self, py: Python, value: bool) }
273    bind_python! { self.is_instancer => pub fn is_instancer(&self, py: Python) -> Result<bool> }
274    bind_python! { self.is_shadow_catcher => pub fn is_shadow_catcher(&self, py: Python) -> Result<bool> }
275    bind_python! { self.is_shadow_catcher = pub fn set_is_shadow_catcher(&mut self, py: Python, value: bool) }
276    bind_python! { self.lightgroup => pub fn lightgroup(&self, py: Python) -> Result<String> }
277    bind_python! { self.lightgroup = pub fn set_lightgroup(&mut self, py: Python, value: &str) }
278    bind_python! { self.lineart => pub fn lineart<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
279    bind_python! { self.location => pub fn location(&self, py: Python) -> Result<[f32; 3]> }
280    bind_python! { self.location = pub fn set_location(&mut self, py: Python, value: [f32; 3]) }
281    bind_python! { self.lock_location => pub fn lock_location<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
282    bind_python! { self.lock_location = pub fn set_lock_location(&mut self, py: Python, value: &PyAny) }
283    bind_python! { self.lock_rotation => pub fn lock_rotation<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
284    bind_python! { self.lock_rotation = pub fn set_lock_rotation(&mut self, py: Python, value: &PyAny) }
285    bind_python! { self.lock_rotation_w => pub fn lock_rotation_w<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
286    bind_python! { self.lock_rotation_w = pub fn set_lock_rotation_w(&mut self, py: Python, value: &PyAny) }
287    bind_python! { self.lock_rotations_4d => pub fn lock_rotations_4d<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
288    bind_python! { self.lock_rotations_4d = pub fn set_lock_rotations_4d(&mut self, py: Python, value: &PyAny) }
289    bind_python! { self.lock_scale => pub fn lock_scale<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
290    bind_python! { self.lock_scale = pub fn set_lock_scale(&mut self, py: Python, value: &PyAny) }
291    bind_python! { self.material_slots => pub fn material_slots<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
292    bind_python! { self.matrix_basis => pub fn matrix_basis<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
293    bind_python! { self.matrix_basis = pub fn set_matrix_basis(&mut self, py: Python, value: &PyAny) }
294    bind_python! { self.matrix_local => pub fn matrix_local<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
295    bind_python! { self.matrix_local = pub fn set_matrix_local(&mut self, py: Python, value: &PyAny) }
296    bind_python! { self.matrix_parent_inverse => pub fn matrix_parent_inverse<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
297    bind_python! { self.matrix_parent_inverse = pub fn set_matrix_parent_inverse(&mut self, py: Python, value: &PyAny) }
298    bind_python! { self.matrix_world => pub fn matrix_world<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
299    bind_python! { self.matrix_world = pub fn set_matrix_world(&mut self, py: Python, value: &PyAny) }
300    bind_python! { self.mode => pub fn mode(&self, py: Python) -> Result<ContextMode> }
301    bind_python! { self.modifiers => pub fn modifiers(&self, py: Python) -> Result<ObjectModifiers> }
302    bind_python! { self.motion_path => pub fn motion_path<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
303    bind_python! { self.parent => pub fn parent(&self, py: Python) -> Result<Self> }
304    bind_python! { self.parent = pub fn set_parent(&mut self, py: Python, value: &Self) }
305    bind_python! { self.parent_bone => pub fn parent_bone(&self, py: Python) -> Result<String> }
306    bind_python! { self.parent_bone = pub fn set_parent_bone(&mut self, py: Python, value: &str) }
307    bind_python! { self.parent_type => pub fn parent_type(&self, py: Python) -> Result<ObjectType> }
308    // bind_python! { self.parent_type = pub fn set_parent_type(&mut self, py: Python, value: ObjectType) }
309    bind_python! { self.parent_vertices => pub fn parent_vertices<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
310    bind_python! { self.parent_vertices = pub fn set_parent_vertices(&mut self, py: Python, value: &PyAny) }
311    bind_python! { self.particle_systems => pub fn particle_systems<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
312    bind_python! { self.pass_index => pub fn pass_index(&self, py: Python) -> Result<i16> }
313    bind_python! { self.pass_index = pub fn set_pass_index(&mut self, py: Python, value: i16) }
314    bind_python! { self.pose => pub fn pose<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
315    bind_python! { self.rigid_body => pub fn rigid_body<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
316    bind_python! { self.rigid_body_constraint => pub fn rigid_body_constraint<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
317    bind_python! { self.rotation_axis_angle => pub fn rotation_axis_angle(&self, py: Python) -> Result<[f32; 4]> }
318    bind_python! { self.rotation_axis_angle = pub fn set_rotation_axis_angle(&mut self, py: Python, value: [f32; 4]) }
319    bind_python! { self.rotation_euler => pub fn rotation_euler(&self, py: Python) -> Result<[f32; 3]> }
320    bind_python! { self.rotation_euler = pub fn set_rotation_euler(&mut self, py: Python, value: [f32; 3]) }
321    bind_python! { self.rotation_mode => pub fn rotation_mode(&self, py: Python) -> Result<String> }
322    bind_python! { self.rotation_mode = pub fn set_rotation_mode(&mut self, py: Python, value: &str) }
323    bind_python! { self.rotation_quaternion => pub fn rotation_quaternion(&self, py: Python) -> Result<[f32; 4]> }
324    bind_python! { self.rotation_quaternion = pub fn set_rotation_quaternion(&mut self, py: Python, value: [f32; 4]) }
325    bind_python! { self.scale => pub fn scale(&self, py: Python) -> Result<[f32; 3]> }
326    bind_python! { self.scale = pub fn set_scale(&mut self, py: Python, value: [f32; 3]) }
327    bind_python! { self.shader_effects => pub fn shader_effects<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
328    bind_python! { self.shader_effects = pub fn set_shader_effects(&mut self, py: Python, value: &PyAny) }
329    bind_python! { self.show_all_edges => pub fn show_all_edges(&self, py: Python) -> Result<bool> }
330    bind_python! { self.show_all_edges = pub fn set_show_all_edges(&mut self, py: Python, value: bool) }
331    bind_python! { self.show_axis => pub fn show_axis(&self, py: Python) -> Result<bool> }
332    bind_python! { self.show_axis = pub fn set_show_axis(&mut self, py: Python, value: bool) }
333    bind_python! { self.show_bounds => pub fn show_bounds(&self, py: Python) -> Result<bool> }
334    bind_python! { self.show_bounds = pub fn set_show_bounds(&mut self, py: Python, value: bool) }
335    bind_python! { self.show_empty_image_only_axis_aligned => pub fn show_empty_image_only_axis_aligned(&self, py: Python) -> Result<bool> }
336    bind_python! { self.show_empty_image_only_axis_aligned = pub fn set_show_empty_image_only_axis_aligned(&mut self, py: Python, value: bool) }
337    bind_python! { self.show_empty_image_orthographic => pub fn show_empty_image_orthographic(&self, py: Python) -> Result<bool> }
338    bind_python! { self.show_empty_image_orthographic = pub fn set_show_empty_image_orthographic(&mut self, py: Python, value: bool) }
339    bind_python! { self.show_empty_image_perspective => pub fn show_empty_image_perspective(&self, py: Python) -> Result<bool> }
340    bind_python! { self.show_empty_image_perspective = pub fn set_show_empty_image_perspective(&mut self, py: Python, value: bool) }
341    bind_python! { self.show_in_front => pub fn show_in_front(&self, py: Python) -> Result<bool> }
342    bind_python! { self.show_in_front = pub fn set_show_in_front(&mut self, py: Python, value: bool) }
343    bind_python! { self.show_instancer_for_render => pub fn show_instancer_for_render(&self, py: Python) -> Result<bool> }
344    bind_python! { self.show_instancer_for_render = pub fn set_show_instancer_for_render(&mut self, py: Python, value: bool) }
345    bind_python! { self.show_instancer_for_viewport => pub fn show_instancer_for_viewport(&self, py: Python) -> Result<bool> }
346    bind_python! { self.show_instancer_for_viewport = pub fn set_show_instancer_for_viewport(&mut self, py: Python, value: bool) }
347    bind_python! { self.show_name => pub fn show_name(&self, py: Python) -> Result<bool> }
348    bind_python! { self.show_name = pub fn set_show_name(&mut self, py: Python, value: bool) }
349    bind_python! { self.show_only_shape_key => pub fn show_only_shape_key(&self, py: Python) -> Result<bool> }
350    bind_python! { self.show_only_shape_key = pub fn set_show_only_shape_key(&mut self, py: Python, value: bool) }
351    bind_python! { self.show_texture_space => pub fn show_texture_space(&self, py: Python) -> Result<bool> }
352    bind_python! { self.show_texture_space = pub fn set_show_texture_space(&mut self, py: Python, value: bool) }
353    bind_python! { self.show_transparent => pub fn show_transparent(&self, py: Python) -> Result<bool> }
354    bind_python! { self.show_transparent = pub fn set_show_transparent(&mut self, py: Python, value: bool) }
355    bind_python! { self.show_wire => pub fn show_wire(&self, py: Python) -> Result<bool> }
356    bind_python! { self.show_wire = pub fn set_show_wire(&mut self, py: Python, value: bool) }
357    bind_python! { self.soft_body => pub fn soft_body<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
358    bind_python! { self.track_axis => pub fn track_axis<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
359    bind_python! { self.up_axis => pub fn up_axis<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
360    bind_python! { self.use_camera_lock_parent => pub fn use_camera_lock_parent(&self, py: Python) -> Result<bool> }
361    bind_python! { self.use_camera_lock_parent = pub fn set_use_camera_lock_parent(&mut self, py: Python, value: bool) }
362    bind_python! { self.use_dynamic_topology_sculpting => pub fn use_dynamic_topology_sculpting(&self, py: Python) -> Result<bool> }
363    bind_python! { self.use_empty_image_alpha => pub fn use_empty_image_alpha(&self, py: Python) -> Result<bool> }
364    bind_python! { self.use_empty_image_alpha = pub fn set_use_empty_image_alpha(&mut self, py: Python, value: bool) }
365    bind_python! { self.use_grease_pencil_lights => pub fn use_grease_pencil_lights(&self, py: Python) -> Result<bool> }
366    bind_python! { self.use_grease_pencil_lights = pub fn set_use_grease_pencil_lights(&mut self, py: Python, value: bool) }
367    bind_python! { self.use_instance_faces_scale => pub fn use_instance_faces_scale(&self, py: Python) -> Result<bool> }
368    bind_python! { self.use_instance_faces_scale = pub fn set_use_instance_faces_scale(&mut self, py: Python, value: bool) }
369    bind_python! { self.use_instance_vertices_rotation => pub fn use_instance_vertices_rotation(&self, py: Python) -> Result<bool> }
370    bind_python! { self.use_instance_vertices_rotation = pub fn set_use_instance_vertices_rotation(&mut self, py: Python, value: bool) }
371    bind_python! { self.use_mesh_mirror_x => pub fn use_mesh_mirror_x(&self, py: Python) -> Result<bool> }
372    bind_python! { self.use_mesh_mirror_x = pub fn set_use_mesh_mirror_x(&mut self, py: Python, value: bool) }
373    bind_python! { self.use_mesh_mirror_y => pub fn use_mesh_mirror_y(&self, py: Python) -> Result<bool> }
374    bind_python! { self.use_mesh_mirror_y = pub fn set_use_mesh_mirror_y(&mut self, py: Python, value: bool) }
375    bind_python! { self.use_mesh_mirror_z => pub fn use_mesh_mirror_z(&self, py: Python) -> Result<bool> }
376    bind_python! { self.use_mesh_mirror_z = pub fn set_use_mesh_mirror_z(&mut self, py: Python, value: bool) }
377    bind_python! { self.use_shape_key_edit_mode => pub fn use_shape_key_edit_mode(&self, py: Python) -> Result<bool> }
378    bind_python! { self.use_shape_key_edit_mode = pub fn set_use_shape_key_edit_mode(&mut self, py: Python, value: bool) }
379    bind_python! { self.use_simulation_cache => pub fn use_simulation_cache(&self, py: Python) -> Result<bool> }
380    bind_python! { self.use_simulation_cache = pub fn set_use_simulation_cache(&mut self, py: Python, value: bool) }
381    bind_python! { self.vertex_groups => pub fn vertex_groups<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
382    bind_python! { self.visible_camera => pub fn visible_camera(&self, py: Python) -> Result<bool> }
383    bind_python! { self.visible_camera = pub fn set_visible_camera(&mut self, py: Python, value: bool) }
384    bind_python! { self.visible_diffuse => pub fn visible_diffuse(&self, py: Python) -> Result<bool> }
385    bind_python! { self.visible_diffuse = pub fn set_visible_diffuse(&mut self, py: Python, value: bool) }
386    bind_python! { self.visible_glossy => pub fn visible_glossy(&self, py: Python) -> Result<bool> }
387    bind_python! { self.visible_glossy = pub fn set_visible_glossy(&mut self, py: Python, value: bool) }
388    bind_python! { self.visible_shadow => pub fn visible_shadow(&self, py: Python) -> Result<bool> }
389    bind_python! { self.visible_shadow = pub fn set_visible_shadow(&mut self, py: Python, value: bool) }
390    bind_python! { self.visible_transmission => pub fn visible_transmission(&self, py: Python) -> Result<bool> }
391    bind_python! { self.visible_transmission = pub fn set_visible_transmission(&mut self, py: Python, value: bool) }
392    bind_python! { self.visible_volume_scatter => pub fn visible_volume_scatter(&self, py: Python) -> Result<bool> }
393    bind_python! { self.visible_volume_scatter = pub fn set_visible_volume_scatter(&mut self, py: Python, value: bool) }
394    bind_python! { self.children => pub fn children(&self, py: Python) -> Result<Vec<Self>> }
395    bind_python! { self.children_recursive => pub fn children_recursive(&self, py: Python) -> Result<Vec<Self>> }
396    bind_python! { self.users_collection => pub fn users_collection(&self, py: Python) -> Result<Vec<Collection>> }
397    bind_python! { self.users_scene => pub fn users_scene<'py>(&'py self, py: Python<'py>) -> Result<Vec<Scene<'py>>> }
398    bind_python! { self.select_get() => pub fn select_get(&self, py: Python, view_layer: Option<ViewLayer>) -> Result<bool> }
399    bind_python! { self.select_set() => pub fn select_set(&self, py: Python, state: bool, view_layer: Option<ViewLayer>) }
400    bind_python! { self.hide_get() => pub fn hide_get(&self, py: Python, view_layer: Option<ViewLayer>) -> Result<bool> }
401    bind_python! { self.hide_set() => pub fn hide_set(&self, py: Python, state: bool, view_layer: Option<ViewLayer>) }
402    bind_python! { self.visible_get() => pub fn visible_get(&self, py: Python, view_layer: Option<ViewLayer>, viewport: Option<SpaceView3D>) -> Result<bool> }
403    bind_python! { self.holdout_get() => pub fn holdout_get(&self, py: Python, view_layer: Option<ViewLayer>) -> Result<bool> }
404    bind_python! { self.indirect_only_get() => pub fn indirect_only_get(&self, py: Python, view_layer: Option<ViewLayer>) -> Result<bool> }
405    bind_python! { self.local_view_get() => pub fn local_view_get(&self, py: Python, viewport: SpaceView3D) -> Result<bool> }
406    bind_python! { self.local_view_set() => pub fn local_view_set(&self, py: Python, viewport: SpaceView3D, state: bool) }
407    bind_python! { self.visible_in_viewport_get() => pub fn visible_in_viewport_get(&self, py: Python, viewport: SpaceView3D) -> Result<bool> }
408    // bind_python! { self.convert_space() => pub fn convert_space(&self, py: Python, pose_bone=None, matrix=((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)), from_space='WORLD', to_space='WORLD') -> Result<&PyAny> }
409    // bind_python! { self.calc_matrix_camera() => pub fn calc_matrix_camera(&self, py: Python, x=1, y=1, scale_x=1.0, scale_y=1.0) -> Result<&PyAny> }
410    // bind_python! { self.camera_fit_coords() => pub fn camera_fit_coords(&self, py: Python, coordinates) -> Result<&PyAny> }
411    // bind_python! { self.crazyspace_eval() => pub fn crazyspace_eval(&self, py: Python, scene) -> Result<&PyAny> }
412    // bind_python! { self.crazyspace_displacement_to_deformed() => pub fn crazyspace_displacement_to_deformed(&self, py: Python, vertex_index=0, displacement=(0.0, 0.0, 0.0)) -> Result<&PyAny> }
413    // bind_python! { self.crazyspace_displacement_to_original() => pub fn crazyspace_displacement_to_original(&self, py: Python, vertex_index=0, displacement=(0.0, 0.0, 0.0)) -> Result<&PyAny> }
414    // bind_python! { self.crazyspace_eval_clear() => pub fn crazyspace_eval_clear(&self, py: Python) -> Result<&PyAny> }
415    bind_python! { self.to_mesh() => pub fn to_mesh(&self, py: Python) -> Result<Mesh> }
416    bind_python! { self.to_mesh_clear() => pub fn to_mesh_clear(&self, py: Python) }
417    bind_python! { self.to_curve() => pub fn to_curve(&self, py: Python, apply_modifiers: bool) -> Result<Curve> }
418    bind_python! { self.to_curve_clear() => pub fn to_curve_clear(&self, py: Python) }
419    bind_python! { self.find_armature() => pub fn find_armature(&self, py: Python) -> Result<Self> }
420    // bind_python! { self.shape_key_add() => pub fn shape_key_add(&self, py: Python, name='Key', from_mix: bool) -> Result<&PyAny> }
421    // bind_python! { self.shape_key_remove() => pub fn shape_key_remove(&self, py: Python, key) }
422    // bind_python! { self.shape_key_clear() => pub fn shape_key_clear(&self, py: Python) }
423    bind_python! { self.ray_cast() => pub fn ray_cast(&self, py: Python, origin: [f32; 3], direction: [f32; 3], distance: f32) -> Result<(bool, [f32; 3], [f32; 3], i32)> }
424    bind_python! { self.closest_point_on_mesh() => pub fn closest_point_on_mesh(&self, py: Python, origin: [f32; 3], distance: f32) -> Result<(bool, [f32; 3], [f32; 3], i32)> }
425    bind_python! { self.is_modified() => pub fn is_modified(&self, py: Python, scene: Scene, settings: RenderVariant) -> Result<bool> }
426    bind_python! { self.is_deform_modified() => pub fn is_deform_modified(&self, py: Python, scene: Scene, settings: RenderVariant) -> Result<bool> }
427    bind_python! { self.update_from_editmode() => pub fn update_from_editmode(&self, py: Python) -> Result<bool> }
428    bind_python! { self.cache_release() => pub fn cache_release(&self, py: Python) }
429    bind_python! { self.generate_gpencil_strokes() => pub fn generate_gpencil_strokes(&self, py: Python, grease_pencil_object: &Self, use_collections: bool, scale_thickness: f32, sample: f32) -> Result<bool> }
430}
431
432impl From<pyo3::PyObject> for Object {
433    fn from(value: pyo3::PyObject) -> Self {
434        Self(value)
435    }
436}
437
438impl From<&pyo3::PyAny> for Object {
439    fn from(value: &pyo3::PyAny) -> Self {
440        Self(value.into())
441    }
442}
443
444impl pyo3::FromPyObject<'_> for Object {
445    fn extract(value: &pyo3::PyAny) -> pyo3::PyResult<Self> {
446        Ok(Self(value.into()))
447    }
448}
449
450impl pyo3::ToPyObject for Object {
451    fn to_object(&self, py: pyo3::Python<'_>) -> pyo3::PyObject {
452        self.as_ref(py).to_object(py)
453    }
454}