Long shot - swDocumentMgr.dll API calls
Long shot - swDocumentMgr.dll API calls
(OP)
OK, I know this is a really long shot, but has anyone figured out how to use the swDocumentMgr.dll calls? I believe they have to do with Solidworks Explorer. They're unsupported, but I found this link showing it being used somehow. I can't read whatever the language is. Not the programming language, but the other language. It seems to require some sort of license key string - "7B6BC9E" on that website, but I'm guessing it's generated when you install SW or something like that.
The reason I'd like to use it is that I want to read the Update Stamp from the stored version of an open file and compare that value to the current value of an open SW document. To do it with SW I would have to create a copy of the file and then open the copy. Obviously that's a poor way to do it.
Anyway, as I said I think it's a long shot here, but I thought I'd give it a try before I play "Stump the VAR".
Thanks!
The reason I'd like to use it is that I want to read the Update Stamp from the stored version of an open file and compare that value to the current value of an open SW document. To do it with SW I would have to create a copy of the file and then open the copy. Obviously that's a poor way to do it.
Anyway, as I said I think it's a long shot here, but I thought I'd give it a try before I play "Stump the VAR".
Thanks!






RE: Long shot - swDocumentMgr.dll API calls
SA
RE: Long shot - swDocumentMgr.dll API calls
http
RE: Long shot - swDocumentMgr.dll API calls
That's pretty much exactly what I want to do. My goal is to write a macro that I can run at any time that will look at the documents I have open in SW and make some determination about how much work has been done since the last save. I thought about checking the Windows timestamps on the files, but that really doesn't tell you how much has changed. For example, say you open a file first thing in the morning when you arrive at work. Its "Accessed" Windows timestamp gets set to whatever time you opened it. At 3 PM you change a dimension on that part. Now it looks like you've been working on that file for 7 hours without saving. However, if I could compare the current Update Stamp with the one saved in the file I would be able to see that only 1 or 2 changes were made.
I can see from the Object Browser that it looks like swDocumentMgr will do just what I want. Based on the code on the link I referenced, I have:
CODE
Dim swDocMgr As SwDocumentMgr.SwDMApplication
Dim swDoc As SwDocumentMgr.SwDMDocument
Dim Stamp As Long
set Classfac = CreateObject("SwDocumentMgr.SwDMClassFactory")
set swDocMgr = Classfac.GetApplication("7B6BC9E")
set swDoc = swDocMgr.GetDocument([filename goes here], swDmDocumentUnknown, True, Empty)
Stamp = swDoc.GetLastUpdateStamp
It actually runs up to the "set swDocMgr..." line, but then it gives an "Automation Error". I'm pretty sure it's because I don't know how to get the License Key.
Does it give any information about how to figure out your license key? I think that's really all I need to get where I need to go.
Thanks, CBL! Totally brain farted on that one. I work for a Japanese company so I use Google Translator all the time, but I didn't even think to use it in this case. Unfortunately, it didn't help much.
Thanks both of you! I'm trying to add this functionality to my DocPick macro (thread559-152362). I've already added functionality that puts an asterisk beside documents that have been modified (based on ModelDoc2::GetSaveFlag), but I'd really like to add more asterisks the more changes have been made.
RE: Long shot - swDocumentMgr.dll API calls
What version of SolidWorks are you running? The license key is no longer required in SW2007. You can find help in SW2007 by searching for "Document Manager" in SolidWorks and Add-Ins API Help. For earlier versions of SW, you will have to contact SolidWorks API Support to get a license key and.
SA
RE: Long shot - swDocumentMgr.dll API calls
And? And? Pay through the nose? Grovel? Hope it works? Don't leave me hanging, man!
But seriously, if I get a key will it only work on my PC? If so it may not be worth the trouble.
Thanks for the great help, SA!
RE: Long shot - swDocumentMgr.dll API calls
RE: Long shot - swDocumentMgr.dll API calls
I do not know if you must be a subscription customer to get the key; it did not cost me anything to get it. I simply wrote API help and asked for it. There is no indication that the key is computer specific (I have not actually tried it yet, next project). Originally, all SW asked was that it not be given out to anyone outside the company but since the key is no longer required, I do no know if that is still true.
SA
RE: Long shot - swDocumentMgr.dll API calls
Jason
UG NX2.02.2 on Win2000 SP3
SolidWorks 2006 SP5.0 on WinXP SP2
RE: Long shot - swDocumentMgr.dll API calls
Here's the reply I got from our VAR:
Is that last statement correct to your knowledge? Can it only be used with compiled code? As far as I can tell my code is successful up to the GetApplication line. Comparing the ClassFac object to Nothing gives False.
RE: Long shot - swDocumentMgr.dll API calls
Eric
RE: Long shot - swDocumentMgr.dll API calls
I have sent a request to API support asking about distribution limitations. Normally they get back to me pretty fast but I am still waiting. I will post a proper reply when I know more.
SA
RE: Long shot - swDocumentMgr.dll API calls
RE: Long shot - swDocumentMgr.dll API calls
RE: Long shot - swDocumentMgr.dll API calls
After two trys I finally got some sort of answer from API support. Basically they stated that the dll could be distribruted inside the company. They completely side-stepped the issue of what could be done with a macro or program that uses the Document Manager API calls. Have you found out any additional information?
Regards,
SA
RE: Long shot - swDocumentMgr.dll API calls
RE: Long shot - swDocumentMgr.dll API calls
To make a long story short, the swDocumentMgr.dll calls can be used in a VBA macro. However, they do request that the license string is not distributed in any readable form outside the company the license is assigned to.
However, it's also true that the license is not required starting with 2007, and if a string is passed to 2007 it will just be ignored. Here's the macro I used this in. It should work as-is on any machine running 2007. For 2006 your own company's license string will have to be used. If you don't have one already, you can email for it as has been outlined above.
Here is the new and improved DocPick macro. There are two constants to set up to your taste, both of them stored at the very top of the code for the form.
The first is (obviously) the license key string. If you're running 2007 don't worry about that. If you're running 2006 you'll have to enter your key. If you don't have a valid key, the functionality that requires it will be disabled, but the macro will still run.
The other one is the number of changes you want to allow before being alerted on the form by an exclamation mark. This is the functionality that requires the license key. The macro will compare the Update Stamp of the document in memory to the Update Stamp of the document as-last-saved. If the Stamp in memory is more than the sum of the saved Stamp and this constant then you will be alerted that the document "Really needs saving"
There's a bit more background information in the thread I linked to above, but if anyone has any other questions please feel free to ask!
RE: Long shot - swDocumentMgr.dll API calls
Thanks.
RE: Long shot - swDocumentMgr.dll API calls
Try not to post the same question in multiple places.
However if you want to use the Document manager look at the example Get External References Example VB in API help. There are two with the same name, one for the Document Manager and one for when the file is open.
SA