blr/types/
bpy_id.rs

1use crate::types::{Scene, ViewLayer};
2use pyo3::{PyAny, PyObject};
3use pyo3_macros_more::bind_python;
4use std::{
5    collections::HashSet,
6    ops::{Deref, DerefMut},
7};
8
9/// Wrapper all subclasses of around <https://docs.blender.org/api/latest/bpy.types.ID.html>
10pub trait BpyID: Deref<Target = PyObject> + DerefMut<Target = PyObject> + pyo3::ToPyObject {
11    bind_python! { self.asset_data => fn asset_data<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
12    bind_python! { self.is_embedded_data => fn is_embedded_data(&self, py: Python) -> Result<bool> }
13    bind_python! { self.is_evaluated => fn is_evaluated(&self, py: Python) -> Result<bool> }
14    bind_python! { self.is_library_indirect => fn is_library_indirect(&self, py: Python) -> Result<bool> }
15    bind_python! { self.is_missing => fn is_missing(&self, py: Python) -> Result<bool> }
16    bind_python! { self.is_runtime_data => fn is_runtime_data(&self, py: Python) -> Result<bool> }
17    bind_python! { self.is_runtime_data = fn set_is_runtime_data(&mut self, py: Python, value: bool) }
18    bind_python! { self.library => fn library<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
19    bind_python! { self.library_weak_reference => fn library_weak_reference<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
20    bind_python! { self.name => fn name(&self, py: Python) -> Result<String> }
21    bind_python! { self.name = fn set_name(&mut self, py: Python, value: &str) }
22    bind_python! { self.name_full => fn name_full(&self, py: Python) -> Result<String> }
23    bind_python! { self.original => fn original<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
24    bind_python! { self.override_library => fn override_library<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
25    bind_python! { self.preview => fn preview<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
26    bind_python! { self.tag => fn tag(&self, py: Python) -> Result<bool> }
27    bind_python! { self.tag = fn set_tag(&mut self, py: Python, value: bool) }
28    bind_python! { self.use_extra_user => fn use_extra_user(&self, py: Python) -> Result<bool> }
29    bind_python! { self.use_extra_user = fn set_use_extra_user(&mut self, py: Python, value: bool) }
30    bind_python! { self.use_fake_user => fn use_fake_user(&self, py: Python) -> Result<bool> }
31    bind_python! { self.use_fake_user = fn set_use_fake_user(&mut self, py: Python, value: bool) }
32    bind_python! { self.users => fn users(&self, py: Python) -> Result<u32> }
33    bind_python! { self.evaluated_get() => fn evaluated_get<'py>(&'py self, py: Python<'py>, depsgraph: &PyAny) -> Result<&'py PyAny> }
34    bind_python! { self.copy() => fn copy<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
35    bind_python! { self.asset_mark() => fn asset_mark(&self, py: Python) }
36    bind_python! { self.asset_clear() => fn asset_clear(&self, py: Python) }
37    bind_python! { self.asset_generate_preview() => fn asset_generate_preview(&self, py: Python) }
38    bind_python! { self.override_create() => fn override_create<'py>(&'py self, py: Python<'py>, remap_local_usages: bool) -> Result<&'py PyAny> }
39    bind_python! { self.override_hierarchy_create() => fn override_hierarchy_create<'py>(&'py self, py: Python<'py>, scene: Scene, view_layer: ViewLayer, reference: Option<impl BpyID>, do_fully_editable: bool) -> Result<&'py PyAny> }
40    bind_python! { self.override_template_create() => fn override_template_create(&self, py: Python)}
41    bind_python! { self.user_clear() => fn user_clear(&self, py: Python)}
42    bind_python! { self.user_remap() => fn user_remap(&self, py: Python, new_id: impl BpyID) }
43    bind_python! { self.make_local() => fn make_local<'py>(&'py self, py: Python<'py>, clear_proxy: bool) -> Result<&'py PyAny> }
44    bind_python! { self.user_of_id() => fn user_of_id(&self, py: Python, id: impl BpyID) -> Result<u32> }
45    bind_python! { self.animation_data_create() => fn animation_data_create<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
46    bind_python! { self.animation_data_clear() => fn animation_data_clear(&self, py: Python) }
47    bind_python! { self.update_tag() => fn update_tag(&self, py: Python, refresh: HashSet<String>) }
48    bind_python! { self.preview_ensure() => fn preview_ensure<'py>(&'py self, py: Python<'py>) -> Result<&'py PyAny> }
49}