Dynamic constraints for properties

Forum Forums Visual Components 4.1 Component Modeling Dynamic constraints for properties

This topic contains 1 reply, has 2 voices, and was last updated by Avatar jouha 4 months, 3 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #15650

    Hello everyone,

    I am currently modelling an item which has the properties Length as well as Range. My requirement is that Range can only be two thirds of Width. I know how to set hardcoded constraints (just write sth. like “0.0-10.0” into the textfield) but this solution is not what I need.

    I created the properties as follows:

    Does anyone know how to fix this issue?

    Thanks in advance


    Hi JakobHerk,

    This is classical type issue. Dividing integer with integer results to… integer. Meaning that 2/3 = 0, because int(0.67) = 0 or 3/4 = 1, because int(1.33) = 1.

    Dividing by a float will result to float. So change the code to:

    2/3.0 * prop_length.Value

    I would add parenthesis around division since I don’t mean to divide with the product of 3.0 and prop_lenght.Value, just to make it easier to read:

    (2/3.0) * prop_length.Value

    Otherwise it should be good to go!

    P.S To make it “perfect” add OnChanged event for the prop_length and adjust the MaxValue of prop_range in the event handler.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.