How to block a property value with a value from another property?

Hy, i want to block a property value with a value from another property to avoid some overlappings.

Example: soft_max from gp_bvl2_offset should not exceed the complete value from gp_bvl_offset



    gp_bvl_offset = bpy.props.FloatProperty(name="Offset",  description="value", default=0.5, min=0.02, soft_max=100)                          
    gp_bvl2_offset = bpy.props.FloatProperty(name="Shift",  description="value", default=0.25, min=0.02, soft_max = self.gp_bvl_offset)       


Do i have to define it outside?
https://docs.blender.org/api/blender_python_api_2_77_0/bpy.props.html

Thanks for any help…

Hi mkbreuer,

You can use an update in “gp_bvl_offset” and access to the values of “gp_bvl2_offset” like this (from the console):


>>> gp_bvl2_offset = bpy.props.FloatProperty(name="Offset",  description="value", default=0.5, min=0.02, soft_max=100) 
 
>>> gp_bvl2_offset[
                           0]
                           1]


>>> gp_bvl2_offset[1]['
                      default']
                      description']
                      min']
                      name']
                      soft_max']


>>> gp_bvl2_offset[1]['soft_max']
100



Hope it can help.
C.

Thank you for you fast reply.
But i am not so far advanced and i want to use this in a simple operator script.
Here can make a look for what i needed this:
https://drive.google.com/file/d/0B5QQIWH-54S1ZVdoQ196ZmtOQmM/view?usp=sharing
If you test loopgap you see that the mesh is going to overlapp,
when you rise the SHIFT of create 2 gaps higher than the first main offset.
(props for line 296 and 306)

Maybe you have just an operator example where i can figure it out?

Hi, sorry if it’s not clear.

I don’t know how to make your addon working :slight_smile:

To resume, you should do something like this :
Create a new update function that will update the parameter of gp_bvl2_offset.
Here is an example of how to change one parameter or the value of the property :

def update_gp_bvl(self, context):
    print("OFFSET: ", VIEW3D_TP_LoopGap.gp_bvl2_offset[1]['soft_max'])
    offset = self.gp_bvl_offset
    if offset > 0.5:
        VIEW3D_TP_LoopGap.gp_bvl2_offset[1]['soft_max'] = offset
        self.gp_bvl2_offset = offset
    else:
        VIEW3D_TP_LoopGap.gp_bvl2_offset[1]['soft_max'] = 100

Then add an update to your property gp_bvl_offset :

gp_bvl_offset = bpy.props.FloatProperty(name="Offset",  description="value", default=0.5, min=0.02, soft_max=100, update=<b>update_gp_bvl</b>)

By the way, you have a “min” parameter, but not a “max”. Be careful, the “soft_min/soft_max” is only when using the mouse on the widget (dragging the slider). It should be :


gp_bvl_offset = bpy.props.FloatProperty(name="Offset",  description="value", default=0.5, min=0.02, <b>max</b>=100, update=update_gp_bvl)

Hope it will help.
C.

Ah! Thank you! This helps a lot!
I test it, but i it works only in one direction.
Means: the slider will be blocked, after its arrive the targeted value. And i can´t move the value backwards. Its frozen…
Anyway, now i know how to use such kind of update function or in wich way i have to continue my study.
I will not use it in loopgap, but when i have a other use of it i, will post it here.