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
Hi Salvatore,
salvatore montella said: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
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
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
salvatore montella said:Creating the rule manually everything works.
And is it possible to provide example DGN file (just one or two elements + the rule)?
Regards,
Creating the rule manually everything works. The problem occurs when I try to code it through API
Hi Salvio,
it's not clear from your description whether the problem is "how to define action" (because it does not work even when created manually), or you have DGN file with working display rule, but there is a problem when the same rule should be created using API.
When DGN file with correct rule is available, it would be nice to share it. It's always better and more efficient than to describe it by words ;-)