Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Jan 2014
    Location
    Dresden
    Posts
    725

    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
    Code:
        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...bpy.props.html

    Thanks for any help...
    Last edited by mkbreuer; 10-Sep-17 at 14:48.
    "Just simple, but not simpler!" (A.E.) / GitHub



  2. #2
    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):

    Code:
    >>> 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.
    Floor board generator addon : https://github.com/clarkx/Parquet
    Wood procedural texture node : https://github.com/clarkx/ProceduralWood
    Lumiere : Lighting addon : https://github.com/clarkx/Lumiere
    VisionHDR: Environment addon : https://github.com/clarkx/VisionHDR



  3. #3
    Member
    Join Date
    Jan 2014
    Location
    Dresden
    Posts
    725
    Originally Posted by clarkx View Post
    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):

    Code:
    >>> 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/0B5Q...ew?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?
    "Just simple, but not simpler!" (A.E.) / GitHub



  4. #4
    Hi, sorry if it's not clear.

    I don't know how to make your addon working

    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 :
    Code:
    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 :
    Code:
    gp_bvl_offset = bpy.props.FloatProperty(name="Offset",  description="value", default=0.5, min=0.02, soft_max=100, update=update_gp_bvl)
    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 :
    Code:
    gp_bvl_offset = bpy.props.FloatProperty(name="Offset",  description="value", default=0.5, min=0.02, max=100, update=update_gp_bvl)

    Hope it will help.
    C.
    Floor board generator addon : https://github.com/clarkx/Parquet
    Wood procedural texture node : https://github.com/clarkx/ProceduralWood
    Lumiere : Lighting addon : https://github.com/clarkx/Lumiere
    VisionHDR: Environment addon : https://github.com/clarkx/VisionHDR



  5. #5
    Member
    Join Date
    Jan 2014
    Location
    Dresden
    Posts
    725
    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.
    "Just simple, but not simpler!" (A.E.) / GitHub



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •