TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: snownut2 on April 06, 2014, 03:33:53 PM

Title: Dwg Preview / Thumbnail
Post by: snownut2 on April 06, 2014, 03:33:53 PM
Looking to acquire the thumbnail from a dwg to use as image in DCL. Is there a method to do this in LISP, seems the post I've found here mostly apply to NET.

Much like the image shown in getfiled preview.

Title: Re: Dwg Preview / Thumbnail
Post by: MP on April 06, 2014, 03:37:53 PM
If memory serves DOSLIB will perform this.
Title: Re: Dwg Preview / Thumbnail
Post by: snownut2 on April 06, 2014, 03:58:04 PM
Thanks MP, unfortunately Bricscad Classic will not run DOSLIB, I am looking for another option.
Title: Re: Dwg Preview / Thumbnail
Post by: maicy on April 07, 2014, 01:50:19 AM
http://www.theswamp.org/index.php?topic=33819.msg391791#msg391791
Title: Re: Dwg Preview / Thumbnail
Post by: roy_043 on April 07, 2014, 04:10:33 AM
The code in maicy's link may not work for files saved with BricsCAD V14 since that version uses .png drawing previews instead of .bmp previews.
Title: Re: Dwg Preview / Thumbnail
Post by: snownut2 on April 07, 2014, 06:46:29 AM
The code in maicy's link may not work for files saved with BricsCAD V14 since that version uses .png drawing previews instead of .bmp previews.

That is correct, maicy's code works perfect in ACAD, but does not work for drawings save from BricsCAD. 

Bruce
Title: Re: Dwg Preview / Thumbnail
Post by: MP on April 07, 2014, 08:06:44 AM
Thanks MP, unfortunately Bricscad Classic will not run DOSLIB, I am looking for another option.

