Skip to main content
1-Visitor
September 13, 2022
Solved

J-Link: can not open a model with more than 29 characters in modelName in CREO8 and CREO9

  • September 13, 2022
  • 2 replies
  • 2104 views

Hello,

 

I use J-Link, the Java language toolkit for PTC Creo Parametric.

In my test directory C:/test_dir are a model with root(master) assembly file 123456789012345678901234567890.asm.1 and related child files (other assemblies, parts, ...).

To open a model file I use the following Java code:

...
BaseSession session = connection.GetSession();
...
String modelName = "123456789012345678901234567890";
ModelType modelType = ModelType.MDL_ASSEMBLY;
String instance = null;
String dirName = "C:/test_dir";

Model model = null;
ModelDescriptor proeModelDescriptor = null;
try {
proeModelDescriptor = pfcModel.ModelDescriptor_Create(modelType, instance, modelName);
session.ChangeDirectory(dirName);
model = session.RetrieveModel(proeModelDescriptor);
model.Display();
} catch (jxthrowable jxt) {
String errorMessage = MessageFormat.format("Cannot open model ''{0}''. jxt = ''{1}''", modelName, jxt.toString()));
}

This code works fine for CREO version 1 to CREO version 7.

But for CREO version 8 and CREO version 9 the call of
model = session.RetrieveModel(proeModelDescriptor);
produces the following error message
Cannot open model \'123456789012345678901234567890\'. jxt = \'com.ptc.pfc.Implementation.pfcExceptions$XToolkitInvalidName

 

When I change the model assembly file to 12345678901234567890123456789.asm.1 and modelName to "12345678901234567890123456789" the code works.

 

Thats means I can open models with a modeName of max. 29 characters and I can not open models with a modeName of 30 or more characters.

 

Note: I can succesfull open the model in GUI CREO version 8 and CREO version 9 manually.

 

My customers have models with 30 or more characters in the modelName.
In Creo version <= 7 I can open models with 30 or more characters in the modelName.

 

What can I do to open models with a modeName of 30 or more characters in CREO version 8 and CREO version 9?

 

Thank you for your hints Thomas

 

Best answer by sjuraj

You have swapped instance and modelName.

static ModelDescriptorModelDescriptor_Create(ModelType Type, String InstanceName, /*optional*/ String GenericName)

your instance should be modelName (1234567...) and your modelName should be named generic and should be null

so you code should look like this

String instance = "123456789012345678901234567890";
ModelType modelType = ModelType.MDL_ASSEMBLY;
String generic = null;
String dirName = "C:/test_dir";

Model model = null;

proeModelDescriptor = pfcModel.ModelDescriptor_Create(modelType, instance, generic);
session.ChangeDirectory(dirName);
model = session.RetrieveModel(proeModelDescriptor);

 

you can also user RetrieveModelWithOpts to retrieve directly from non-working directory so you do not have to ChangeDiroctory and can stay in work. dri

2 replies

24-Ruby III
September 13, 2022

Hi,

please ask PTC Support. This is PTC User Community website.

sjuraj15-MoonstoneAnswer
15-Moonstone
September 13, 2022

You have swapped instance and modelName.

static ModelDescriptorModelDescriptor_Create(ModelType Type, String InstanceName, /*optional*/ String GenericName)

your instance should be modelName (1234567...) and your modelName should be named generic and should be null

so you code should look like this

String instance = "123456789012345678901234567890";
ModelType modelType = ModelType.MDL_ASSEMBLY;
String generic = null;
String dirName = "C:/test_dir";

Model model = null;

proeModelDescriptor = pfcModel.ModelDescriptor_Create(modelType, instance, generic);
session.ChangeDirectory(dirName);
model = session.RetrieveModel(proeModelDescriptor);

 

you can also user RetrieveModelWithOpts to retrieve directly from non-working directory so you do not have to ChangeDiroctory and can stay in work. dri

1-Visitor
September 17, 2022

Hello sjuraj,

 

thank you for your answer.

Yes, your solution works.

 

With kind regards, Thomas