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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Can someone help to create a simple j-link program?

DanielScheidegg
11-Garnet

Can someone help to create a simple j-link program?

Hi all,

My experience in java and J-Link are VERY low, and that's not really my daily business.

I think that can not be a big issue. hopefully someone can help me.

I need a program that starts with creo4 (protk.dat) and wait until the drawing is loaded. after that a mapkey should run.

the drawing will be loaded with the Creo start command (not with J-Link).

I found something that could maybe help:

OnAfterModelRetrieve and then macrostring = "~ Activate `main_dlg_cur`;%myMapkey;";

hopefully someone can help me.

Thanks and best Regards

Daniel

1 ACCEPTED SOLUTION

Accepted Solutions

I got it. I was struggling because in the workflow has something changed.

in earlier releases the application was loaded direct after Creo start, but when starting Creo with a filename like:

"C:\ptc\creo4\Creo 4.0\M010\Parametric\bin\parametric.exe" "C:\ptc\creo4\Creo 4.0\M010\Parametric\bin\parametric.psf" mydrawing.drw

the jlink application is started after the model is retrieved... and in this case i do not need a listener who is waiting for the drawing retrieved or displayed..

here my code:

public class JlinkAPP {

static int done = 0;

public static void start() {

try {

Logger.write("Application started.");

String macrostring;

Session s = pfcGlobal.GetProESession();

Logger.write("session id : " + s);

macrostring = "~ Activate `main_dlg_cur`;%mymapkey;";

Logger.write(" *** RUN macrostring ***= " + macrostring);

JlinkAPP.done = JlinkAPP.done + 1;

if (JlinkAPP.done == 1) {

s.RunMacro(macrostring);

}

} catch (Exception x) {

Logger.write("Exception start : " + x);

Logger.write("Exception mapkey: " + x);

StackTraceElement[] st = x.getStackTrace();

for (int i = 0; i < st.length; i++) {

Logger.write(st[i].toString());

}

}

}

public static void stop() {

Logger.write("Application stoped.");

}

}

View solution in original post

5 REPLIES 5

This is quite big issue if your skills in java and j-link are low. I suggest you to learn basics of java oop and basic of j-link. There are lot of tutorials for java on the internet. Pdf guide to j-link is located in creo common files in jlink directory.

Hi Juraj,

Thank you for your reply, I know that's a big thing for someone who has no skills. and i know there are a lot tutorials in the internet.

And you are right, I could learn basics of java and j-link. but that was not the question and i do not have the time for that

The question is, can someone help ore write that tool? or maybe someone has something similar?

Thanks and best regards

Daniel

I got it. I was struggling because in the workflow has something changed.

in earlier releases the application was loaded direct after Creo start, but when starting Creo with a filename like:

"C:\ptc\creo4\Creo 4.0\M010\Parametric\bin\parametric.exe" "C:\ptc\creo4\Creo 4.0\M010\Parametric\bin\parametric.psf" mydrawing.drw

the jlink application is started after the model is retrieved... and in this case i do not need a listener who is waiting for the drawing retrieved or displayed..

here my code:

public class JlinkAPP {

static int done = 0;

public static void start() {

try {

Logger.write("Application started.");

String macrostring;

Session s = pfcGlobal.GetProESession();

Logger.write("session id : " + s);

macrostring = "~ Activate `main_dlg_cur`;%mymapkey;";

Logger.write(" *** RUN macrostring ***= " + macrostring);

JlinkAPP.done = JlinkAPP.done + 1;

if (JlinkAPP.done == 1) {

s.RunMacro(macrostring);

}

} catch (Exception x) {

Logger.write("Exception start : " + x);

Logger.write("Exception mapkey: " + x);

StackTraceElement[] st = x.getStackTrace();

for (int i = 0; i < st.length; i++) {

Logger.write(st[i].toString());

}

}

}

public static void stop() {

Logger.write("Application stoped.");

}

}

Hi,

if I were you I would probably solve the procedure (i.e. open drawing & run mapkey) using trail file.

MH


Martin Hanák

Hi Martin,

shure, but this runns on nongraphics mode

Have a good time

Daniel

Top Tags