cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

J-Link - running mapkey recursively

DavidRodriguez
4-Participant

J-Link - running mapkey recursively

I have a J-Link program which recursively searches and retrieves all components in an assembly. I have problems to execute a mapkey on each component after its retrieval. It appears the mapkey runs multiple times but only on the LAST component found and not for each component. I've tried creating the mapkey on-the-fly and then executing it with RunMacro(), but to no avail (see below). Could the problem be that the mapkey loaded with Session.RunMacro() gets executed when control is first returned to Pro/ENGINEER?


try {
String macrostring = "mapkey aw @MAPKEY_LABELActivate Workspace";+


curSession.RunMacro(macrostring);
}
m.Save( );


Regards
David Rodriguez



This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
7 REPLIES 7


Yes, David. The RunMacro() method only runs after control has been
returned to ProE. See the section below from the J-Link API Wizard.


Mike


RunMacro







void RunMacro (StringMacro)






Runs the specified macro.

Macros may only run when control is returned to Pro/ENGINEER. If control is maintained by a J-Link program, the
macro will be stored for later running.
Manual References:
Session Objects: Macros, Session Objects: Macros, Session Objects: Macros

You are correct.
You are only loading the mapkeys (macros) which are executed only after your J-link app exits and returns control to Pro/E.
Pro/Toolkit has this same limitation.



Gerry


In Reply to David Rodriguez:



I have a J-Link program which recursively searches and retrieves all components in an assembly. I have problems to execute a mapkey on each component after its retrieval. It appears the mapkey runs multiple times but only on the LAST component found and not for each component. I've tried creating the mapkey on-the-fly and then executing it with RunMacro(), but to no avail (see below). Could the problem be that the mapkey loaded with Session.RunMacro() gets executed when control is first returned to Pro/ENGINEER?


try {
String macrostring = "mapkey aw @MAPKEY_LABELActivate Workspace";+


curSession.RunMacro(macrostring);
}
m.Save( );


Hi Jerry


Thanks for your feedback. I was afraid that this would be the case with synchronous programs that mapkeys are only executed after the J-link app exits and returns control to Pro/E. Do you have any other ideas or know a workaround to this problem?


Regards


David



In Reply to Gerry Champoux:



You are correct.
You are only loading the mapkeys (macros) which are executed only after your J-link app exits and returns control to Pro/E.
Pro/Toolkit has this same limitation.



Gerry


In Reply to David Rodriguez:



I have a J-Link program which recursively searches and retrieves all components in an assembly. I have problems to execute a mapkey on each component after its retrieval. It appears the mapkey runs multiple times but only on the LAST component found and not for each component. I've tried creating the mapkey on-the-fly and then executing it with RunMacro(), but to no avail (see below). Could the problem be that the mapkey loaded with Session.RunMacro() gets executed when control is first returned to Pro/ENGINEER?


try {
String macrostring = "mapkey aw @MAPKEY_LABELActivate Workspace";+


curSession.RunMacro(macrostring);
}
m.Save( );



Well, From what I have read, jlink runs map keys when the focus returns to
pro/e. This is on jlink programs that run from the pro/e process. The
documentation says that if you run the program a-sync then you can run map
keys without returning the focus to pro/e. I have not tried but I will try
at some point soon.

regards,

Alfonso

On Fri, Feb 3, 2012 at 1:23 PM, David Rodriguez <
-> wrote:

> I have a J-Link program which recursively searches and retrieves all
> components in an assembly. I have problems to execute a mapkey on each
> component after its retrieval. It appears the mapkey runs multiple times
> but only on the LAST component found and not for each component. I've tried
> creating the mapkey on-the-fly and then executing it with RunMacro(), but
> to no avail (see below). Could the problem be that the mapkey loaded with
> Session.RunMacro() gets executed when control is first returned to
> Pro/ENGINEER?
>
> try {
> String macrostring = "mapkey aw @MAPKEY_LABELActivate Workspace";+
> "mapkey(continued) ~ Select `main_dlg_cur` `PHTLeft.ProExplorerTab`1
> `PHTLeft.Folders`;"+
> "mapkey(continued) ~ Activate `main_dlg_cur` `workspace_pb`;";
>
> curSession.RunMacro(macrostring);
> }
> m.Save( );
>
> Regards
> David Rodriguez
>
>
>

I use a async J-Link app and it works like a charm. I can run mapkeys and wait until they finished her work.


So in async Tools everything seems to be alright.


Best regards,


Eike

Hi Eike


Great to hear that in Async mode the mapkeys wait until they finish their work. Do you know if an Aync program works with objects residing in PDMLink workspaces? My problem is that the user is logged in to PDMLink and needs to open a model from the workspace with ProE and then run the JLink program. Can one do this with an Asynchronous program and how do you which model to open from the workspace?


Regards
David



In Reply to Eike Petersen:



I use a async J-Link app and it works like a charm. I can run mapkeys and wait until they finished her work.


So in async Tools everything seems to be alright.


Best regards,


Eike


Hi David,


wait one second : ) I never mean that mapkeys wait until they finished. This you must program yourself. But its a simple workaroud. If your mapkey is finished his work you write a parameter or something in a file what you can read with your program. So you see when it is finished his work.


You can load and save files from a PDMLink workspace with J-Link programs. You can also checkout and checkin files if the PDMLink structures are simple enough. (You can get problems with wtparts and so on with basic JLink API). To open a file you only need to use its name because the workspace are in the searchpath from Creo / ProE and so it gets your file and open it.



Best regards,


Eike

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags