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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Translate the entire conversation x

JS API pfcUICommand.Designate

ilyachaban
16-Pearl

JS API pfcUICommand.Designate

Hello, i've been tryign ot designate created command in PTC Creo JS API and didn't succed at all. 

Creo API can't find message file. I've been also trying to create absolute path to message file but it didn't work too. 

Here is my code example:

// 1) Get the active Creo session
var session = pfcGetCurrentSession();

// 2) Unique id for your command (make it unique per run while testing)
var COMMAND_NAME = "MyJsSampleCommand_" + (new Date().getTime());

// 3) Implement the action listener
var actionListener = pfcUICommandActionListener.create({
  OnCommand: function (commandId) {
    print("Hello from " + COMMAND_NAME + "!");
  },
  OnCommandEnable: function (commandId) {
    return pfcCommandStatus.pfcCommandStatus_Enabled;
  }
});

// 4) Create the UI command
var uiCmd = session.UICreateCommand(COMMAND_NAME, actionListener);

// 5) Designate it so it can be placed in Screen Customization
uiCmd.Designate(
  "message.txt",  // Message file
  "MyCmdLabel",      // Label key from ui_message.txt
  "MyCmdHelp",       // Help key (or null)
  "MyCmdDesc"        // Description key (or null)
);

// 6) (Optional) Assign an icon
// uiCmd.SetIcon("my_cmd_icon.gif");


Screenshot from support.ptc.com no directory described:

ilyachaban_0-1755079505570.png

 

screenshot from pdf no directory described:

ilyachaban_1-1755079643301.png

 

There is also no format and description about how does this file has to look like. 

Here is how it looks like when i run it via DevTools

ilyachaban_0-1755079802508.png

 



 

ACCEPTED SOLUTION

Accepted Solutions

Message file has to be placen not into %PRO_DIRECTORY%\text but  %PRO_DIRECTORY%\text\%YOUR_LANGUAGE%

In my case it was usascii

Whole path than looked like C:\Applic\Creo_11.0.3.0\Common_Files\text\usascii

also for icon not text file but text\resource

Whole path than looked like C:\Applic\Creo_11.0.3.0\Common_Files\text\resource

View solution in original post

7 REPLIES 7
RPN
17-Peridot
17-Peridot
(To:ilyachaban)

Make sure you have properly setup your text folder, next see your message.txt file, this is referenced in your code. There are a couple of examples, but you have to deal with message id’s due to different language environments.

ilyachaban
16-Pearl
(To:RPN)

Tell me please where is this text folder or how can i find it

RPN
17-Peridot
17-Peridot
(To:ilyachaban)

Sorry, for me Java and JS are not the right tool, due to much code writing, so I can’t really help for JS.  I use Toolkit.

 

The doc is telling about a message file, and your code is using two of them. In toolkit you specify the text folder in the registry file protk.dat or creotk.dat. You need to check the PTC documentation for one example. I guess in JS it is similar, and you need to map your string token in the given message file.

RPN
17-Peridot
17-Peridot
(To:ilyachaban)

Here some note from the tk manual. Note: Using message.txt may dangerous 😉😵💫

 

IMG_0033.jpeg

 

Hello @ilyachaban,

 

It looks like you have some responses from a community member. If any of these replies helped you solve your question please mark the appropriate reply as the Accepted Solution. 

Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,
Vivek N.
Community Moderation Team.

Web.Link User’s Guide. Accessing the Creo Parametric Interface:

Remember that Web.Link applications, as unregistered web pages, do not
currently support setting of the Creo Parametric text directory. All the resource
files for messages must be located under $PRO_DIRECTORY/text folder.
You can force Creo Parametric to load a message file by registering a Creo
TOOLKIT or J-Link application via the web page, and calling a function or
method that requires the message file. Once the file has been loaded by Creo
Parametric, Web.Link applications may use any of its keystrings for displaying
messages in the message window.

Message file has to be placen not into %PRO_DIRECTORY%\text but  %PRO_DIRECTORY%\text\%YOUR_LANGUAGE%

In my case it was usascii

Whole path than looked like C:\Applic\Creo_11.0.3.0\Common_Files\text\usascii

also for icon not text file but text\resource

Whole path than looked like C:\Applic\Creo_11.0.3.0\Common_Files\text\resource

Announcements

Top Tags