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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Translate the entire conversation x

Export customized Ribbon text encoding Creo 9.0.6.0

bobrikula
7-Bedrock

Export customized Ribbon text encoding Creo 9.0.6.0

Creo 9.0.6.0


Dear PTC team, 

I want to figure out how to customize Ribbon via Creo TOOLKIT. To do it I launch an example from Creo 9.0.6.0\Common Files\otk\otk_cpp\x86e_win64\obj called otk_install.zip. When the auxiliary application is active I see that the Ribbon has changed and have a new group (20250228_screenshot_1.png).

 

To save Customized Ribbon I follow the next steps from the User's guide:
1. Go to File -> Options -> Options

2. In "Creo Parametric Options" window go to Ribbon press Export->Save Auxiliary Application user interface

Then I check resulting toolkitribbonui.rbn (attached) or creo_parametric_customization.ui (depends on Export option) and can read nothing cause the encoding is incorrect.
It seems strange cause initial file otk_install_test.rbn is readable. 
What 's interesting is that if I try to import Ribbon from the creo_parametric_customization.ui file, it works seamlessly, which makes me think that this file has a standard encoding for Creo.

What I tried to do:
1. Open the file with different encodings in Notepad and Visual Studio Code.

2. Use python script to open the file in binary format and then guess the encoding using 

chardet.universaldetector.UniversalDetector() 
3. Change Region Settings (20250228_screenshot_1.png)
4. Ask ChatGPT
 
Am I doing anything wrong?
How to add new buttons to Ribbon and save customization?
ACCEPTED SOLUTION

Accepted Solutions

I found out that there is no necessity to modify directly any *.rbn file to get the Ribbon updated.

I followed the next steps from the html manual (<Creo directory>\Common Files\otk_cpp_doc\objecttoolkit_Creo\index.html) and it worked:
Set the configuration option tk_enable_ribbon_custom_save to yes before customizing the ribbon user interface. The steps to add commands to the Creo Parametric ribbon user interface are as follows:

 

  1. Create a Creo Object TOOLKIT C++ application with complete command definition, which includes specifying command label, help text, large icon name, and small icon name. Designate the command using the pfcUICommand::Designate.
  2. Start the Creo Object TOOLKIT C++ application and ensure that it has started or connected to Creo Parametric. The commands created by the Creo Object TOOLKIT C++ application will be loaded in Creo Parametric.
  3. Click File ▶ Options. The Creo Parametric Options dialog box opens.
  4. Click Customize Ribbon.
  5. In the Customize the Ribbon list, select a tab and create a new group in it or create a new tab and a group in it.
  6. In the Choose commands from list, select TOOLKIT Commands. The commands created by the Creo Object TOOLKIT C++ application are displayed.
  7. Click Add to add the commands to the new tab or group.
  8. Click Import/Export ▶ Save the Auxilliary Application User Interface. The changes are saved to the toolkitribbonui.rbn file. The toolkitribbonui.rbn file is saved in the text folder specified in the Creo Object TOOLKIT C++ application registry file. For more information refer to the section on About the Ribbon Definition File.
    Note
    The Save the Auxilliary Application User Interface button is enabled only if you set the configuration option tk_enable_ribbon_custom_save to yes.
  9. Click Apply. The custom settings are saved to the toolkitribbonui.rbn file.
  10. Reload the Creo Object TOOLKIT C++ application or restart Creo Parametric. The toolkitribbonui.rbn file will be loaded along with the Creo Object TOOLKIT C++ application.


The code to create a command:

#include <wfcSession.h>
#include <pfcGlobal.h>
#include <pfcCommand.h>
#include <pfcUI.h>
#include <pfcExceptions.h>
#include <wfcClient.h>
#include <fstream>


static ofstream logFile;

class MyCallBack : public virtual pfcUICommandActionListener
{
public:
	void OnCommand();
};


/* Entry */
extern "C" int user_initialize(
	int argc,
	char *argv[],
	char *version,
	char *build,
	wchar_t errbuf[80])
{  
	try
	{
		pfcSession_ptr		Session = pfcGetProESession ();
		wfcWSession_ptr wSession = wfcWSession::cast (Session);

		pfcUICommand_ptr InputCommand1 = wSession->UICreateCommand("My_command", new MyCallBack() );        
		InputCommand1->Designate ("msg_user.txt", "My_label", "My_help", "My_description");

		return (wfcTK_NO_ERROR);
	}
	xcatchbegin
		xcatchcip (Ex)
		logFile << "Exception:\n" << Ex << endl;
	return (wfcTK_NO_ERROR);
	xcatchend
}

