CE C# Build Display Rules programmatically

Hi everyone,

I'm developing an AddIn in C # for Microstation Connect Version 12 and I should create, by code, a rule to insert in a display rules.


If I create the following rule (REFERENCE.References.Logical Name = Attachment_1), in the Microstation environment, everything works correctly (DisplayRules1.JPG) .


If I try to create the same rule from c # Microstation I get the message "Unrecognized Criteria" (DisplayRules2.JPG)

Code Example :

"string fieldValue = "Attachment_1";

string RuleStenName = "RulSet_1";

string MyRuleCondition = $@"REFERENCE.References.Logical Name = {fieldValue}";"

 


Could anyone tell me what is the exact way to build this rule condition from code?

Thanks for your help,

Salvio

Parents
  • Could anyone tell me what is the exact way to build a rule condition from code?

    More generally, I think we need advice on writing Expressions programmatically.  It's easy to get an Expression wrong, but hard to get diagnostic information (as you have found).

    string MyRuleCondition = $@"REFERENCE.References.Logical Name = {fieldValue}";"

    It's not clear what you're writing in that statement...

    • A literal string is prefixed with two special .NET modifiers $@
    • The string is terminated with an additional quote after the semi-colon
    • How do you assign that statement to an Expression?

    Please write your actual code here so we can better understand what you have:  Use the Insert|Code button.

     
    Regards, Jon Summers
    LA Solutions

Reply
  • Could anyone tell me what is the exact way to build a rule condition from code?

    More generally, I think we need advice on writing Expressions programmatically.  It's easy to get an Expression wrong, but hard to get diagnostic information (as you have found).

    string MyRuleCondition = $@"REFERENCE.References.Logical Name = {fieldValue}";"

    It's not clear what you're writing in that statement...

    • A literal string is prefixed with two special .NET modifiers $@
    • The string is terminated with an additional quote after the semi-colon
    • How do you assign that statement to an Expression?

    Please write your actual code here so we can better understand what you have:  Use the Insert|Code button.

     
    Regards, Jon Summers
    LA Solutions

Children