1
$\begingroup$

Is there a way to change a prop with an update def without calling the update def?

def update_prop(self, context):
    print ("update")
    if self.variable > 10:
        self.variable  = 10 #10 is a variable that changes in my code 
    #i want to set the prop without recalling the update
    else:
        print("else")



class Props(bpy.types.PropertyGroup):


    bpy.types.Object.variable  = bpy.props.IntProperty(
        name="variable",
        default=0,
        min=0,
        update=update_prop,
$\endgroup$
4
  • $\begingroup$ Please make the question more clear and concise. $\endgroup$
    – Krisego
    Commented Mar 22, 2019 at 19:56
  • 3
    $\begingroup$ Could you please put a little more effort into your questions? $\endgroup$ Commented Mar 22, 2019 at 20:05
  • $\begingroup$ @metaphor_set better ? $\endgroup$
    – Syler
    Commented Mar 22, 2019 at 20:27
  • 1
    $\begingroup$ A lot better, actually. $\endgroup$ Commented Mar 22, 2019 at 20:41

1 Answer 1

1
$\begingroup$

In the example, simply setting a max will do this for us

import bpy

def update_prop(self, context):
    print ("update")
    print(self.variable)


bpy.types.Object.variable  = bpy.props.IntProperty(
    name="variable",
    default=0,
    min=0,
    max=10,
    update=update_prop)

In python console

>>> C.object.variable = 22
update
10

>>> C.object.variable
10

If you wish to set a value and not fire an update, set the id property. A property defined via bpy.props for example ob.prop is stored as ob["prop"] once set to non default.

May be better to use a getter / setter method(s) Internal "get/set" function of property?

def update_prop(self, context):
    print ("update")
    self["variable"] = 4
    print(self.variable)


>>> C.object.variable = 22
update
4

>>> C.object.variable
4

Note this has been answered recenlty, couldn't find that one

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .