• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    *Tony Tanzillo

    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....
    Please use plain text.
    Member
    Posts: 4
    Registered: ‎11-23-2006

    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
    Please use plain text.
    Distinguished Contributor
    Posts: 303
    Registered: ‎09-26-2004

    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]
    Please use plain text.
    Distinguished Contributor
    Posts: 4,707
    Registered: ‎12-12-2003

    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
    Please use plain text.
    Mentor
    Posts: 2,504
    Registered: ‎02-17-2004

    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.
    Please use plain text.
    Distinguished Contributor
    Posts: 4,707
    Registered: ‎12-12-2003

    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
    Please use plain text.
    Distinguished Contributor
    Posts: 4,707
    Registered: ‎12-12-2003

    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
    Please use plain text.
    Distinguished Contributor
    Posts: 4,707
    Registered: ‎12-12-2003

    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
    Please use plain text.
    Valued Contributor
    RamanSBV
    Posts: 85
    Registered: ‎02-28-2012

    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

     

     

     

    Please use plain text.
    *Expert Elite*
    Posts: 6,457
    Registered: ‎06-29-2007

    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
    -------------------------------------------------------------------------
    Please use plain text.