file Getting all elements in a BlockDiagram

5 years 3 months ago #3290 by INTO-CPS-Rasmus
Hi,

I have created a new module with a new PropertyPage. In the PropertyPage I have added some customized parameters for a Block.

In my BlockDiagram I have several Blocks. I know want to launch a command where I get all the Block elements so I can use their parameters.

I can also currently only get my command displayed when right clicking a single Block element.


Questions:
1. Is it possible to right click a single Block and select a command, which can then find all the Block elements in the diagram? If so could someone show the code?

2. If the above is not possible. How do i define my command and the accept functions so that I can get all my block diagram elements?


Regards

Please Log in or Create an account to join the conversation.

5 years 3 months ago #3295 by INTO-CPS-Rasmus
So below is a picture of 3 Blocks. Each block have different parameters in the PropertyPage.

I would like to run the command co-simulation, where I have access to all 3 block elements, so that I can use their parameters.

Attachments:

Please Log in or Create an account to join the conversation.

5 years 3 months ago #3308 by ebr
The best would be to use the following code in your command implementation.
 public void actionPerformed(List<MObject> selectedElements, IModule module) {
        IModelingSession session = Modelio.getInstance().getModelingSession();
        IDiagramService diagramServices = Modelio.getInstance().getDiagramService();
        IDiagramHandle dh = diagramServices.getDiagramHandle((AbstractDiagram)selectedElements.get(o));

        for (IDiagramLink dl: dh.getDiagramNode().getLinks()){
            System.err.println( ((IDiagramNode)dl.getFrom()).getParent().getElement());
        }

    }

Hoping it helps,

EBR

Please Log in or Create an account to join the conversation.

Moderators: tmachmaab
Time to create page: 0.243 seconds
^ Back to Top