I'm looking for the command to use in my SolidWorks macro to check in the PDM vault (EPDM) if the file name I'm automatically generating is unique or not.
I manage to do this check with the code below:
Sub CheckFileNameUnique()
Set PDMVault = ConnectToVault("MyVaultName")
If PDMVault.IsLoggedIn = True Then Debug.Print "Already logged in" Else End If
Set Search = PDMVault.CreateSearch() Set SearchResult = Search.GetFirstResult
While Not SearchResult.Name = "033244.SLDPRT" Debug.Print SearchResult.Name Set SearchResult = Search.GetNextResult() Wend
Debug.Print "Found!! "
End Sub
But the processing time is too long. I would like to have the same response time as when you start archiving and the file name is not unique; In this case, the control is instantaneous! It should therefore be possible to do so via the macro...
If you have a solution to suggest to me, I thank you in advance.
In vba, unless I'm mistaken, it is impossible to do this control. As far as I know, it's more the behavior of an addin that would be coded in C# or VB.Net that can access the internal features of PdmWorks.
Finally, if not in the way of doing things (which is long since the scan of the entire database is launched and then analyzed), I think it is better to launch a search for the reference concerned as a criterion. The processing time will probably be better.
Set folder = vault. GetFolderFromPath("... ") 'populate the vault root Search.StartFolderID = folder.ID Search.FindFolders = False Search.Filename="033244.SLDPRT" Then apply the treatment if found or not.
@ KVuilleumier, I asked myself the same question but I think it must be so that I don't have to change my name after trying to archive it. But if not, yes, just forbid duplicates.
In fact, I'm working on a macro that we're going to run on an assembly before launching in production.
The goal is, for each part and sub-assembly used in the processed assembly, to automatically retrieve the article numbers and other information from the ERP and use them to generate the name of the new file created via a "save as".
That's why I want to check at this time if the auto-generated name is unique or not. If you wait for the user to check in the assembly to notice that some names are not unique. It will have to list these files, make new "save as" but manually and restart the macro.