Cameo Macro to Run A Macro

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Cameo Macro to Run A Macro

Postby amd0023@uah.edu » Tue Apr 16, 2019 10:41 am

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
amd0023@uah.edu
Forum Newbie
Forum Newbie
 
Posts: 12
Posts Rating:0
Joined: Mon Mar 25, 2019 8:59 am

Re: Cameo Macro to Run A Macro

Postby zet0001@uah.edu » Thu Apr 18, 2019 8:28 am

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?
zet0001@uah.edu
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:0
Joined: Thu Apr 18, 2019 8:27 am

Re: Cameo Macro to Run A Macro

Postby gdhardy1 » Thu Apr 18, 2019 12:30 pm

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.
gdhardy1
Forum Newbie
Forum Newbie
 
Posts: 8
Posts Rating:2
Joined: Thu Oct 18, 2018 11:24 am

Re: Cameo Macro to Run A Macro

Postby amd0023@uah.edu » Mon Apr 22, 2019 7:01 am

I have figured out the solution. Your code helped a lot.

Thank you!

From,
Austin M. Deavers
amd0023@uah.edu
Forum Newbie
Forum Newbie
 
Posts: 12
Posts Rating:0
Joined: Mon Mar 25, 2019 8:59 am

Re: Cameo Macro to Run A Macro

Postby amd0023@uah.edu » Mon Apr 22, 2019 8:49 am

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
amd0023@uah.edu
Forum Newbie
Forum Newbie
 
Posts: 12
Posts Rating:0
Joined: Mon Mar 25, 2019 8:59 am

Re: Cameo Macro to Run A Macro

Postby cpadilla@tamu.edu » Mon Apr 22, 2019 1:22 pm

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).
cpadilla@tamu.edu
Forum Newbie
Forum Newbie
 
Posts: 6
Posts Rating:0
Joined: Tue Feb 12, 2019 3:00 pm

Re: Cameo Macro to Run A Macro

Postby amd0023@uah.edu » Mon May 13, 2019 7:33 am

I figured out the solution. Thank you for your help!

From,
Austin M. Deavers
amd0023@uah.edu
Forum Newbie
Forum Newbie
 
Posts: 12
Posts Rating:0
Joined: Mon Mar 25, 2019 8:59 am


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 1 guest

cron