Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Long shot - swDocumentMgr.dll API calls 1

Status
Not open for further replies.

handleman

Automotive
Jan 7, 2005
3,411
0
0
US
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!
 
Replies continue below

Recommended for you

No, I have not had time to play with it. The Document Manager APIs allows you to get information from a SolidWorks file (like configuration information) without the document open or even having SolidWorks installed. I have the help file for SW2005 but SolidWorks has told me that it is included with SolidWorks 2007. I do not know if it will do what you want.

SA
 
SolidAir said:
The Document Manager APIs allows you to get information from a SolidWorks file (like configuration information) without the document open or even having SolidWorks installed.

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 Classfac As SwDocumentMgr.SwDMClassFactory
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.

SolidAir said:
I have the help file for SW2005

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.

CorBlimeyLimey said:

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.
 
Handleman,

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
 
Sweet! All the more reason to try to push Management for '07. We've had the CDs for a while. The only issue is that our hoky "department software doorkeeper" used the same serial number to install all our seats. And now she's gone. There's nobody assigned to actually do the new install. I think it needs to be done by admin image with each seat getting its rightful serial # to comply with the looming seat locking that's been discussed here before. I've volunteered to do it, but I still haven't gotten the go-ahead.

SolidAir said:
For earlier versions of SW, you will have to contact SolidWorks API Support to get a license key and.

And? And? Pay through the nose? Grovel? Hope it works? Don't leave me hanging, man! :p

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!
 
Handleman,

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
 
It was probably to keep competitors from access the files data......only parteners and customers. Guess its wide open now.

Jason

UG NX2.02.2 on Win2000 SP3
SolidWorks 2006 SP5.0 on WinXP SP2

 
SolidAir,

Here's the reply I got from our VAR:

I have someone looking into whether or not the swDocumentMgr.dll API can
be used by end-users. If it is, then I am told that you cannot use the
calls in a text macro. It can only be used in a compiled code. We'll let
you know soon.

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.
 
handleman,

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
 
Thanks once more, SA! Late this afternoon I gave up waiting on my VAR and found a link on the SW API Support site that said the swDocumentMgr.dll stuff was available since SW2004, but to contact API support for more information. So I forwarded a link to that page to my VAR and sent an email to APISupport myself. We'll see what happens come Monday. I'd star you again if I could... Perhaps if there's not a distribution limitation I'll be able to post the finished macro for anyone who might be interested.
 
Handleman,

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
 
Nope, no answer on my end. I emailed my VAR yesterday and got the response that nobody at SW had responded to them. Now I'm on vacation until 11/1, and I used my work address, so if SW or my VAR does respond I won't know until then.
 
It's almost getting too late to resurrect this thread, but here goes anyway. I would have gotten a response from SolidWorks about 3 days (including a weekend) after my first email to apisupport. However, a subtle typo in my email address by the guy at SW really caused some confusion. Apparently, the undelivered email never got bounced back to SW, so they thought I already had it. I finally did get my license key string today.

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!
 
I know this thread hasn't been opened in a while but I was wondering if anyone knows of a way to write to SolidWorks external file references. I know there is a way to ListExternalFileReferences2 but I have not found a way to actaully write to them. I am trying to mimic the File, Save As, References..., Edit Referenced File Locations. I want to be able to write a program to automatically save files that are incontext anyway I want.

Thanks.
 
Agridion,

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
 
Status
Not open for further replies.
Back
Top