Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hello!
Anybody have detailed info about this?
http://www.ptc.com/appserver/search/results.jsp?&tag=java+toolkit
Hi Yaroslav,
You need to implement J/Link and can run an Pro/Toolkit dll from J/Link over the J/Link function:
some part from the loadDLL function:
if (pid = -1) {
loadedDll = session.LoadProToolkitDll("MP_DLL", ldllf + "\" + dllName, ldllf, true);
pid = loadedDll.GetId();
} else {
loadedDll = session.GetProToolkitDll(pid);
}
After that I use the following to use the loaded dll but that can change :
static public boolean regenerateMdlInner(Model mdl, String mode) {
boolean ret = false;
String dllName = "proeapiwf4.dll"; //NOI18N
String fktName = "solid".equals(mode.substring(0,5)) ? "regenSolidMdl" : "regenDrawingMdl"; //NOI18N
Arguments args = null;
try {
// YOU NEED TO BUILD AN ARGUMENT LIST
args = Arguments.create();
String nam = mdl.GetFileName();
if (nam.contains("<")) {
ArgValue arg0Val = pfcArgument.CreateStringArgValue(nam.split("\\<")[0]);
Argument arg0 = pfcArgument.Argument_Create("MDL_NAME", arg0Val); //NOI18N
args.append(arg0);
} else {
ArgValue arg0Val = pfcArgument.CreateStringArgValue(nam.substring(0, nam.length() - 4));
Argument arg0 = pfcArgument.Argument_Create("MDL_NAME", arg0Val); //NOI18N
args.append(arg0);
}
ArgValue arg1Val = pfcArgument.CreateStringArgValue(nam.substring(nam.length() - 4));
Argument arg1 = pfcArgument.Argument_Create("MDL_TYPE", arg1Val); //NOI18N
args.append(arg1);
} catch (jxthrowable jxt) {
}
Arguments retOuts = null;
try {
holdFunc hf = new holdFunc();
// AND THEN PUSH IT OVER TO THE DLL WITH LoadProToolkitDll --> inside the loadDLL function
retOuts = pt.loadDll(dllName, fktName, args, hf);
System.out.println("regenerateMdl:"+hf.fret.GetFunctionReturn());
ret = hf.fret.GetFunctionReturn() == 0;
if (!ret) {
retOuts = pt.loadDll(dllName, fktName, args, hf);
System.out.println("regenerateMdl:"+hf.fret.GetFunctionReturn());
ret = hf.fret.GetFunctionReturn() == 0 || hf.fret.GetFunctionReturn() == -7;
}
} catch (Exception ex) {
System.out.println("Invalid wide string failure ?");
ex.printStackTrace();
System.out.println("-.-");
//Toolkit failure
}
return ret;
}
I think its a good way to build an synchronous Toolkit applikation and an asynchronous Java application, but you need to be aware that you need a toolkit license to free the DLLs. If you programm for a user outside your company they need a toolkit license too.
Another way is to work with J/Link.
Best regards,
Eike
That is means, I'm still must to use c++ and pro\toolkit to build the DLL. And only after that I can use this DLL from program on J-Link?If so, then, unfortunately, this is not what I expected. I thought, using this binding, now I can write the pro/toolkit programs using Java instead C++ (and VS).
I heard that it is possible to use C# and VB using Pro\Toolkit. I'll search in this direction.
Thank you for the answer!
Oh ok : )
What you want is to use the other APIs.
So the APIs are as following:
C - Pro/Toolkit
C++ - Object Toolkit
Java - J/Link
Visual Basic - vbapi
JavaScript - Web/Link
So every Language has his own API support and you can use it to change things inside of Creo // Pro/E. You find the helpfiles and examples inside the Installation directory (you need to check them at the installing process) for example for J/Link at:
<install_directory>\Creo 2.0\Common Files\M080\jlink\
or
<install_directory>\Wildfire5_m180_x64\jlink\
There are demo applications, tutorials and a help documentation.
Best regards,
Eike
Yep. Now I'm using J-Link. But this API not so functional as Pro Toolkit. After some investigation I see that in any way if I'll want to use another language instead C, I'll mut to build DLL using C. So, your example with LoadProToolkitDll is most usefull way in my case.
Now need to find the way how to easily build DLL with TOOLKIT functions. )
Again, thank for your help.
Hi,
for this you need a Toolkit License. If you build it for another company think about that they need a Toolkit License too.
If you have/get one, it makes fun:
If you don't need a async. program, that is make many things that don't need the Toolkit functions, it is much easier to create your program directly in C // Toolkit (There is a fancy dialog class for Creo programs that makes it easy to create complex dialogs). If you create it in Java / C combination you need to check your thread handling that you only use one Pro/E connection from one thread per time, else your Pro/E get crashed and the handle get's blocked.
To compile and run the DLL from Java you need to create in C native Interface Methods that you can connect from Java and give native C Strings (ArgumentList in the Java API) as char array to the native C program. That can answer to the Java program also by and filles up ArgumentList. Be sure the ArgumentList didn't get to large, because you have a memory size of 2MB (or so ... not sure) per allocated memory in the Pro/E memory space. Else Pro/E get crashed.
But if it run, it is a very stable connection.
Best regards,
Eike
In Reply to Eike Petersen:
Hi,
for this you need a Toolkit License. If you build it for another company think about that they need a Toolkit License too.
I read that it is not necessary to have a licence to run TOOLKIT applications, if the DLL is unlocked.
Like described in this blog
http://cadinterface.blogspot.ru/2009/05/unlocking-protoolkit-application.html
Hi,
you're right that another user from same company don't need a toolkit license to run the program if you unlock it.
The following is something I think it's right but can't test it and are sure for now:
But there is a license thing about that. So there are two possible Toolkit License types (don't know if they are really different, or if they are only different in definition). The one is for all the company users they program for their own company and the other one is for software developers that want to sell the software. I don't know wich one you have.
Best regards,
Eike