Hello J-Link Gurus,
Would anybody please be able to share a code snippet that shows how to import a simple relation into a Pro/E model using J-Link?
I have been trying unsuccessfully.
I could not make sense of how to use RelationImportInstructions in the user guide, nor find any code examples.
I was also unsuccessful getting a solution from PTC Tech support.
Any help offered would be appreciated.
TIA
Paul Stephens
Kenworth Trucks Australia
Thanks to everybody who replied.
The solution came from Ken at PTC Tech Support:
"Session session = pfcGlobal.GetProESession ();Model model = session.GetCurrentModel();RelationImportInstructions instruct = pfcModel.RelationImportInstructions_Create();model.Import("prt0001_rel.txt", instruct);"
I just had to make sure there were no comment lines in the text filethat containedthe relations before they would read in to the model.
Other replies below:
======================================================================================================
"You have to read it out – alter it – then add it all back as I recall."
=====================================================================================================================
"Attached you wil find te java script HandleParams.java.In this script there are several methods to use parameters in jlink. With thenext goal:naamParam (ModelDescriptor md, Model model, Session session, String param)==> checks if a parameter existsgetStringParam (ModelDescriptor md, Model model, Session session, String param) ==> gives the value of a String Parameter
getDoubleParam (ModelDescriptor md, Model model, Session session, String param) ==> gives the value of a double Parameter
getBoolParam (ModelDescriptor md, Model model, Session session, String param) ==> gives the value of a boolean Parameter
createParam (ModelDescriptor md, Model model, Session session, String param, String paramValue) ==> creates a new Parameter
createParamValueFromString(String s)==> converts a String value to the Parameter corresponding (integer, Double, String or boolean) value.
short java script to show params (used in async environment):
public static ModelDescriptor md = null;session = connection.GetSession();
md = pfcModel.ModelDescriptor_CreateFromFileName (objectToRetrieve );
model = session.RetrieveModel(md);
HandleParams HPars = new HandleParams();
try {
Parameters pars = model.ListParams();
System.out.println ("arraysize = " + pars.getarraysize());
for (int x=0;x<pars.getarraysize();x++){<br/>System.out.println (HPars.showParam(md, model, session, pars.get(x).GetName()));
}
}
catch ( Exception x ) {
System.out.println ( "caught exception by arraysize" + x );
}
In this code the showParam method is used, for the parameters in the Proe file. Setting params (setParam) works simular exept that you have to indicate the name of the parameter and the value as string. So HPars.setParam(md, model, session, "name parameter", "value parameter")
f.y.i. most of these methods I never used, but the showParams and the setParam methods I used for sure. So do'not worry is some do not do what they promise to do.
I hope this is what you needed. "