How to create an auxiliary view of a Model Element using the API?

Hi, I’m developing a plug-in and for a specific functionality I need to get an existing Model Element and create an auxiliary view in a specific diagram using the API methods, but I’m struggling to do that.
One way of doing this on VP is by opening Model Explorer, right-click a Model Element > Create View in Active Diagram.
I tried to use the createDiagramElement() method from IDiagramUIModel and then change the name of the element to the same as the one I wanna replicate, but it didn’t work. I also tried to use addDiagramElement(), but I would need to pass the auxiliary view as an argument, and I just have the master view. Is there a method that creates an auxiliary view by passing the master view?
Or is there any other way to solve this problem?

Hi. You need to method createDiagramElement(IDiagramUIModel d,IModelElement m) in the DiagramManager Class. if IDiagramElement master is the Masterview you can create an auxilary view in IDiagramUIModel dia with the following code:
IDiagramElement aux=DiagramManager.instance().createDiagramElement(dia,master.getModelElement());

1 Like