I have a get and set method for my properties. As an example, I'm getting the x dimension of a vertex selection. The get is simple enough. For the set, how can I get the delta or change in the Property value?
As in, if I have an object that is 6m in X, then the value being passed to my in my set function would be 6m. How can I then run my code to find the current size so that I can multiply the x coordinates by the change in value?
Here's some code for demonstration purposes:
def get_dim_x(self):
obj = bpy.context.object
v_x = [v.co for v in obj.data.vertices]
dimension_x = max(v_x)-min(v_x)
return dimension_x
def set_dim_x(self,value):
# How do I get the delta/change in value without recursion?
dim_x = get_dim_x(self)
for v in obj.data.vertices:
if dim_x != 0:
v.co.x *= value/dim_x
class EXAMPLE_PG_props(PropertyGroup):
dimension_x: FloatProperty(name = "Dimension X",
default = 0.0,
step = 100,
get = get_dim_x,
set = set_dim_x
)
Thanks!
obj.dimensionsdirectly ? – Gorgious Feb 01 '23 at 08:08self["dimension_x"], which was ill-advised. https://blender.stackexchange.com/questions/49264/how-to-use-set-get-property-callbacks-correctly – Dr. Pontchartrain Feb 01 '23 at 08:11