When running a macro, to do everything at the same time, my CAD files are saved in STEP.
The record path is in a file located in the EPDM vault. The recording is done without any problem but it remains a local file. So I would have liked to know if it was possible to archive the recording directly, please?
Indeed, macro archiving will not work if the file is opened in SolidWoprks, but if it comes from a 3D sldprt model followed by a saveAs in Step via macro, then we can consider that this step file is not open in SolidWorks and macro archiving will work.
Be careful, between the saveAs and the archive, you have to manage the time of adding to the vault...
Hello, thank you for your answers but I don't really understand... In addition, on the help there are no examples in Vba and I don't really understand the VB.net.
D.Roger when you talk about the addition time is it if I want to use it directly? Because in fact my application is used to manage the selection and activation of a 3D configuration and the opening of the drawing. At the same time I would like to offer the user the possibility to save this configuration in STEP to use it more translate.
For the moment my code is simple
If Check_step.Value = True Then
UserfrmSTEP.Show
EnregistrementSTEP = Part.SaveAs3("Chemin du dossier d'enregistrement\" & NomFichierSTEP & ".STEP", 0, 0)
MsgBox "Le fichier STEP a été enregistré dans le dossier suivant : Cjemin du dossier d'enregistrement" & Chr(10) & "Sous le nom suivant : " & NomFichierSTEP & Chr(10) & "Pensez à archiver le fichier car il se trouve encore en local", vbInformation, "Emplacement du fichier"
End If
Dispatch is a utility available in the vault's administration interface (in the tree view, add-ins and then right-click on dispatch and manage actions).
For the addition time mentioned by d.roger, this corresponds to the time it takes to process the vault to add the file to the database. As this time may vary, the file will be considered as used by an application and therefore cannot be archived via a macro. You would have to wait until SW has finished its action and the vault has finished adding the file to its database.
That's why I recommend going through dispatch which is managed directly by the vault and is applied at the right time.
For VBA version lockfile:
Private Sub LockMyFile(vault As EdmVault5)
On Error GoTo ErrHand
Dim folder As IEdmFolder5
Set folder = vault.RootFolder
Dim file As IEdmFile5
Set file = folder.GetFile("MyFile.txt")
file.LockFile folder.ID, Me.hWnd
Exit Sub
ErrHand:
Dim ename As String
Dim edesc As String
vault.GetErrorString Err.Number, ename, edesc
MsgBox ename + vbLf + edesc
End Sub
Here is an example in C# to save a step sldprt file in Epdm with archiving of it:
private SldWorks swAppli;
private void Button8Click(object sender, EventArgs e) { We cling to SW if (swAppli == null) { swAppli = (SldWorks)Activator.CreateInstance(Type.GetTypeFromProgID("SldWorks.Application")); swAppli.Visible = true; }
We connect to the safe EdmVault5 vault; vault = new EdmVault5(); if (!vault. IsLoggedIn) { while (!vault. IsLoggedIn) { Vault. LoginAuto("Coffre_BE", this. Handle.ToInt32()); } }
We recover the open SW part ModelDoc2 Part = null; Part = ((ModelDoc2)(swAppli.ActiveDoc));
We define the destination folder of the step file IEdmFolder5 folder; folder = vault. GetFolderFromPath(@"C:\Coffre_BE\TEST");
We define the full name of the STEP file string fileSTEP = folder. LocalPath + @"\" + Part.GetTitle() + ".step";
The file is saved in STEP format if (Part.GetType() == (int)swDocumentTypes_e.swDocPART) { Part.SaveAs(STEP file); }
We add the STEP file to the trunk int fileID; fileID = folder. AddFile(this. Handle.ToInt32(), STEP file, "", 0);
We connect to the STEP file created in the vault IEdmFile5 newFileSTEP = null; IEdmFolder5 ParentFolder = null; while (newFileSTEP == null) { try { newFileSTEP = (IEdmFile5)vault. GetFileFromPath(STEPFILE, out ParentFolder); } catch (Exception) {
} }
We archive the STEP file newFileSTEP.UnlockFile(this. Handle.ToInt32(), "Create STEP file.", 0, null); }