Reading DWG/DXF

Dealing with DWG/DXF files in Eyeshot requires several additional steps compared to other standard CAD file formats. As all professional CAD systems do, Eyeshot relies on Open Design Alliance for this file format translation. This tool still contains some legacy DLLs that cannot be copied automatically by Visual Studio. You'll find all the necessary DLLs inside the Bin folders of the Eyeshot installation.

Basically, the required steps to read/write DWG/DXF files are:

  1. Prepare a working Eyeshot based Visual Studio project (or start from one of the source code samples)
  2. Change the Target Platform of your Visual Studio project to x86
  3. Add the Bin\x86\devDept.Eyeshot.Control.x86.dll to your Visual Studio project references
  4. Change the type of the viewportLayout1 control from ViewportLayout to ViewportLayoutEx in the Form designer file1
  5. Manually copy the Bin\x86\AcIdViewObj_3.09_10.tx and RecomputeDimBlock_3.09_10.tx files to your Bin/Debug or Bin/Release folder2
  6. Add the ViewportLayoutEx.ReadAutodesk()/WriteAutodesk() call in your code3

1 If you plan to use the ReadAutodesk class this step is not strictly necessary
2 These *.tx files can be easily added to your Visual Studio project as well to automate the file copy operation
3 ViewportLayoutEx.ReadAutodesk() is performed asynchronously. To take full control on how the file import is performed use directly the ReadAutodesk class (see Import/Export topic of the documentation)

Please note that once completed the steps above, the number of Eyeshot DLLs in the project references will be three compared to the single one of Eyeshot 6.0.

On end-user machines the Microsoft Visual C++ 2010 Redistributable Package is also required.

Have more questions? Submit a request

21 Comments

  • 0
    Avatar
    Alberto Bencivenni

    We meant that if you need only to import DWG/DXF using the ReadAutodesk class, you don't need the ViewportLayoutEx object at all. In addition, the WriteAutodesk class does not exist.

  • 0
    Avatar
    Hannes Papesh

    Hi there!

    I'm just playing around with the trial version. I would need it for my 64bit project. Actually I have problems transferring the ReadDWG sample you offered to 64bit. Could you please as well offer a 64bit project (incl all references)?

    Thanks!

    Hannes

  • 0
    Avatar
    Ian Swift

    Alberto, 

    Can you give an example of just using the ReadAutodesk class.

     

    Thanks,

    Ian

  • 0
    Avatar
    Alberto Bencivenni

    Please check the "Import/export" chapter of the documentation.

  • 0
    Avatar
    Ilya

    Hello, how I can run solution on "Any CPU" platform?

  • 0
    Avatar
    Alberto Bencivenni

    No, sorry. Only Eyeshot 8, with a small trick can do it.

  • 0
    Avatar
    Ilya

    Alberto, what a small trick? Now I'am using 8 version. Please tell me this secret! It is very necessary!

  • 0
    Avatar
    Alberto Bencivenni

    You need to check the IntPtr.Size() == 4 to determine if you are on a 32 or 64 bit machine and copy/replace the other necessary DLLs from a x86/x64 folder to your main app folder, then load dynamically the proper Eyeshot x86 or x64 DLL. We will publish an article on this trick soon.

  • 0
    Avatar
    Luca Cornazzani

    Hi Alex,

    they come from the Bin/x86 or Bin/x64 folder of step 3 above.

    They are needed to read / write Autodesk files and are automatically copied.

    You also need to copy the other 2 tx files as explained in step 5 above, because they are not automatically copied.

  • 0
    Avatar
    Alex Miller

    Hello Robert,

    The commands are there. Make sure your viewportlayout control is of type ViewportLayoutEx and not ViewportLayout. You need to change this at two places in the designer file of your form.

    Alex

  • 0
    Avatar
    Alex Miller

    Hello Alberto,

    These new files appear in my bin folder. From where do they come?

    TD_Br_3.09_10.dll

    TD_BrepRenderer_3.09_10.dll

    TD_Db_3.09_10.dll

    TD_DbRoot_3.09_10.dll

    TD_DynBlocks_3.09_10.tx

    TD_Ge_3.09_10.dll

    TD_Gi_3.09_10.dll

    TD_Gs_3.09_10.dll

    TD_Mgd_3.09_10.dll

    TD_MgdBrep_3.09_10.dll

    TD_Root_3.09_10.dll

    TD_SpatialIndex_3.09_10.dll

    TD_AcisBuilder_3.09_10.dll

    TD_Alloc_3.09_10.dll

    Thanks

    Alex

  • 0
    Avatar
    Robert Race

    I cannot find where to change the viewportlayout control in the designer form.  Is there some reference I am looking for?

    R Race

  • 0
    Avatar
    Alex Miller

    You have to go to the ‘Code’ section of the designer. In the solution explorer you can right-click your Form and select ‘View Code’. Or you can expand the Form in the solution explorer and edit Form.Designer.cs.

     

    See attached screenshot.

  • 0
    Avatar
    Robert Race

    I have updated everything, but the component does not have:

    WriteAutodesk or ReadAutodesk.  Does v7 have new commands?

  • 0
    Avatar
    Robert Race

    Ok, got it working.  The example file did not work but setting that up solved my problem.

    When I set up EyeShot I dragged the SingleViewPort into my project.  It did not populate the references with the dlls as required.  If I double clicked on one of the images for the background, then the references were set up correctly.  I could then change the type in the Form Designer and all works well.

     

    Maybe this will help someone else having the same issue.

    Thanks for your help on this.

  • 0
    Avatar
    Robert Race

    Sorry, I follow you but changing ViewPortLayout() to ViewPortLayoutEx() shows it does not exist.

                this.viewport1 = new devDept.Eyeshot.ViewportLayout(); to             this.viewport1 = new devDept.Eyeshot.ViewportLayoutEx();

  • 0
    Avatar
    Alex Miller

    Hello Robert,

    Check this video, let me know if it's clearer.

    http://screencast.com/t/1LMlTjiRqS

    Alex

  • 0
    Avatar
    Jeff Godfrey

    Got it.  So, maybe this small addition would help clarify the point?

    1 If you plan to use the ReadAutodesk class (instead of the ViewportLayoutEx.ReadAutodesk class) this step is not strictly necessary.

  • 0
    Avatar
    Jeff Godfrey

    While I haven't tried any of this yet... In the steps listed at the top of this post, step 4 states:

    4. Change the type of the** viewportLayout1** control from ViewportLayout to ViewportLayoutEx in the Form designer file1

    ... and the associated footnote state_s:_

    1 If you plan to use the ReadAutodesk class this step is not strictly necessary

    The footnote is not overly clear to me in this case.  Does that mean "If you plan to use *only* the ReadAutodesk class (and therefore *not* the WriteAutodesk class), this step is not strictly necessary"?

    I assume that's the intended meaning, but it's not very clear.  Whatever the meaning, I suggest a clarification in the footnote to prevent confusion.

    Jeff

  • 0
    Avatar
    Robert Race

    Thanks, that's better.  BUT, when I loaded the Eyeshot component I do not get the devDept.EyeshotControl or devdept.Geometry in the References.  If I stick them in manually I get an error.

  • 0
    Avatar
    Alex Miller

    Does the attached VS solution work on your end?

Please sign in to leave a comment.