<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://communities.bentley.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>[Connect] c# Display Rules - AreaPatternAction</title><link>https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/197590/connect-c-display-rules---areapatternaction</link><description>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 
 
 In the file, in which I want to create the display</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: [Connect] c# Display Rules - AreaPatternAction</title><link>https://communities.bentley.com/thread/588258?ContentTypeID=1</link><pubDate>Thu, 21 May 2020 10:55:11 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:cc5322b4-6032-407c-9f74-2d0d3307f600</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi Salvatore,&lt;/p&gt;
[quote userid="1009364" url="~/products/programming/microstation_programming/f/microstation-programming---forum/197590/connect-c-display-rules---areapatternaction/588253"]This is the procedure I wrote to create the display rule[/quote]
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [Connect] c# Display Rules - AreaPatternAction</title><link>https://communities.bentley.com/thread/588253?ContentTypeID=1</link><pubDate>Thu, 21 May 2020 10:35:00 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:3adcd0e6-ef72-42c1-b07d-17ade90097cb</guid><dc:creator>salvatore montella</dc:creator><description>&lt;p&gt;This is the procedure I wrote to create the display rule&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt; 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 = &amp;quot;RulSet_1&amp;quot;;
            string value = &amp;quot;Attachment_1&amp;quot;;
            string MyRuleCondition =  @&amp;quot;element.IsOfClass (&amp;quot;&amp;quot;ShapeElement&amp;quot;&amp;quot;,&amp;quot;&amp;quot;DgnElementSchema&amp;quot;&amp;quot;)&amp;quot;;


            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(&amp;quot;MDL KEYIN CUSTOMDISPMODE DIALOG DISPLAYSTYLES&amp;quot;);
            keyInCommand.SendKeyin(@&amp;quot;DISPLAYSTYLE CREATE &amp;quot;&amp;quot;DISPLAY_STYLE_BY_KEYIN&amp;quot;&amp;quot;&amp;quot;);
            keyInCommand.SendKeyin(@&amp;quot;MDL KEYIN VIEWCTRL CHANGE VIEW CUSTOM &amp;quot;&amp;quot;DISPLAY_STYLE_BY_KEYIN&amp;quot;&amp;quot; 1&amp;quot;);
            keyInCommand.SendKeyin(@&amp;quot;DISPLAYSTYLE SETPARAM DISPLAYRULESET &amp;quot;&amp;quot;DISPLAY_STYLE_BY_KEYIN&amp;quot;&amp;quot; &amp;quot;&amp;quot;RulSet_1&amp;quot;&amp;quot;&amp;quot;);

            ustnApp.CommandState.StartDefaultCommand();


        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Attached is the Dgn file and the cell library&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://communities.bentley.com/cfs-file/__key/communityserver-discussions-components-files/343173/sir.cel"&gt;communities.bentley.com/.../sir.cel&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://communities.bentley.com/cfs-file/__key/communityserver-discussions-components-files/343173/ThematicPlanStart.dgn"&gt;communities.bentley.com/.../ThematicPlanStart.dgn&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;thanks for the help,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;greetings&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Salvio&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [Connect] c# Display Rules - AreaPatternAction</title><link>https://communities.bentley.com/thread/588251?ContentTypeID=1</link><pubDate>Thu, 21 May 2020 10:13:23 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:06f6b488-dce3-4f48-be57-3e002c752136</guid><dc:creator>Jan Šlegr</dc:creator><description>[quote userid="1009364" url="~/products/programming/microstation_programming/f/microstation-programming---forum/197590/connect-c-display-rules---areapatternaction/588247"]Creating the rule manually everything works. [/quote]
&lt;p&gt;And is it possible to provide example DGN file (just one or two elements + the rule)?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [Connect] c# Display Rules - AreaPatternAction</title><link>https://communities.bentley.com/thread/588247?ContentTypeID=1</link><pubDate>Thu, 21 May 2020 10:10:13 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:733e989c-dfb5-45ae-99b0-52ab9989297f</guid><dc:creator>salvatore montella</dc:creator><description>&lt;p&gt;Creating the rule manually everything works. &lt;br /&gt;The problem occurs when I try to code it through API&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [Connect] c# Display Rules - AreaPatternAction</title><link>https://communities.bentley.com/thread/588244?ContentTypeID=1</link><pubDate>Thu, 21 May 2020 09:42:56 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:0ff5bbd1-5d43-4a57-8ea5-0a38475bc9c2</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi Salvio,&lt;/p&gt;
&lt;p&gt;it&amp;#39;s not clear from your description whether the problem is &amp;quot;how to define action&amp;quot; (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.&lt;/p&gt;
&lt;p&gt;When DGN file with correct rule is available, it would be nice to share it. It&amp;#39;s always better and more efficient than to describe it by words ;-)&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>