.NET

Reply
*Tony Tanzillo
Message 11 of 20 (1,500 Views)

Re: Save preview to file

09-05-2006 01:32 AM in reply to: EvertM
Alex's code extracts an existing preview from a .DWG file
that's been saved (with a preview), and writes it out to a
BMP file.

The code I posted doesn't do that. Instead, it generates
a new preview image of the Active viewport of the active
document, but it is not assigned as the database's saved
thumbnail.

It may also help to know that to do what Alex's code
does, you don't need native ObjectARX. You can use the
Shell's IExtractImage COM interface to get the thumbnail
preview for any file type that has one, including DWG files.

Have at look here for working example code:

http://www.vbaccelerator.com/home/net/code/libraries/Shell_Projects/Thumbnail_Extraction/article.asp

So, it depends on what you want to do (generate a new
preview, or 'snapshot' of the active viewport, or just get
the preview thumbnail from a saved file). If the drawing
is open in the editor, you should be able to save it, then
use Alex's code, or IExtractImage to get an up-to-date
thumbnail.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5316869@discussion.autodesk.com...
Hi rivilis,
I want to know if you have got dwgpreview.arx for Autocad 2007. IF not then how can i do it in 2007. Tony's code is working but not for 3D drawings.
Thanks....
Member
peterjacx
Posts: 4
Registered: ‎11-23-2006
Message 12 of 20 (1,500 Views)

Re: Save preview to file

11-23-2006 11:25 PM in reply to: EvertM
Hello,

interesting idea to do it with a own arx.

[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("dwgpreview.arx", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi ,
EntryPoint = "SaveDWGPreview")]
extern static private int SaveDWGPreview(string dwgfilename, string bmpfilename);

My question: How is the definition of the function (dllexport) in the ARX programm.

thanks
Peter
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 13 of 20 (1,500 Views)

Re: Save preview to file

11-24-2006 03:02 AM in reply to: EvertM
For AutoCAD 2006:
__declspec( dllexport ) int SaveDWGPreview(const char *dwgfile, const char *bmpfile);
For AutoCAD 2007:
__declspec( dllexport ) int SaveDWGPreview(const TCHAR *dwgfile, const TCHAR *bmpfile);
Also dwgpreview.def has lines:
[code]
EXPORTS
SaveDWGPreview
[/code]
Distinguished Contributor
BillZ
Posts: 4,707
Registered: ‎12-12-2003
Message 14 of 20 (1,500 Views)

Re: Save preview to file

02-18-2008 10:36 AM in reply to: EvertM
Any chance that this could be fixed to work with R2006?
I've made some modest attempts to doso, but it appears that resources like using System.Collections.Generic; are not present in 2006.

TIA

Bill
Mentor
t.willey
Posts: 2,504
Registered: ‎02-17-2004
Message 15 of 20 (1,500 Views)

Re: Save preview to file

02-18-2008 12:58 PM in reply to: EvertM
That is not an Acad error, it is a framwork issue. System.Collections.Generic isn't available until .Net 2.0.
Distinguished Contributor
BillZ
Posts: 4,707
Registered: ‎12-12-2003
Message 16 of 20 (1,500 Views)

Re: Save preview to file

02-18-2008 06:04 PM in reply to: EvertM
>>>it is a framwork issue

Thanks TIm,
After I though about it a bit, I thought that probably was the case.

In any case, reading the preview image, and displaying it, is something that I think I could do. But I'd be more interested in getting the current viewport view as Tony suggested that his .cs does.
That would not only replace what we do now in Vlisp, it would be better.
In our current program, I read the block entities and draw the part, using a transformation matrix to get the VIEW ucs, then use grvecs to put it into an image_tile.
Something that I imagine would be far more complicated in C#.
Anyway, I think a view of the current viewport would do it.

TIA


Bill
Distinguished Contributor
BillZ
Posts: 4,707
Registered: ‎12-12-2003
Message 17 of 20 (1,500 Views)

Re: Save preview to file

02-19-2008 04:02 AM in reply to: EvertM
>>>Anyway, I think a view of the current viewport would do it.

Hmm,
Maybe not.

I need to be able to display only the one part selected in the listbox. I've attached a .png of the DCL version.

Bill
Distinguished Contributor
BillZ
Posts: 4,707
Registered: ‎12-12-2003
Message 18 of 20 (1,500 Views)

Re: Save preview to file

03-19-2008 07:07 AM in reply to: EvertM
Well I did find a way to accomplish the image problem.
Thanks to Kean Walmsley(watch word wrap):
http://through-the-interface.typepad.com/through_the_interface/2007/02/using_the_com_i.html

I learned how to acces AutoCAD geometry points of certain entities and then use those points to "paint" on a picturebox.

Thanks also to Tony T. for his PolarPoint function that enabled me to add points for arcs & circles.

I still have some scaling and rotation isues to iron out but this program duplicates what the old Vlisp one did by displaying the selected block.
I won't post the code as not all like Italian cusine but as I have time will sort things out better.

The only problem is that once in a while, some of the points that are created with PolarPoint, to duplicate arcs, don't always end up on the right plane of the arc (Using arc startangle). So that's another issue to work on (see last image in the attached).

But thanks for having this site and having people that are knowlegable in .net.
Well ack to my "day job".

Bill
Valued Contributor
RamanSBV
Posts: 87
Registered: ‎02-28-2012
Message 19 of 20 (892 Views)

Re: Save preview to file

03-04-2012 10:37 PM in reply to: BillZ

HI,

 

I am using Auto CAD 2010 and .net

 

can you please tell me how i can get the preview of the dwg file using file name

 

 

 

*Expert Elite*
Alfred.NESWADBA
Posts: 8,962
Registered: ‎06-29-2007
Message 20 of 20 (889 Views)

Re: Save preview to file

03-04-2012 11:02 PM in reply to: RamanSBV

Hi,

 

you have so much samples and links in the above posts. What have you tried from them? Or should all be repeated now againg?

 

Sorry, - alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.