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

working on temp ProMdl

Newbie

working on temp ProMdl

Hey,

I have a workflow which basically is:

  • open creo
  • load/create ProMdl
  • do some regular stuff and save ProMdl.
  • do some other stuff I do not want to be saved.
  • close creo

My Idea is to call "ProMdlSave()" after I am done with my regular stuff. Then clear the session with "ProMdlErase()", "ProMdlRetrieve(saved model)" and "ProObjectwindowCreate(..)", "ProMdlDisplay" and "ProWindowActivate".

The Problem with that is, that I do not know how to change my Current working Directory. I am trying:

ProMdldata modelData;

status = ProMdlDataGet(mdl, &modelData);

wcsncat(modelData.path, modelData.name, PRO_PATH_SIZE);

ProDirectoryChange((ProPath)modelData.path);


But the File I am working on is stored on a network drive and I think this is causing the error... Does someone has an idea on how to get the correct path. Or create a temp copy of my mdl?
best regards and thanks in adavance

3 REPLIES 3

Re: working on temp ProMdl

The "wcsncat(modelData.path, modelData.name, PRO_PATH_SIZE);" line concatenates the name of the model (without extension) to the file path. This way you get an incomplete path of the model file. I think that is what is causing the error.

What you are looking for is to get the name of the directory where the file is stored. For this you need to concatenate the modelData.device with the modelData.path:

Something like:

ProPath workingDir;

...

wcscpy(workingDir, modelData.device);

wcscat(workingDir, L":");

wcscat(workingDir, modelData.name);

ProDirectoryChange(workingDir);

The above code should work if you are using mapped network drives. If you want to use UNC paths then you should replace modelData.device with modelData.host

Another way to do it is to use ProMdlLoad. This function allows you to load model that are stored in directories different than the working directory. I don't recommend to use ProMdlLoad when you are working with assemblies or drawings. For standalone parts it should work fine.

Re: working on temp ProMdl

Hey Gabriel Zaha,

thanks for your reply.

Unfortunately both, ".device" and ".host" are empty strings.

The "modelData.path" i receive is in UNC:

+"\\Server.Name\UserName$\My Documents\DestinationFolder\"

If I set  ProDirectoryChange to this path i get: PRO_TK_INVALID_NAME ... do I have to format this path?

And for Load I got the same problem to find the correct path

//edit: I am trying a new way: use creo save as function to save a local stored copy... do my stuff on the local stored copy... and delete the copy afterwards

//edit 2:  Re: How to access the hidden UNC path with "$" in Creo   <- this seems to be the reason why it is not working. Although I find it very strange.. because I am able to work with Creo using files stored on network devices... (Creo 2.0)... but API is not able to??? wired..

Re: working on temp ProMdl

I think you are right. Hidden UNC paths can be tricky. In these circumstances I'd look at two possible ways:

1. Since the model is already in memory I'd look to see if there is a way to skip the model erase and retrieval steps.

2. If first option is not applicable then I would use a local copy - same way as you described