I hope the question is clear, but I can flesh out more details if a there is a pdm api expert that thinks (s)he might be able to help me.
Essentially what I am trying to do is write a solidworks macro to replace the built-in Solidworks "save as" command.
The purpose of the macro is to "save-as" solidworks documents into an automatically selected pdm folder. (Taking away the users ability to "put it in the wrong spot")
The macro is working great, but I have few problems:
Problem 1: I cannot get PDM to generate default values for the new document's card when I use the "API Save-as". The card is just blank, unlike the built-in save-as, which generates default numbers and serial numbers.
Problem 2 (attempting workaround for 1): I thought I would explicitly tell the card to generate default values after the save-as through the api. I do not know how to access the variables directly through the pdm api while it is a brand new document that hasn't been checked in yet. I attempted to access the variables like this example...
Dim var As IEdmEnumeratorVariable10
Set var = eFile.GetEnumeratorVariable
var.SetVar "Description", "@", sDescription, True
'saves card data
Unfortunately, this doesn't work because solidworks still has write access. I figure there should be a way to do this since you are able to manipulate and save the pdm data card while the file is checked out... Hence the title of the post. Anyone know if there is a trick to this? Maybe a way to temporarily give pdm write access and take it away form solidworks?? Some kind of "Soft check-in". Do I need to do a "full check-in" and if so, is it possible to do a full API checkin-data card update-checkout without closing the document in solidworks?
Problem 3(Attempting workaround for 2): The variables that I want to update are all $prp'ed to the model. I have put code in my macro to add and update the custom properties directly to the file through the solidworks api. The idea being, the properties will get then pushed to the pdm database. This almost works. Unfortunately, I have 1 field that refuses to update in pdm correctly. I can preview the datacard, and the value I have populated in the Custom Property shows up just fine, but when I check in the new file, it just gets "blanked out". see the following screenshots.
This particular field is unique, because is is a serial number generated field. (default value is a serial number). This is my best guess as to why it is the only one that doesn't "stick". Don't ask me why it ends up blank as opposed to a new serial number...
Sorry for the ramble, I hope some of this makes sense, enough to get someone that might know something on the right track to giving me some advice? I could see a solution for either Problem 1, 2, or 3 getting me where I need to go, but I'm kinda stuck right now, and I can't think of anymore workarounds.