/* Exit*/
extern "C" void user_terminate()
{
	logFile<< endl;
	logFile<< "================================================" << endl;
	logFile<< "OTK application terminated successfully."<<endl;
	logFile<< "================================================" << endl;

	logFile.close();
}

void MyCallBack::OnCommand()
{
	try
	{
		pfcSession_ptr		Session = pfcGetProESession ();

		Session->UIShowMessageDialog("Test succeeded!!", NULL);
	}
	xcatchbegin
		xcatchcip (Ex)
		logFile << "Exception:\n" << Ex << endl;
	xcatchend
}

View solution in original post

1 REPLY 1

I found out that there is no necessity to modify directly any *.rbn file to get the Ribbon updated.

I followed the next steps from the html manual (<Creo directory>\Common Files\otk_cpp_doc\objecttoolkit_Creo\index.html) and it worked:
Set the configuration option tk_enable_ribbon_custom_save to yes before customizing the ribbon user interface. The steps to add commands to the Creo Parametric ribbon user interface are as follows:

 

  1. Create a Creo Object TOOLKIT C++ application with complete command definition, which includes specifying command label, help text, large icon name, and small icon name. Designate the command using the pfcUICommand::Designate.
  2. Start the Creo Object TOOLKIT C++ application and ensure that it has started or connected to Creo Parametric. The commands created by the Creo Object TOOLKIT C++ application will be loaded in Creo Parametric.
  3. Click File ▶ Options. The Creo Parametric Options dialog box opens.
  4. Click Customize Ribbon.
  5. In the Customize the Ribbon list, select a tab and create a new group in it or create a new tab and a group in it.
  6. In the Choose commands from list, select TOOLKIT Commands. The commands created by the Creo Object TOOLKIT C++ application are displayed.
  7. Click Add to add the commands to the new tab or group.
  8. Click Import/Export ▶ Save the Auxilliary Application User Interface. The changes are saved to the toolkitribbonui.rbn file. The toolkitribbonui.rbn file is saved in the text folder specified in the Creo Object TOOLKIT C++ application registry file. For more information refer to the section on About the Ribbon Definition File.
    Note
    The Save the Auxilliary Application User Interface button is enabled only if you set the configuration option tk_enable_ribbon_custom_save to yes.
  9. Click Apply. The custom settings are saved to the toolkitribbonui.rbn file.
  10. Reload the Creo Object TOOLKIT C++ application or restart Creo Parametric. The toolkitribbonui.rbn file will be loaded along with the Creo Object TOOLKIT C++ application.


The code to create a command:

#include <wfcSession.h>
#include <pfcGlobal.h>
#include <pfcCommand.h>
#include <pfcUI.h>
#include <pfcExceptions.h>
#include <wfcClient.h>
#include <fstream>


static ofstream logFile;

class MyCallBack : public virtual pfcUICommandActionListener
{
public:
	void OnCommand();
};


/* Entry */
extern "C" int user_initialize(
	int argc,
	char *argv[],
	char *version,
	char *build,
	wchar_t errbuf[80])
{  
	try
	{
		pfcSession_ptr		Session = pfcGetProESession ();
		wfcWSession_ptr wSession = wfcWSession::cast (Session);

		pfcUICommand_ptr InputCommand1 = wSession->UICreateCommand("My_command", new MyCallBack() );        
		InputCommand1->Designate ("msg_user.txt", "My_label", "My_help", "My_description");

		return (wfcTK_NO_ERROR);
	}
	xcatchbegin
		xcatchcip (Ex)
		logFile << "Exception:\n" << Ex << endl;
	return (wfcTK_NO_ERROR);
	xcatchend
}

/* Exit*/
extern "C" void user_terminate()
{
	logFile<< endl;
	logFile<< "================================================" << endl;
	logFile<< "OTK application terminated successfully."<<endl;
	logFile<< "================================================" << endl;

	logFile.close();
}

void MyCallBack::OnCommand()
{
	try
	{
		pfcSession_ptr		Session = pfcGetProESession ();

		Session->UIShowMessageDialog("Test succeeded!!", NULL);
	}
	xcatchbegin
		xcatchcip (Ex)
		logFile << "Exception:\n" << Ex << endl;
	xcatchend
}
Announcements

Top Tags