smartanand
New member
Hi,
I am trying to write a synchronous jlink application which will get the value of a specific parameter like "Created by" or some other parameter without opening the model.
I have the class path settings and other stuffs correct as I am able to use example applications in the jlink installation directory.
Please find my code below
import com.ptc.cipjava.*;
import com.ptc.pfc.pfcSession.*;
import com.ptc.pfc.pfcGlobal.pfcGlobal;
import com.ptc.pfc.pfcModel.*;
import com.ptc.pfc.pfcModelItem.Parameter;
import javax.swing.JOptionPane;
public class GetParameter{
private static Session cursession;
public static void main(String []args)
{
String path = "D:\\JLink\\ProEModels";
ModelDescriptor descr;
Model model;
String modelname = "Test.prt";
try
{
descr = pfcModel.ModelDescriptor_Create (ModelType.MDL_PART, modelname, null);
descr.SetPath(path);
cursession = pfcGlobal.GetProESession ();
model = cursession.RetrieveModel(descr);
Parameterparam1 = model.GetParam("Length");
String length = param1.GetValue().toString();
msgBox ("Parameter value is "+length);
} catch (jxthrowable e)
{
e.printStackTrace();}
}
public static void msgBox (String msg)
{
String title = "ProE";
JOptionPane.showMessageDialog (new java.awt.Frame (),msg,title + " Error",JOptionPane.ERROR_MESSAGE);
}
}
But when i open proE, it says Application GetParameter failed in a message box.
I have created the same folder structure as of sample application like parameter editor in jlink directory.
Please help me to resolve this issue.
Regards,
Anand.C
I am trying to write a synchronous jlink application which will get the value of a specific parameter like "Created by" or some other parameter without opening the model.
I have the class path settings and other stuffs correct as I am able to use example applications in the jlink installation directory.
Please find my code below
import com.ptc.cipjava.*;
import com.ptc.pfc.pfcSession.*;
import com.ptc.pfc.pfcGlobal.pfcGlobal;
import com.ptc.pfc.pfcModel.*;
import com.ptc.pfc.pfcModelItem.Parameter;
import javax.swing.JOptionPane;
public class GetParameter{
private static Session cursession;
public static void main(String []args)
{
String path = "D:\\JLink\\ProEModels";
ModelDescriptor descr;
Model model;
String modelname = "Test.prt";
try
{
descr = pfcModel.ModelDescriptor_Create (ModelType.MDL_PART, modelname, null);
descr.SetPath(path);
cursession = pfcGlobal.GetProESession ();
model = cursession.RetrieveModel(descr);
Parameterparam1 = model.GetParam("Length");
String length = param1.GetValue().toString();
msgBox ("Parameter value is "+length);
} catch (jxthrowable e)
{
e.printStackTrace();}
}
public static void msgBox (String msg)
{
String title = "ProE";
JOptionPane.showMessageDialog (new java.awt.Frame (),msg,title + " Error",JOptionPane.ERROR_MESSAGE);
}
}
But when i open proE, it says Application GetParameter failed in a message box.
I have created the same folder structure as of sample application like parameter editor in jlink directory.
Please help me to resolve this issue.
Regards,
Anand.C