How do I get the model element associated to a shape and vice versa
My sixth How do I is up.
Scenario
The scenario here is really simple, we want to get the shape associated with a model element or vice versa. The focus of this How do I tackles this scenario.
Interfaces and classes needed
Code snippet
Getting the model element corresponding shape:
PresentationViewsSubject.GetPresentation(modelElement)
.ForEach(pel =>
{
ShapeElement shape = pel as ShapeElement;
//TODO: use shape
});
Getting the model element corresponding shape:
ModelElement modelElement = PresentationViewsSubject.GetSubject(shape);
//TODO: use model element
Assemblies needed
- Microsoft.VisualStudio.Modeling.Sdk.Diagrams
Stay tuned,
Pablo