Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Test with menus with Jlink

ilson

New member
Hi
I'm trying to create a "Menu" with JLINK and I can not.
Two errors:
1 - Do not create the menu;
2 - Lock the Creo.

code:
import javax.swing.JOptionPane;
import com.ptc.pfc.pfcGlobal.pfcGlobal;
import com.ptc.pfc.pfcSession.Session;

public class helloworld {
public static void start() {
//JOptionPane.showMessageDialog(null,"Test!!!!");
try {
Session curSession = pfcGlobal.GetProESession();
curSession.UIAddMenu("MENUNAME", "Utilities", "MenuFile.txt", null);
}catch(Exception err) {
JOptionPane.showMessageDialog(null, err.toString());
}
}
public static void stop() {
//System.exit(0);
}
}


Archive MenuFile.txt

Menu
Jlink-Menu
#
#
USER Button
Test1
#
#
USER Message
Test2
#
#

Archive protk.dat

name helloworld
startup java
java_app_classpath D:\Local\JlinkHelloWord.jar
java_app_class helloworld
java_app_start start
java_app_stop stop
allow_stop true
delay_start true
text_dir D:\Local\text
end



grateful
 
" This method is deprecated. Use Customize UI dialog to create menus in Creo Parametric Ribbon UI " see the Creo Jlink user guide, chapter "Ribbon tabs, groups, ... "

+ i think the .jar file may only consist of small letters
 
I am USING CODE:

Main class
//=========================================================================
package com.ptc.jlinkexamples;
public class AddingMenu {
public static void addInputButton(Session session) {
UICommand inputCommand = null;
try {
inputCommand=session.UICreateCommand("INPUT", new MenuButtonListener());
} catch (jxthrowable x) {
System.out.println("xxxxxxxxxxx");
return;
}
try {
session.UIAddButton(inputCommand, "Windows", null,"USER Input info", "USER Gather inputs","jlexamples.txt");
}
catch(jxthrowable x){
System.out.println("xxxxxxxxxxx");
return;
}
}
public static void stop() {
System.exit(0);
}
}
//=========================================================================



Class MenuButtonListener
//=========================================================================

package com.ptc.jlinkexamples;
import com.ptc.pfc.pfcCommand.DefaultUICommandActionListener;

class MenuButtonListener extends DefaultUICommandActionListener{
public void OnCommand()
{
return;
}
}
//=========================================================================


Protk.dat file
//=========================================================================
name Testee
startup java
java_app_classpath C:\Local\Test.jar
java_app_class AddingMenu
java_app_start addInputButton
java_app_stop stop
allow_stop false
delay_start true
text_dir C:\Local\Text\
end
//=========================================================================



jlexamples.txt file, in directory ..\text
//=========================================================================
USER#Input#info
Input info
#
#
USER#Gather#inputs
Gather inputs used in my J-Link program
#
#
//=========================================================================
 

Sponsor

Articles From 3DCAD World

Back
Top