CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14
  1. #1
    Join Date
    May 2003
    Location
    Jodhpur -> Rajasthan -> INDIA
    Posts
    453

    AutoCAD dwg file format and read and use HOW TO?

    Hi

    Well as in subject can anybody tell me or help me in How to read the DWG file prepared in AutoCAD and use into MFC project?

    Tasks are:

    1.0 Know the format fo DWG file
    2.0 Based on this read the input DWG file
    3.0 Plot the circles and map to the scale in the MFC application

    Any help/suggestions/guidelines

    Sandeep
    Leave Your Mark Wherever You Go
    http://www.danasoft.com/sig/d0153030Sig.jpg

  2. #2
    Join Date
    Jul 2001
    Location
    Germany, near Frankfurt
    Posts
    135
    Hi,
    I took a tool from
    http://www.vdraw.com
    it works fine an you have a whole CAD application included.

  3. #3
    Join Date
    May 2004
    Posts
    5
    I suggest you to use DXF files rather that DWG. It is quite easy to convert DWG files to DXF files in AutoCAD. These are ASCII coded files and reading and writing outside the AutoCAD is easy.
    Take it easy.

  4. #4
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688
    In addition the DXF file format is a part of the documentation that provides AutoCad. (At least in the 2002 version)

  5. #5
    Join Date
    May 2003
    Posts
    9

    The DWG file format...

    ...is proprietary to Autodesk, and they are not talking. DXF's are definitely easier. If DWG's are a requirement for you, you'll probably want to spend some bucks on a third-party library. I've seen several graphics packages that support them, plus there is OpenDWG.org, which is a consortium of just about every cad vendor BUT Autodesk, who make it their job to reverse engineer the DWG format. It costs $$ to join and have access to their code libraries, but it is high-quality stuff.

  6. #6
    Join Date
    May 2003
    Location
    Jodhpur -> Rajasthan -> INDIA
    Posts
    453

    Thanks

    Hi

    thanks for your prompt replies

    Well it is not necessary that only DWG to read from. I hope we can get the DWG file converted to DXF in AutoCAD then i can work on DXF too.

    Well now can you help me in how to work on reading teh contents of teh DXF files and to draw it in MFC view
    Leave Your Mark Wherever You Go
    http://www.danasoft.com/sig/d0153030Sig.jpg

  7. #7
    Join Date
    May 2003
    Posts
    9

    I'd start at the Autodesk website

    They have, among other things, a set of help files on the DXF format.

  8. #8
    Join Date
    Feb 2001
    Posts
    2,455
    Use openDwg toolkit. They have reverse engineered the dwg file format and provide tools to read and write dwg files. I have used it and it worked great. Kind of difficult at first but....


    http://www.opendwg.org/

    Good luck!

    Mike B

  9. #9
    Join Date
    May 2003
    Posts
    9

    I agree, the OpenDWG library was a pain

    But it did the job. Their new C++ version, DWGDirect, is much easier to use.

  10. #10
    Join Date
    May 2004
    Posts
    5

    How to read and write DXF

    Simply draw a line, a circle, a rectangle on a new ACAD page. Then, open "File" menu and "Save As" option. Through the alternatives choose "ACAD R12/LT2 DXF (*.DXF)" (This is the simplest form of DXFs). Give a file name and have your DXF extended file. Now, you can open the file with WordPad or NotePad since it is ASCII coded. Find ENTITIES section and see the definitions of the entities that you have drawn. Try to understand the entity definitions and DXF writing. While writing a DXF file, ENTITIES section is enough. So, you have not to deciphere other sections.
    Take it easy.

  11. #11
    Join Date
    Feb 2001
    Posts
    2,455

    Re: I agree, the OpenDWG library was a pain

    Originally posted by JackW
    But it did the job. Their new C++ version, DWGDirect, is much easier to use.
    Yeah, well hopefully I will see that for myself. I just sent them a signed contract so I can download it!. Did you sign the contract? How long before you were able to download the libraries?

    Mike B

  12. #12
    Join Date
    May 2003
    Posts
    9

    I could not tell you...

    We've been using OpenDWG for years, so we had no wait for the new libraries, and I don't recall how long it took to get access when we originally signed up. I shouldn't think it would be more than a day or so.

  13. #13
    Join Date
    Jun 2015
    Posts
    1

    Re: AutoCAD dwg file format and read and use HOW TO?

    [QUOTE=d0153030;947424]Hi
    i have the same problem:


    1.0 Know the format fo DWG file
    2.0 Based on this read the input DWG file
    3.0 Plot the circles and map to the scale in the MFC application
    if you can solve problem could you please help me?

    Any help/suggestions/guidelines
    Roushanak

  14. #14
    Join Date
    Jul 2015
    Posts
    1

    Re: AutoCAD dwg file format and read and use HOW TO?

    For the first part, which is knowing DWG format (and its version), you can read the first few bytes of the file and search for the DWG version marker. For example, DWG 2004 files will have the string "AC1018" in the file's header.
    For a list of versions and their signature strings, see the Version history section in the following Wikipedia article:
    https://en.wikipedia.org/wiki/.dwg
    About the other parts, which are reading the DWG, parsing it and displaying circles in MFC application, this is not easy to do on your own because the DWG format is so complex. You will be better off using a library like OpenDWG mentioned above or LEADTools.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured