What is the best practice for the class that sets up the commands that you
launch in Creo 2.0?
The way I am doing it now is under startup command;
cmd = session.UICreateCommand(
"Test Command", new TestCommand_CmdListener());
cmd.SetIcon("test_command.gif");
cmd.Designate(GlobalVariables.MESSAGE_FILE, "TestCommand
Label", "TestCommand Help",
null);
Then later in this same file;
public class TestCommand_CmdListener extends
DefaultUICommandActionListener {
@Override
public void OnCommand() {
try {
Experimental.CreateFGLStruts(session, log);
} catch (Exception e) {
MiscFunctions.WriteLog("Error in Test: " + e.toString(),
log);
}
}
}
Is it better to keep the cmd_listener short and sweet? Or is it ok to fill
it with lots of code? Like this;
public class ImportCartesianPoints_CmdListener extends
DefaultUICommandActionListener {
@Override
public void OnCommand() {
String templateModelName = "import_points_start_part";
String newModelName = ("imported_points");
String userDefinedFilename = null;
try {
FileOpenOptions Create_option =
pfcUI.FileOpenOptions_Create("*.pts");
userDefinedFilename =
MiscFunctions.GetUserDefinedFilename(session, Create_option, log);
} catch (Exception e) {
MiscFunctions.WriteLog("Exception thrown by
GetUserDefinedFilename: " + e.toString(), log);
}
try {
userDefinedFilename = userDefinedFilename.replace("\\",
"/");
Geom.ImportDatumPoints(session, templateModelName,
newModelName, userDefinedFilename, log);
} catch (Exception e) {
MiscFunctions.WriteLog("Exception thrown by
Dome_Import_Points_CmdListener method: " + e.toString(), log);
}
}
}