CE Display Rules C#

Hello, I'm trying to develop an add-in for creating Display Rules in c #. I have a problem creating the condition to pass as a parameter to the constructor of the DisplayRule class.
At this link "">www.bimsdks.com/.../structBentley_1_1DgnPlatform_1_1DisplayRule.html" I found some examples (see Condition format and types) but they are very few.

I implemented the following code that works:

string MyRuleCondition = @"element.IsOfClass (""ShapeElement"",""DgnElementSchema"")";

DisplayRuleSet displayRuleSet = new DisplayRuleSet(RuleStenName, dgnFile);
DisplayRulesManager.WriteDisplayRuleSetToFile(displayRuleSet, dgnFile, true);
DisplayRule displayRuleElement = new DisplayRule(MyRuleCondition, true, dgnFile);

IDisplayRuleAction ruleAction = new ColorOverrideAction(5, dgnFile);
DisplayRulesManager.WriteDisplayRuleSetToFile(displayRuleSet, dgnFile, true);



I should implement a RuleCondition that evaluates the value of a property of an ItemType,
does anyone know a way, a tool, or examples (in c #) to create RuleConditions?

Thanks for the help, greetings

Parents Reply
  • Hi salvatore,

    I was not able to figure how to determine the schema name of the ItemTypeLibary in the condition's expression.

    it's "simple" (when you know it :-) ). When you need to know intrinsict (stored in DGN file) EC schemas, and ItemTypes EC schemas are alwayas intrinsict, use "ecx schema list" key-in, that lists the schemas to Message Center Details.

    Graphical elements features like color etc. are defined in extrinsict EC schema DgnElementSchema.

    Since there is no match between the condition expression shown in the user's interface and the expression required in code

    There is no reason why there should be the match. It seems description is filled automatically by a summary, but it's not the condition syntax.

    I don't know how to write the condition's expression.

    Well ... as written in the documentation you linked: DisplayRule condition is based on ECExpression. I agree it tells nothing for a plain user, and also for developers it's not clear for 100% (because "is based on" expresses that it's only a subset of ECExpression). But at least, it's defines the basic syntax format.

    Is there a reference guide describing the schemas and the expression syntax?

    I think the description provided in DisplayRule API documentation is where you should start. Despite of it's short, I think it covers the most of needs and scenarios.

    Two other sources are:

    • Search this web (and Internet in general) for ECExpression. Because this technology has existed in Bentley products for many (maybe 15?) years already, it's possible to fined some valuable blogs and articles (e.g. this one). But be aware it's not specified that Display Rules support complete ECExpression (plus some features of ECE are not conditions).
    • Read how conditions are defined in Item Types (now in Technology Preview phase), because they are, again, ECExpressions.

    The problem is that without good knowledge of the whole "EC world" (which is very wide and complex topic), some concepts behind and terminology will remain unexplained.

    With regards,


No Data