[Connect] c# Display Rules - AreaPatternAction


Hi,
I have the following problem with creating a display rules action:
I would like to create a pattern that applies a pattern by selecting a pattern from a cell library.
This is the code I wrote

long elemId = 0;//1,2,3,4,5,6,7
ElementId elementId = new ElementId(ref elemId);

AreaPatternAction.AreaPatternParams patternParams = new AreaPatternAction.AreaPatternParams(
                elementId, 1, false, 45, 5, 1, 1);
IDisplayRuleAction ruleAction = new AreaPatternAction(patternParams, dgnFile);

displayRuleElement.AddAction(ruleAction);

In the file, in which I want to create the display rules, I hooked a cell library but the result is the following

the cell model is empty.

I suppose the problem may arise from how I calculate the ElementId object

Any ideas on this?

thanks for the help,

greetings

Salvio

Parents Reply Children
  • This is the procedure I wrote to create the display rule

     private void DiplayRulesSampleNew()
            {
                BIM.CadInputQueue keyInCommand = ustnApp.CadInputQueue;
    
                DgnFile dgnFile = BM.Session.Instance.GetActiveDgnFile();
                DgnModel dgnModel = BM.Session.Instance.GetActiveDgnModel();
                DgnModelRef dgnModelRef = BM.Session.Instance.GetActiveDgnModelRef();
    
                string RuleStenName = "RulSet_1";
                string value = "Attachment_1";
                string MyRuleCondition =  @"element.IsOfClass (""ShapeElement"",""DgnElementSchema"")";
    
    
                DisplayRuleSet displayRuleSet = new DisplayRuleSet(RuleStenName, dgnFile);
                
                DisplayRulesManager.WriteDisplayRuleSetToFile(displayRuleSet, dgnFile, true);
                DisplayRule displayRuleElement = new DisplayRule(MyRuleCondition, true, dgnFile);
    
                long elemId = 0;//1,2,3,4,5,6,7
                ElementId elementId = new ElementId(ref elemId);
    
                AreaPatternAction.AreaPatternParams patternParams = new AreaPatternAction.AreaPatternParams(
                    elementId, 1, false, 45, 5, 1, 1);
                IDisplayRuleAction ruleAction = new AreaPatternAction(patternParams, dgnFile);
                
    
                displayRuleElement.AddAction(ruleAction);
                displayRuleSet.AddDisplayRule(displayRuleElement);
                DisplayRulesManager.WriteDisplayRuleSetToFile(displayRuleSet, dgnFile, true);
    
                keyInCommand.SendKeyin("MDL KEYIN CUSTOMDISPMODE DIALOG DISPLAYSTYLES");
                keyInCommand.SendKeyin(@"DISPLAYSTYLE CREATE ""DISPLAY_STYLE_BY_KEYIN""");
                keyInCommand.SendKeyin(@"MDL KEYIN VIEWCTRL CHANGE VIEW CUSTOM ""DISPLAY_STYLE_BY_KEYIN"" 1");
                keyInCommand.SendKeyin(@"DISPLAYSTYLE SETPARAM DISPLAYRULESET ""DISPLAY_STYLE_BY_KEYIN"" ""RulSet_1""");
    
                ustnApp.CommandState.StartDefaultCommand();
    
    
            }

    Attached is the Dgn file and the cell library

    sir.cel

    ThematicPlanStart.dgn

    thanks for the help,

    greetings

    Salvio

  • Hi Salvatore,

    This is the procedure I wrote to create the display rule

    I assume (but did not test it) that ElementId in AreaPatternParams should be element it of shared cell definition instance, which in the case of ThematicPlanStart.dgn is 1021.

    With regards,

      Jan