Search code examples
rulebooggie

How can I execute a rule from within a script in booggie2?


Is there a way to call a rule (or multiple rules) in a script and execute it?

Please note: The booggie-project does not exist anymore but led to the development of Soley Studio which covers the same functionality.


Solution

  • Yes!

    There are two cases:

    • You know which rule to apply:
            thisRule = transformation.GetRuleByName("myRule")
            thisRule.Apply(param1, param2, ...)
    

    Make sure that the rule parameters param1, param2, ... are of the right type!

    • You don't know which rule to apply:
            rules = transformation.GetRulesWithParams(0)
            rules[0].Apply()
    

    In this case might only use rules that have no parameters since you have to provide the rule parameter of the right type. Here, all rules with no parameters are stored in the list rule and the first one is applied. You can also get the rules' names using rules[0].Name.