Should have gone BrisCAD Pro. (http://www.theswamp.org/screens/mp/poke.gif)
Title: Re: Dwg Preview / Thumbnail
Post by: ymg on April 07, 2014, 10:13:21 AM
As MP stated Doslib will do it:

Here extract of the help file:
Quote
dos_extractpreview

Extracts the thumbnail image from the active document to a bitmap file.
Syntax

(dos_extractpreview filename)
Parameters

filename
The name of the bitmap file to create. The allowable file types are as follows:
 
BMP
Windows Bitmap
JPG
JFIF Compliant
GIF
Compuserve Graphics Interchange
TIF
Tagged Image File Format
PNG
Portable Network Graphics
Returns

A string identifying the created bitmap file if successful.
nil on error.
Example

Command: (dos_extractpreview "C:\\test.bmp")
"C:\\test.bmp"


ymg
Title: Re: Dwg Preview / Thumbnail
Post by: exmachina on April 07, 2014, 02:44:18 PM
... Bricscad Classic will not run DOSLIB...

If Bricscad Classic supports "VisualLisp" i could help you.
I can create a COM library to extract the images.
Title: Re: Dwg Preview / Thumbnail
Post by: ymg on April 07, 2014, 03:48:32 PM
jar,

The way I understand it, Doslib will extract from the currently opened drawing
and creates a bmp file.

More interesting would be a command where you specify a drawing extract the preview
and returns it in the proper format for DCL display.

ymg
Title: Re: Dwg Preview / Thumbnail
Post by: Bhull1985 on April 07, 2014, 05:14:47 PM
Or what would be useful is a ribbon to view the current drawing and/or any directories dwg file previews, and dwgnames within autocad for easy click to open.
Now there's a program for you jar.
One image preview in height of bar to be placed right under command line window.
Slide bar left or right to scroll through dwgs and their previews....double click to minimize currently open dwg and open the dwg double clicked on.
Now *THAT* would be sweet.
Challenge!
Title: Re: Dwg Preview / Thumbnail
Post by: Lee Mac on April 07, 2014, 06:12:35 PM
You could use the techniques from this function (http://www.theswamp.org/index.php?topic=42413.0), in conjunction with ObjectDBX -  though, you may need to exclude objects below a certain size to improve the performance of such a function.
Title: Re: Dwg Preview / Thumbnail
Post by: snownut2 on April 07, 2014, 06:30:07 PM
Lee,

I would like to use that function, however text is an issue.  The function does not display text. 

Bruce
Title: Re: Dwg Preview / Thumbnail
Post by: snownut2 on April 07, 2014, 06:31:36 PM

More interesting would be a command where you specify a drawing extract the preview
and returns it in the proper format for DCL display.


This is what I am looking to accomplish.
Title: Re: Dwg Preview / Thumbnail
Post by: Lee Mac on April 07, 2014, 06:54:29 PM
I would like to use that function, however text is an issue.  The function does not display text. 

You would need to either calculate a vector representation of every character for every font used in your drawings (whether this be generated on-the-fly or hard-coded beforehand), or explode a copy of all text encountered (TXTEXP), or use the methods Sean demonstrates here (http://www.theswamp.org/index.php?topic=31435.0) to obtain a vector representation.
Title: Re: Dwg Preview / Thumbnail
Post by: JasonB on April 07, 2014, 10:56:31 PM
BricsCAD V14 includes additional tools for LISP, including the ability to read and write binary files
http://www.bricsys.com/common/applications/application.jsp?app=720&apploc=1176 (http://www.bricsys.com/common/applications/application.jsp?app=720&apploc=1176)
See included help on VLE binary read and write functions. Perhaps this would be a way to do this, specifically for BricsCAD?
This of course assumes knowledge of the .dwg file.

BricsCAD Classic does support COM and visual lisp

Upgrade to BricsCAD Pro may be easier than having to overly stress the grey matter ^-^
Title: Re: Dwg Preview / Thumbnail
Post by: roy_043 on April 08, 2014, 02:14:31 AM
This of course assumes knowledge of the .dwg file.
To extract V14 previews using code similar to maicy's you would also need to know about .png files. Since .png files have compression they are not as easy to understand as 256 color .bmp files.
Title: Re: Dwg Preview / Thumbnail
Post by: roy_043 on April 08, 2014, 02:17:24 AM
Using the 'ObjectDBX' approach there will probably also be a problem with hatch patterns.
Title: Re: Dwg Preview / Thumbnail
Post by: MP on April 08, 2014, 09:20:16 AM
Upgrade to BricsCAD Pro may be easier than having to overly stress the grey matter ^-^

Should have gone BrisCAD Pro. (http://www.theswamp.org/screens/mp/poke.gif)

Quote from: David Gregory
I see a pattern emerging.
Title: Re: Dwg Preview / Thumbnail
Post by: snownut2 on April 08, 2014, 08:16:55 PM
Thanks MP, unfortunately Bricscad Classic will not run DOSLIB, I am looking for another option.

Should have gone BrisCAD Pro. (http://www.theswamp.org/screens/mp/poke.gif)

You need to be careful with that stick, you could poke someones eye out.... :ugly:
Title: Re: Dwg Preview / Thumbnail
Post by: exmachina on April 15, 2014, 04:54:15 PM
The way I understand it, Doslib will extract from the currently opened drawing
and creates a bmp file.
But it seems that BricsCad Classic does not support Doslib...

jar,
More interesting would be a command where you specify a drawing extract the preview
and returns it in the proper format for DCL display.
.. Autolisp Command?
I do not have the BRX|bricsys TX SDK's , do you have the BRX or the bricsys TX SDK's?

This problem (PNG images/Bricscad_Classic_will_not_support_DOSLIB) can be solved easily with a COM library (aka ActiveX) totally independent of bricscad.
If anyone knows another way , please send the code
Title: Re: Dwg Preview / Thumbnail
Post by: ymg on April 16, 2014, 09:35:25 AM
jar,

Quote
.. Autolisp Command?
I do not have the BRX|bricsys TX SDK's , do you have the BRX or the bricsys TX SDK's?

I don't have it, but could probably find it on the web.
I am a complete newbie when it comes to Bricsys but they seem
to recommend going with the BRX SDK's as it is supposed to be completely
compatible with ARX.

You need to register as a developper here http://www.bricsys.com/bricscad/help/en_US/V14/DevRef/index.html?page=source%2FBRX_01.htm (http://www.bricsys.com/bricscad/help/en_US/V14/DevRef/index.html?page=source%2FBRX_01.htm) in order to download the SDK.

However a little reading on their site states that the SDK is not compatible with "Classic" you need "Pro"
or "Platinum" .

Furthermore some of the required dll are part of the Bricscad installation.  Seems like you need Bricscad
installed on your system in order to develop for it.

I believe you are right, there is no other way than having an interface to a library  (For example "libpng").
You also need "zlib" as libpng is dependent on it.

ymg