I have a workflow which basically is:
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:
status = ProMdlDataGet(mdl, &modelData);
wcsncat(modelData.path, modelData.name, PRO_PATH_SIZE);
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
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:
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.
Hey Gabriel Zaha,
thanks for your reply.
Unfortunately both, ".device" and ".host" are empty strings.
The "modelData.path" i receive is in UNC:
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..
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