How do I select a DSL shape via APIHi All<br/> <br/> I want select particular Shape programmatically...<br/> <br/> <span style="color:blue">public</span> <span style="color:blue">void</span> SelectShape(<span style="color:#2b91af">ModelElement</span> modelElement) <p style="margin:0px">    {</p> <p style="margin:0px">        <span style="color:#2b91af">ShapeElement</span> modelElementShape = <span style="color:#2b91af">PresentationViewsSubject</span> .GetPresentation(modelElement).FirstOrDefault() <span style="color:blue">as</span> <span style="color:#2b91af">ShapeElement</span> ;</p> <p style="margin:0px"> </p> <p style="margin:0px">        <span style="color:#2b91af">Diagram</span> diagram = modelElement.Store.ElementDirectory.AllElements.OfType&lt;<span style="color:#2b91af">Diagram</span> &gt;().FirstOrDefault();</p> <p style="margin:0px">        <span style="color:#2b91af">DiagramItem</span> diagramItem = <span style="color:blue">new</span> <span style="color:#2b91af">DiagramItem</span> (modelElementShape);</p> <p style="margin:0px">        diagram.ActiveDiagramView.Selection.Set(diagramItem);</p> <p style="margin:0px">    }</p> <p style="margin:0px"> </p> <p style="margin:0px">but diagram.ActiveDiagramView value is null ..</p> <p style="margin:0px">what is wrong with my code?</p> <p style="margin:0px"> </p> <p style="margin:0px"> </p> <p style="margin:0px">Thank You</p> <p style="margin:0px"> </p> <p style="margin:0px">Atul Katare</p> <p style="margin:0px">_____________________________</p> <p style="margin:0px">Build Relationship Dynamically</p>  © 2009 Microsoft Corporation. All rights reserved.Wed, 08 Jul 2009 13:41:22 Z90891865-7438-46cf-8fd2-d55d816d535fhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#90891865-7438-46cf-8fd2-d55d816d535fhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#90891865-7438-46cf-8fd2-d55d816d535fAtulKatarehttp://social.msdn.microsoft.com/Profile/en-US/?user=AtulKatareHow do I select a DSL shape via APIHi All<br/> <br/> I want select particular Shape programmatically...<br/> <br/> <span style="color:blue">public</span> <span style="color:blue">void</span> SelectShape(<span style="color:#2b91af">ModelElement</span> modelElement) <p style="margin:0px">    {</p> <p style="margin:0px">        <span style="color:#2b91af">ShapeElement</span> modelElementShape = <span style="color:#2b91af">PresentationViewsSubject</span> .GetPresentation(modelElement).FirstOrDefault() <span style="color:blue">as</span> <span style="color:#2b91af">ShapeElement</span> ;</p> <p style="margin:0px"> </p> <p style="margin:0px">        <span style="color:#2b91af">Diagram</span> diagram = modelElement.Store.ElementDirectory.AllElements.OfType&lt;<span style="color:#2b91af">Diagram</span> &gt;().FirstOrDefault();</p> <p style="margin:0px">        <span style="color:#2b91af">DiagramItem</span> diagramItem = <span style="color:blue">new</span> <span style="color:#2b91af">DiagramItem</span> (modelElementShape);</p> <p style="margin:0px">        diagram.ActiveDiagramView.Selection.Set(diagramItem);</p> <p style="margin:0px">    }</p> <p style="margin:0px"> </p> <p style="margin:0px">but diagram.ActiveDiagramView value is null ..</p> <p style="margin:0px">what is wrong with my code?</p> <p style="margin:0px"> </p> <p style="margin:0px"> </p> <p style="margin:0px">Thank You</p> <p style="margin:0px"> </p> <p style="margin:0px">Atul Katare</p> <p style="margin:0px">_____________________________</p> <p style="margin:0px">Build Relationship Dynamically</p>  Wed, 01 Jul 2009 13:53:34 Z2009-07-01T13:53:34Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#783fcfe3-7be5-4674-926f-3b7d5ce3b804http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#783fcfe3-7be5-4674-926f-3b7d5ce3b804Sebastian Dyckhttp://social.msdn.microsoft.com/Profile/en-US/?user=Sebastian%20DyckHow do I select a DSL shape via APIHi Atul,<br/> <br/> could you please provide some additional information, especially with respect to the context you are invoking this method from and your general porpuse? I tried to reproduce the issue and diagram.ActiveDiagramView returned the correct object.<br/> <br/> Kind regards<br/> SebastianWed, 01 Jul 2009 22:26:30 Z2009-07-01T22:26:30Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#436a5562-96fe-42c6-bc70-69eac6bd4c13http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#436a5562-96fe-42c6-bc70-69eac6bd4c13AtulKatarehttp://social.msdn.microsoft.com/Profile/en-US/?user=AtulKatareHow do I select a DSL shape via APIHi Sebastian <br/> <br/> I will get Model Element using<br/> <br/>             Store store = new Store(typeof(CoreDomainModel), typeof(CoreDesignSurfaceDomainModel),<br/>                                                                                              typeof(ExampleDomainModel));<br/>             using (Transaction txtTransaction = store.TransactionManager.BeginTransaction(&quot;Root Transaction&quot;))<br/>             {<br/>                 ExampleModel ExampleRoot = ExampleSerializationHelper.Instance.LoadModelAndDiagram<br/>                                                 (store, FilePath, FilePath + &quot;.diagram&quot;, null, null);<br/> <br/>                 <br/>                ModelElement modelElement= ExampleRoot .ExampleElement.First();<br/> <br/>              //  then I will call SelectShape Method <br/> <br/>              Selectshape(modelElement);<br/> <br/>                 txtTransaction .Commit();<br/>             }<br/> <br/> <span style="color:blue">public</span> <span style="color:blue">void</span> SelectShape(<span style="color:#2b91af">ModelElement</span> modelElement) <p style="margin:0px">    {</p> <p style="margin:0px">        <span style="color:#2b91af">ShapeElement</span> modelElementShape = <span style="color:#2b91af">PresentationViewsSubject</span> .GetPresentation(modelElement).FirstOrDefault() <span style="color:blue">as</span> <span style="color:#2b91af">ShapeElement</span> ;</p> <p style="margin:0px"> </p> <p style="margin:0px">        <span style="color:#2b91af">Diagram</span> diagram = modelElement.Store.ElementDirectory.AllElements.OfType&lt;<span style="color:#2b91af">Diagram</span> &gt;().FirstOrDefault();</p> <p style="margin:0px">        <span style="color:#2b91af">DiagramItem</span> diagramItem = <span style="color:blue">new</span> <span style="color:#2b91af">DiagramItem</span> (modelElementShape);</p> <p style="margin:0px">        diagram.ActiveDiagramView.Selection.Set(diagramItem);</p> <p style="margin:0px">    }</p> <br/> <br/> Thank You<br/> <br/> AtulKatare<br/> _________________________________<br/> Build Relationship DynamicallyThu, 02 Jul 2009 05:10:55 Z2009-07-02T05:38:17Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#2e4970e1-b179-4974-b8da-290ef10cd7f5http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#2e4970e1-b179-4974-b8da-290ef10cd7f5RubenJMarrufohttp://social.msdn.microsoft.com/Profile/en-US/?user=RubenJMarrufoHow do I select a DSL shape via APIHello, you are opening a model into a new Store, so this Store doesn't have the current active diagram view. I think if you take from the commandset the current opened store and then you get the active diagram view from the diagram, this object wouldn't be null. Regards!!<br/><br/><hr class="sig">RubenBrenesThu, 02 Jul 2009 12:19:21 Z2009-07-02T12:19:21Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#3894553e-fe80-4b31-ba81-92e5bb04d23dhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#3894553e-fe80-4b31-ba81-92e5bb04d23dAtulKatarehttp://social.msdn.microsoft.com/Profile/en-US/?user=AtulKatareHow do I select a DSL shape via APIHi Ruben<br/><br/>How to get Store from CommandSet class?<br/>CommandSet class constructor require IServiceProvider, how to pass value?<br/><br/>Thank You..Thu, 02 Jul 2009 14:11:07 Z2009-07-02T14:11:07Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#03e0ec7d-0822-4232-9f26-926b6bd79429http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#03e0ec7d-0822-4232-9f26-926b6bd79429RubenJMarrufohttp://social.msdn.microsoft.com/Profile/en-US/?user=RubenJMarrufoHow do I select a DSL shape via APIHello, DslTools generate a CommandSet class in your DslPackage that you can extend with your own commands. I suppose you want to select the shape responding to some command action. So there, in YourLanguageCommandSet, you can get Store by this.CurrentDocData.Store. Regards!!<hr class="sig">RubenBrenesThu, 02 Jul 2009 15:33:49 Z2009-07-02T15:33:49Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#f5f8af4d-c77d-4bed-b75d-0e93e11e8448http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/90891865-7438-46cf-8fd2-d55d816d535f#f5f8af4d-c77d-4bed-b75d-0e93e11e8448Kiran Chand Palakkattirihttp://social.msdn.microsoft.com/Profile/en-US/?user=Kiran%20Chand%20PalakkattiriHow do I select a DSL shape via APIDude, you should not create a new store for this requirement.<br/><br/>Instead, here you go!<br/><br/>1. Go to your DSL Package<br/>2. Create a partial class for your CommandSet<br/>3. Write a new method, let the name to be what ever you want<br/>4. Write your logic based on this.<br/><br/>I'll give you a sample piece of code for select all command which will work directly for you.<br/><br/><br/> <pre lang="x-c#">namespace YourNameSpace { /// &lt;summary&gt; /// Partial implementation provides the status and command /// handlers for Select All Menu /// &lt;/summary&gt; internal partial class YourCommandSet { /// &lt;summary&gt; /// Handler for select all /// &lt;/summary&gt; /// &lt;param name=&quot;sender&quot;&gt;the object that invokes the method as object&lt;/param&gt; /// &lt;param name=&quot;e&quot;&gt;event arguments as EventArgs&lt;/param&gt; protected override void ProcessOnMenuSelectAllCommand() { base.ProcessOnMenuSelectAllCommand(); List&lt;ShapeElement&gt; lstSelectableElements = this.GetSelectableElements() ?? new List&lt;ShapeElement&gt;(); foreach (ShapeElement oShape in lstSelectableElements) { if (oShape.ModelElement != null) { DiagramItem diagramItem = new DiagramItem(oShape); if (this.CurrentYourModelDocView!= null &amp;&amp; this.CurrentYourModelDocView.Diagram != null &amp;&amp; this.CurrentYourModelDocView.Diagram.ActiveDiagramView != null &amp;&amp; this.CurrentYourModelDocView.Diagram.ActiveDiagramView.DiagramClientView != null) { this.CurrentYourModelDocView.Diagram.ActiveDiagramView.DiagramClientView.Selection.Add(diagramItem); } } } this.CurrentDocView.SetSelectedComponents(lstSelectableElements); } /// &lt;summary&gt; /// Status handler for select all /// &lt;/summary&gt; /// &lt;param name=&quot;command&quot;&gt;command invokes the method&lt;/param&gt; protected override void ProcessOnStatusSelectAllCommand(MenuCommand command) { base.ProcessOnStatusSelectAllCommand(command); List&lt;ShapeElement&gt; lstSelectableElements = this.GetSelectableElements() ?? new List&lt;ShapeElement&gt;(); command.Enabled = lstSelectableElements.Count &gt; 0; } /// &lt;summary&gt; /// Gets the list of the selectable elements /// &lt;/summary&gt; /// &lt;returns&gt;gets the list of the selectable shape elements as generic collection of shape element&lt;/returns&gt; private List&lt;ShapeElement&gt; GetSelectableElements() { ReadOnlyCollection&lt;ShapeElement&gt; lstShapeElements = null; List&lt;ShapeElement&gt; lstSelectableElements = null; Store oStore = null; oStore = this.CurrentYourModelDocView.Diagram.Store; lstShapeElements = oStore.ElementDirectory.FindElements&lt;ShapeElement&gt;(true); lstShapeElements = lstShapeElements ?? new ReadOnlyCollection&lt;ShapeElement&gt;(new List&lt;ShapeElement&gt;()); lstSelectableElements = (from shape in lstShapeElements where shape is NodeShape select shape).ToList(); return lstSelectableElements; } } }</pre> Try this; You have everything selected on Select All (Ctl + A)<hr class="sig">--Kiran Chand Palakkattiri--<br/> kiran.chand@live.inWed, 08 Jul 2009 13:41:05 Z2009-07-08T13:41:05Z