Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Are people using Object Toolkit (C++)? We have several Creo custom utilities written with Toolkit (C), but I was curious if other developers have switched to using Object Toolkit (C++) when possible.
Here's my current understanding of the 2 APIs:
Toolkit (C) Pros:
Toolkit (C) Cons:
ProMdl pro_mdl;
pro_error = ProMdlCurrentGet(&pro_mdl);
ProMdlName pro_ wszMdlName;
pro_error = ProMdlMdlnameGet(pro_mdl, pro_wszMdlName);
Object Toolkit (C++) Pros:
xstring wCurrentModelName = wSession->GetCurrentModel()->GetFileName();
Object Toolkit (C++) Potential Cons:
Seems like PTC still gives primary support to Toolkit (C). If primary would be Object Toolkit (C++) (not having to revert to Toolkit and easier to find code examples), then switching to Object Toolkit would have very few cons other than investing the time to convert/test. This could happen slowly since Toolkit and Object Toolkit commands can be mixed.
I prefer ProToolkit as I prefer C.
I would love to see a Creo version that runs on Linux. The last version that did ran was WildFire 3.
PTC develops both TOOLKIT (C, TK) and Object TOOLKIT (C++, OTK).
"Creo TOOLKIT is the primary PTC application programmer's interface (API) for Creo Parametric" (Creo 11 tkuse.pdf)
I can overview only fractions of both APIs, but it seems to me in general TK > OTK regarding to functionality.
The release notes (Common Files/protoolkit/Creo_Toolkit_RelNotes.pdf, Common Files\otk_cpp_doc\Otk_Cxx_RelNotes.pdf) give an impression on the constant API growth, see "New Functions" and "Superseded Functions".
TK and OTK both come with an API Wizard (lookup functions/classes) and user guides (wider description of concepts/context).
The user guides complement each other: you should consult both, when in doubt or not found what you needed.
Common Files\protoolkit\tkuse.pdf
Common Files\otk_cpp_doc\otkug.pdf
Code examples:
The PTC shipped examples are a good reference for more than just getting started.
I use a search tool for content searching in all *.c;*.cpp;*.cxx (or even header) files in "Common Files\protoolkit", "Common Files\otk" and "Common Files\otk_cpp_doc" (recursivly).
License:
The article you mentioned makes it clear: CS190307 "Creo Object TOOLKIT Java license requirement".
There is a TK/OTK (one for both) developer license (for unlocking TK/OTK applications).
There are separate licenses for advanced licensed features like TOOLKIT-for-3D_Drawings, TOOLKIT-for-Mechanica, TOOLKIT-for-Access_Solvers and TOOLKIT-for-Advanced_NC).
There is no runtime license.
See also: "When is a TOOLKIT license required for the developer in Creo Parametric?" https://www.ptc.com/en/support/article/CS60620
"There’s still no C#/.net API for Creo."
True, except invoking the VB/VBA (COM) API. Technically, you can start CLR code from within C++ (EXE/DLL), but the CLR code cannot simply call the TK/OTK API (although the C++ part can).
(I did it once, creating a .NET window from within a synchronous OTK application. The CLR code does not "see" the TK/OTK functions in the included TK/OTK libs. If this could be made visible to the CLR code, one could call TK/OTK functions.)
I agree to the pros and cons you listed.
Sadly, the string handling (xstring/xrstring) is still far from Java/.NET string comfort (especially if you have to care about Unicode in/output).
The fewer error handling and automatic memory management are good reasons to switch to C++/OTK (even if it is step by step in existing projects by adding C++ modules with C interfaces).
As you said, missing OTK functionality is not a problem since we can call TK C functions.
(Slightly off topic: In my (short) experience with OTK, I stumbled upon scenarios where the automatic object initialization seems to not work: on an OTK exception and stackunwinding, Creo (the OTK DLL) crashed when there was an uninitialized OTK object in scope. No crash with previous initialization - unsure if my fault.)