-
Re: Macro to know if a file exist in Vault ?
Deepak Gupta Jul 18, 2015 12:19 PM (in response to Mofel Mofel)Here is an example: Get Document Referenced by Drawing View Example (VBA)
-
Re: Macro to know if a file exist in Vault ?
Mofel Mofel Jul 18, 2015 12:33 PM (in response to Deepak Gupta)Thanks Gupta for your reply but this is for an open draw.
My macro is a batch so i don't have any draw open and any view selected.
You don't have any example corresponding more to i need to do ?
Thanks
Mofel
-
Re: Macro to know if a file exist in Vault ?
Deepak Gupta Jul 18, 2015 1:05 PM (in response to Mofel Mofel)Don't have a macro but I remember making a batch macro to save referenced model (though all files were on local hard disk and not vault)
-
Re: Macro to know if a file exist in Vault ?
Mofel Mofel Jul 18, 2015 1:30 PM (in response to Deepak Gupta)Thanks again for your help; i tried all day long and didn't manage to make it through the vault.
Another solution to solve my problem would be to "guess" the part or the assembly name which in 98% of the case is the same than the draw (the 2% can be done manually for now).I works well but:
I use this to get the part or the assembly in local:Set doc = alldocs(fileprt)
doc.Save "C:\temp dir\"
It works well; i get the assembly and the prt and after save it in .step with another Sub in the macro.
The problem is as i need to guess the file name and don't know if it is a .sldprt or .sldasm when i have an error the script kill.
How in VBA, can i catch the error and try another name of file ?
Thanks for your help !
Mofel-
Re: Macro to know if a file exist in Vault ?
Deepak Gupta Jul 18, 2015 1:58 PM (in response to Mofel Mofel)File extension or model type can be found. Are the files in the vault when you run the macro. If yes then I feel you would have to check then out, activate the model and then save as step file. And finally delete all local files
-
Re: Macro to know if a file exist in Vault ?
Mofel Mofel Jul 19, 2015 4:30 AM (in response to Deepak Gupta)Thanks Deepak for your advises.
i finally made a function that return the first part found in the draw (we could return an array but i don't need it)
As i'm a beginner in VBA i'm pretty sure that there is few things to optimize. Do not hesitate to let me know !
' the function don't check that the file exist... you should check it before or add it in the function.
Function GetFilePartFromDraw(sDocFileName As String)
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc
Dim nDocType As Long
Dim nErrors As Long
Dim nWarnings As Long
Set swApp = CreateObject("SldWorks.Application")
Dim swSelMgr As SldWorks.SelectionMgr
Dim swDrawModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Dim swView As SldWorks.View
Dim swActiveView As SldWorks.View
Dim bRet As Boolean
' Determine type of SolidWorks file based on file extension
If InStr(LCase(sDocFileName), "slddrw") > 0 Then
nDocType = swDocDRAWING
Else
Exit Function
End If
Set swModel = swApp.OpenDoc6(sDocFileName, nDocType, _
swOpenDocOptions_Silent, "", nErrors, nWarnings)
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
Set swActiveView = swDraw.ActiveDrawingView
Set swView = swDraw.GetFirstView
While Not swView Is Nothing
If swView.GetReferencedModelName <> "" Then
GetFilePartFromDraw = swView.GetReferencedModelName
swApp.CloseDoc (sDocFileName)
Exit Function
End If
bRet = swDraw.ActivateView(swView.GetName2):
If False = bRet Then
bRet = swDraw.ActivateSheet(swView.GetName2)
End If
Set swView = swView.GetNextView
Wend
swApp.CloseDoc (sDocFileName)
End Function
-
Re: Macro to know if a file exist in Vault ?
Deepak Gupta Jul 20, 2015 5:28 AM (in response to Mofel Mofel)So how do you intend to run it with WPDM?
-
-
-
-
-
-