Accurate way to get a SolidWorks Version Check on Files

Hi,
I'm wondering if anyone knows an accurate method of getting the version of a solidworks file that it was created with. Not sure if
that makes sense. lol. Basically i'm in a possition where ihave a number of backups created over a long period of time. Just created incrementley ignoring versions of files (some are not modified with newer versions of SW while others may have been). BUt basically i'd like to be able to tell what the majority of files are last saved with so that i can save them as a version specific backup.
I hope this makes sense. And i hope it can be done (but i fear not : ().
Cheers, DWH
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
it would be fairly simple to build a macro for this, based on API SldWorks::VersionHistory
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Philippe,
Thanks for your response. i'm not really up to speed with API (50hr days anyone? :)). Be thankful if anyone could lend some of their valuable time if its not to difficult.
Regards, HoffY
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

This example shows how to get the version history of a SolidWorks document.
'------------------------------------------------
'
' Preconditions: A SolidWorks document is open.
'
' Postconditions: None
'
'------------------------------------------------
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim vVerStr As Variant
Dim i As Long
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Debug.Print "File = " & swModel.GetPathName
If IsEmpty(vVerStr) Then
vVerStr = swApp.VersionHistory(swModel.GetPathName)
End If
If Not IsEmpty(vVerStr) Then
For i = 0 To UBound(vVerStr)
Debug.Print " " & vVerStr(i)
Next i
Else
Debug.Print " No version information."
End If
End Sub
'------------------------------------------------
Easy to add some lines to read for example the whole folder...
regards Markku
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Markku,
Just thought I'd ask,,,,
If the preconditions are that the file be open, don't you already know the answer ???
Mark

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
No, you don't know. The previous code will list all versions of SW that ever modified the document. LIkewise, if you look at the feature properties there will be record of all users that ever modified the file.
In fact, SW contains within itself the ability to create the model according to the older versions used in it until that older geometry is edited and replaced.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Markku,
Thank you for that! I must admit i'm no good at comlex API/Macro stuff. I'd really love to be able to pass a directory (and its sub dirs) and possibly get a read out of what version a file is currently at into an excel style layout. or even a text document would be fine.
If anyone could share their skills and time to create something like this and possibly tweak it. Would be muchly appreciated. I'm sure i'm not the only one that would like ot be able to find out file versions of prts/asms/dwgs with the running of a macro or utility. Expanded features like Created With Version, Last Saved Version could be a couple i'd find really handy just off the top of my head.
Kind Regards, HoffY
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Here's one way to handle all parts in one folder:
Sub main()
Dim swApp As SldWorks.SldWorks Dim swPart As ModelDoc2
Dim sPath As String Dim sFileSW As String Dim sFileTitle As String Dim sMsg As String Dim retval As Boolean Dim config As Variant Dim i As Variant
Const swDocPart = 1 Const swCustomInfoText = 30 Const swSaveAsOptions_Silent = &H1 Const swGenericSaveError = &H1 Const swFileSaveWarning_RebuildError = &H1
sMsg = "Working folder with \ at the end" sPath = InputBox(sMsg, "Folder", "C:\Temp\") If sPath = "" Then Exit Sub
Set swApp = CreateObject("SldWorks.Application")
sFileSW = Dir(sPath & "*.sldprt")
Do While sFileSW <> "" 'open model Set swPart = swApp.OpenDoc(sPath & sFileSW, swDocPart)
'Do something for the models '-----------------------
'read all configurations from the model config = swPart.GetConfigurationNames For i = 0 To UBound(config)
'replace the attribute value 'first remove the old one retval = swPart.DeleteCustomInfo2(config(i), "test")
'then add a new one 'retval = swPart.AddCustomInfo3(config(i), "test", swCustomInfoText, "Attr_value")
'handle next configuration Next i
'------------------------
'save
retval = swPart.Save3(swSaveAsOptions_Silent, swGenericSaveError, swFileSaveWarning_RebuildError)
'close saved part sFileTitle = swPart.GetTitle swApp.CloseDoc sFileTitle
'next file sFileSW = Dir Loop
'finished swApp.SendMsgToUser "Done..."
End Sub
It should be quite easy to combine this with the example code from the API help...
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Markku
Gosh all that code just goes right over my head. Unfort. i can understand sections but to put it all together to make it actaully do something is beyond me at this point.
How would i run that code? I tried a .swp file but it just returns "cant open file". :(
-HoffY
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
You start a new macro in SW and paste it in. Before you run it you go to the tools menu and make sure the SW type library and constants library are checked.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
snipped-for-privacy@no.com wrote:

I can try to build something more usefull during the weekend...
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Markku Lehtola wrote:

Tried to make it as simple as possible..: http://www.markkulehtola.net/wb/pages/solidworks/swxx-tools/swvc.php
Markku
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Markku,
That is awesome. Thank you very much. I downloaded it and gave it a whurl. Just to see if i could get it working and to test its accuracy. NOticed that it seemed to not report things 100% accurately. I had some parts last saved by 2007 (3400) but it doesnt seem to return that value for those. I did a directory full of the same parts created with the same version and modified mostly with the same versions over the years but only about half last saved/modified in 2007. But they all get the same versions returned.
I hate to have to ask more from your generous efforts thus far. :) I def owe you a carton of you favourite beverage. :)
Cheers, HoffY
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
snipped-for-privacy@spam.com wrote:

Hmm, maybe it's the references to 2005 that I put there, you can change them like this:
open xls, go to VB Editor (Tools-Macro-Visual Basic Editor) select Tools-References deselect "SolidWorks 2005 constant type library" and "SolidWorks 2005 type library" and select same ones but for version 2007 instead.
If that doesn't make any difference, then I don't have any ideas...just hope that there's no bug in API.
Markku
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Markku,
I'll give that a look at. It seems to only happen with multiple files in the folder. IF a single file is there it seems to give a more thorough reading of the versions instead of, say, just 3 of the exact same versions for all files listed.
Thanks.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Are you facing the problem where you have created multiple copies of the same file and now you want to eliminate those solidworks files which are same ?
snipped-for-privacy@spam.com wrote:

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
basu,
No thats luckily not the case for me. :) Its simply for an incrementle backup type situation. I'd like to go back now, through all the backups i've created and actually make a specific version backup each time i've upgraded SolidWorks.
Regards, HoffY
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Site Timeline

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.