cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

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

ThomasStep
5-Regular Member

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

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
sjuraj
13-Aquamarine
(To:ThomasStep)

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

View solution in original post

3 REPLIES 3

Hi,

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


Martin Hanák
sjuraj
13-Aquamarine
(To:ThomasStep)

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

ThomasStep
5-Regular Member
(To:sjuraj)

Hello sjuraj,

 

thank you for your answer.

Yes, your solution works.

 

With kind regards, Thomas

Top Tags