Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Display bitmap preview 2

Status
Not open for further replies.

dogarila

Mechanical
Oct 28, 2001
594
Is it possible to extract and display the bitmap preview of a part or assembly from a VB6 exe program? There is some information in the SW API help but it's a bit confusing (or I don't like what it says).
 
Replies continue below

Recommended for you

Looks to me like it can't be done from an external VB executable. It appears that it can be done with C++, though. Perhaps someone could write an ActiveX wrapper per this info from the API help on SldWorks::previewDoc:

C++ programmers can also access this bitmap image from outside SolidWorks. The bitmap was written with CArchive::Write( ) and is found in the Preview node in SolidWorks part, assembly and drawing files. The format of the Preview node is as follows: DWORD (data size) followed by continues chunk of memory of that size (data). The data being read can be cast to LPBITMAPINFO, which has all of the information required to display the bitmap.

I don't know enough about this to know if it's even possible, though.
 
Is it possible to call and execute a Solid Works macro (.swp file) from an external VB executable program?
 
Yes, but it is a different subject from your original one. You should have started a new post.

You can always assign keyboard shortcut keys, and send command from vb using "Sendkey" statement to execute macros.

Alex
 
Sure. Just use SldWorks::RunMacro. However, if I understand right the bitmap still won't be able to be seen by your executable program. However, I don't think you would be able to pass any arguments to the SolidWorks macro from your VB program or return any values from the macro to your program. In order to get the picture into your VB executable, I believe you would have to:

1. Using your VB program, write the file path from which you want to extract the bitmap to a temporary text file.
2. Call the SW macro, which reads the same text file to get the file path
3. Use the SW macro to get the bitmap (as shown in the examples) and save it to a temporary bitmap file with a SavePicture statement
4. Open the picture with your VB program from the temporary bitmap file.

This might work... :)
 
VB can extract bitmap previews from Solidworks models. You do not need to run SolidWorks/Macro.

Alex
 
Alex is right in saying that you can get the bitmaps without running SW. I didn't look far enough down in the list on the API samples page before. The exact sample and code you need is


This file includes the dll wrapper (SW_ExtractBitmap.dll) that I didn't realize had already been written.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor