yes/no or true/false node

Hi All,

I was wondering if there was a way maybe through a function that allowed you to have a yes/no node to split a GC Graph.

For example I am building a façade and we may include a blind box in the façade panel,

I could build this into a user defined node with an option if YES then do this part of the script or if NO then do this other part of the script.

as a diagram maybe something like this, forming a branch in the graph?

Thanks
Wayne

  • hi all,

    I was just thinking about this over night and I think the solution is not to split the path but just have a node by function, then maybe include an 'if then' statement at the beginning of the function if possible. you could then link this to a slider that was had two values 0 or 1 and then read this as a yes no.

     think that would work

    you could link the slider to multiple nodes and have them react to a decision.

    let me know if anyone has any other ideas.

    thanks

    wayne

  • Hi Wayne,

    Yes, a node.ByFunction would certainly work. 

    If you want to feed in a value via a Slider node, there are two additional techniques beyond ByDefault.

    slider.ByDefault mimics an analog slider between a minimum and a maximum value with a set resolution.  (Ultimately, there is no infinite resolution in regular computing.)

    slider.ByValueList permits you to define a list of values, e.g. {"yes", "no"}.  This will result in a slider with a selection list with those two values while still offering the slider thumb with two values (in this example). 

    slider.ByEnumType permits you to select any enum type defined for GC.  Most of these (or all) can be discovered in the Expression Builder (in the Editor available through the green fx icon), under the Bentley.GC tab.  The input for EnumType would be for example typeof(FacetOption), which then will populate the selection pop down with "Diamond", "ForcePlanarQuads", "Quads", etc. 

    transaction 1 modelChange 'Add sliderByEnumType, sliderByValueList, sliderDefault'
    {
        node User.Objects.sliderDefault Bentley.GC.NodeTypes.Slider
        {
            Technique                 = 'Default';
        }
        node User.Objects.sliderByValueList Bentley.GC.NodeTypes.Slider
        {
            Technique                 = 'ByValueList';
            Value                     = 'yes';
            ValueList                 = {"yes", "maybe", "no"};
        }
        node User.Objects.sliderByEnumType Bentley.GC.NodeTypes.Slider
        {
            Technique                 = 'ByEnumType';
            Value                     = FacetOption.Diamond;
            EnumType                  = typeof(FacetOption);
        }
    }

    The alternative to using a node.ByFunction to implement a logical fork in the Graph is that nodes implement a logical switch in form of a one-line conditional expression in an input property.  The format for that would be (for example as "Length" input for a line.ByStartPointDirectionLength):

        sliderByValueList == "yes" ? 50 : "failure"

    This would work analogously if you wanted to switch from using one StartPoint to some other StartPoint based on a third input that varies.  The format of a one-line conditional expression is:

        (condition which evaluates to true or false) ? (value to which this expression evaluates if condition is true) : (value to which this expression evaluates if condition is false)

    with the question mark separating the condition from the values, and the colon separating the value if condition is true from the value if condition is false.  If necessary, this could be nested, like an if else if (etc.) statement, although nesting it deeply becomes tedious to read and debug. 

        sliderByValueList == "yes" ? 50 : (sliderByValueList == "maybe" ? 25 : "failure")

    In the first case, if sliderByValueList is not equal to "yes", line.Length will be "failure" which is an invalid input for that property (expected is a double/numeric value).  This makes the line fail and anything build on it/downstream from it.  That would be one fork of the Graph that then works only if sliderByValueList is equal to "yes".

    In the second case, if sliderByValueList is not equal to "yes", GC continues to check whether sliderByValueList is equal to "maybe", at which point the line would be 25 units long, and only if sliderByValueList is neither "yes" nor "maybe" would this one-line conditional expression evaluate to "failure" and make line and its downstream dependents fail. 

    Please let me know whether you need any more information to explore your options from here.

    Thank you and best success,

          Volker

       

  • Hi Volker,

    I thought I had it but I messed something up.

    I have attached a dgn with a basic line as you mentioned with a sliderByValueList but I must have the syntax incorrect.

    would you mind having a look

    Thanks
    Wayne

    GC_Yes_No.zip

  • Hi Wayne,

    My earlier response may have been misleading because I named the slider "sliderByValueList".

    In your example, your Slider node's name is "slider1".  The expression in line1.Length then should be:

    slider1 == "yes" ? 50 : "failure"

    With that change, line1 will be 50 long when slider1 is 'yes', and line1 will fail when slider1 is 'no'.

    Regards,

          Volker

       

    Answer Verified By: Wayne Dickerson