Page 1 of 1

Cameo Macro to Run A Macro

PostPosted: Tue Apr 16, 2019 10:41 am
by amd0023@uah.edu
Dear Forum Member,

I am wanting to write a macro to open a project and run a macro automatically to open a diagram in that project while closing all others.

I know how to run a macro and write a macro to open a project and open a diagram in that project while closing all others.
But, I am trying to open the diagram by running a macro automatically in the project opened by a macro.

If this helps any, my question can be reduced to: In the Cameo API, what are Tools and Tools->Macro, etc. called?
This may point me in the right direction to open a macro in Cameo.

Otherwise, I really do not have any idea at the moment what process I would have to go through to open a macro in Cameo.
I have looked at the Cameo API 18.5 SP3 documentation, and I can find the two interfaces MacroChange and MacroDifference.
But, the macros do not reveal any information about what it takes to write a macro to open a project and run a macro automatically
to open a diagram in that project while closing all others.

Any assistance on this issue would be tremendously appreciated.

Thank you!

From,
Austin M. Deavers

Re: Cameo Macro to Run A Macro

PostPosted: Thu Apr 18, 2019 8:28 am
by zet0001@uah.edu
I think the piece that Austin is missing is the ability to auto-run a macro on opening a project. I know this is possible in Excel; does Cameo have this functionality?

Re: Cameo Macro to Run A Macro

PostPosted: Thu Apr 18, 2019 12:30 pm
by gdhardy1
I haven't tried this but I think it could work.

Store the "open diagram and close all others" part of the macro in an opaque behavior in the project that will be opened.

Run a macro that opens the new project and then does the following:

Get the active project via the Application class's getProject() method.

Use the Finder class to find the opaque behavior

Use the com.nomagic.magicdraw.expressions.ExpressionHelper class getBehaviorExpression() method to get the macro content

Use the ExpressionHelper call() method to execute it.

I hope this works/helps.

Re: Cameo Macro to Run A Macro

PostPosted: Mon Apr 22, 2019 7:01 am
by amd0023@uah.edu
I have figured out the solution. Your code helped a lot.

Thank you!

From,
Austin M. Deavers

Re: Cameo Macro to Run A Macro

PostPosted: Mon Apr 22, 2019 8:49 am
by amd0023@uah.edu
Is this same thing possible when one opens a project normally without a macro?

In other words, a user opens a project from the Teamwork Server and the macro runs upon opening the project normally. Is this possible?

If not, is it possible for a user to open a local project normally and the macro runs upon opening the project as such?

Thank you!

From,
Austin M. Deavers

Re: Cameo Macro to Run A Macro

PostPosted: Mon Apr 22, 2019 1:22 pm
by cpadilla@tamu.edu
amd0023@uah.edu wrote:Is this same thing possible when one opens a project normally without a macro?

In other words, a user opens a project from the Teamwork Server and the macro runs upon opening the project normally. Is this possible?

If not, is it possible for a user to open a local project normally and the macro runs upon opening the project as such?

Thank you!

From,
Austin M. Deavers


It sounds like you may want to implement a Java Plugin that registers a ProjectEventListener and overrides the projectOpened(Project project) event method. If you do this, no macros are needed anymore since you can just type everything out using MagicDraw Java API calls (the opening and closing of diagrams).

Re: Cameo Macro to Run A Macro

PostPosted: Mon May 13, 2019 7:33 am
by amd0023@uah.edu
I figured out the solution. Thank you for your help!

From,
Austin M. Deavers