I have a problem opening my EDPM files via my macro. In my current project, I had to create a macro in order to open my files being stored in the EPDM vault or when I launch my macro, working very well when the parts are on my desktop the macro goes into Debug:
When running the macro, the files are not extracted from EPDM and this is a desire to have it read-only only. I have this problem on my workstation with my EPDM session, with my session on another workstation and on another workstation with another session so nothing to do with the psote or the session.
But I discovered something: When I open EPDM in Windows Explorer and I click on my part (no double click just click to have it in the preview) I have a window that opens:
And following this loading, not lasting 3 hours as indicated, my macro works wonderfully.
So I was wondering if anyone knew where this came from and maybe fix a problem in the autoload?
One last point, I need, for my macro to work, to click Only on 3D files, drawings are not a problem for me.
In your macro you have to start by connecting to your vault and then get the latest version of your file before opening it, I don't know how it's written in VBA but here is an example in C#:
vault1 = new EdmVault5();
if (!vault1. IsLoggedIn) { vault1. LoginAuto("Your safe", this. Handle.ToInt32()); }
IEdmFile5 file3D = default(IEdmFile5);
IEdmFolder5 folderBOM = null;
file3D = vault1. GetFileFromPath("Your File", out folderBOM);
Thank you very much for your answer because it reassures me to know that there is a solution! On the other hand, I'm starting to have some knowledge of Vba but nothing more and I don't know anything about C# language so I'll wait for other answers to know how to follow in Vba.
I believe this is a limitation of the SW API in VBA. Because if you look in the help for no documentation in VBA: http://help.solidworks.com/SearchEx.aspx?q=EdmVault5&sort=&version=2017&lang=english&prod=api
Hello, if the APIs exist in .net, I think they also exist in vba.
To help you out, you can copy the code you've been given into a C# VB.net converter. You can find several of them on the internet. Since Vba is taken from vb.net, the code will be close enough for you to understand.
From memory, there is a dll to load to access the pdm objects.
No need for a converter, there are many examples in vb.net. Here are several links: http://help.solidworks.com/2017/english/api/epdmapi/Traverse_Folders_and_Files_in_Vault_Example_VBNET.htm
Being on 2 projects simultaneously I have not yet been able to carry out tests but I should be able to today on the other hand I have some questions following your answers:
- For the ddl loaded, I don't know how to do it... Is it a file to download? A file to link only to my parts? - In the codes I was able to go through like d.roger 's I noticed that there was a LoginAuto function, how does it work? Because I have to connect to EPDM through this window:
Will this feature conflict with my usual login method? Maybe I'm misinterpreting the term "Auto".
Because ideally I would like that when launching the macro there is a connection check to EPDM (thanks to the window above) and if so then load the documents in the cache when necessary.
But before I get into the code, wouldn't it be easier to modify the EPDM settings like "Clear cache on logout" or other like in the attachment.
For the connection, it won't conflict. LoginAuto uses local connection parameters so if login/mdp is requested at login, the window will be presented.
When it comes to clearing the cache when you log out, you really have to weigh the pros and cons. This has an impact on the extracted files (the assemblies especially if my memory is correct) and can generate the loss of work. It all depends on your archiving rules and the rigor of your users.
For the rest, there are indeed no more examples in vba (on the 2009 there were) but from VB.NET you can find your way around. However, there will still be features reserved for C# and VB.NET.
For the DLL to be loaded, this is necessary for programs in C#. In VBA you just have to reference "PDMWorks Enterprise 20xx Type Library" in your macro, see the attached image.
Otherwise, I think it's more interesting to start learning a language like VB.net or C# which allow you to do a lot more things either in the form of macros or in the form of independent programs that allow you to easily control EPDM and/or SolidWorks, but that's just a personal opinion. There are excellent courses for learning these languages on different sites such as https://openclassrooms.com/courses/apprenez-a-developper-en-c
For this project, I'm going to try to be satisfied with the Vba because I'm on an internship and unfortunately I won't be hired and the people who will use my program barely have the basics of Vba...
But for future applications, I will dwell on it more. On the other hand I have a very stupid question, how is it better than the Vba? More possibility? Are they also programs to be coded in a specific module of a software or is it independent? (Just small questions to get an idea before I start learning)
The Vb.net is indeed much more similar to VBA and therefore easier to learn, C# is much less "wordy", it's a matter of taste.
For macros in C# or VB.net in SW, I create DLLs and when I insert new buttons in SW I use these DLLs, see attached image. I ended up making a DLL that is only used to read a text file in which I put the path of my main executable and then to launch this executable, it allows me to have much more flexibility on my programs.
For my programs, I use the open source SharpDevelop IDE.
How is it better than the Vba? More possibility? : Visual Basic for Applications (VBA) is an implementation of Microsoft Visual Basic, VB.NET or C# are programming languages in their own right. MUCH more possibilities.
Are they also programs to be coded in a specific module of a software or is it independent? Independent programming (creating executables), using an IDE such as Visual Studio Community or Sharpdevelop makes things a lot easier.
Indeed it looks more interesting! So it's decided after my project, I'm moving on to learning VB.net.
But regarding my problem I tried the macro of d.roger and the beginning seems to work because when I click on a choice, I have the EPDM connection window that opens.
But the following line doesn't seem to do its job, unless it doesn't fix my problem:
'Active la seconde ComboBox lorsqu'un type est sélectionné dans la 1er liste
Private Sub CBox_etat_Click()
'Déclaration des varaibles nécessaires
Dim Part As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long
Dim longwarnings As Long
Dim swModel As ModelDoc2
Dim swDesignTable As DesignTable
Dim xlWS As Worksheet
Dim DebutDesignation As Range
Dim r As Range
Dim Vault As New EdmVault5
Dim File As IEdmFile5
Dim Folder As IEdmFolder5
Vault.LoginAuto "Nom_coffre", 0
If Info_general.CBox_type.Value = ("Pince W25") Then
'Ouverture du fichier correspond au besoin choisi dans la liste
'Chemin à changer lors du changement d'emplacement des fichiers EXEMPLE : Lors de l'insertion dans l'ePDM
If CBox_etat.Value = ("Pince finie") Then
Set File = Vault.GetFileFromPath("Chemin + nom de fichier", Folder)
Set Part = swApp.OpenDoc6("Chemin + nom de fichier", 1, 0, "", longstatus, longwarnings)
swApp.ActivateDoc2 "Nom fichier", False, longstatus
'Activation du modèle ouvert, nécessaire pour accéder à la famille de pièces
Set swModel = swApp.ActiveDoc
'Récupération de la famille de pièces
Set swDesignTable = swModel.GetDesignTable()
'Si récupération correcte de la famille de pièces
If Not swDesignTable Is Nothing Then...........................
Here's some of my code and the "object not set" error appears on the part family recovery line.
Edit: I think it has an impact but when I run my File, Part and swDesigntable = Nothing varaibles step by step but I don't see the problem it works if I load the previous version manually.