From Eyeshot 2023, two new managed classes can be used to import DWG/DXF files: ReadDWG and ReadDXF.
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. You will find all the necessary DLLs inside the Bin folders of the Eyeshot installation.
Basically, the required steps to read/write DWG/DXF files are:
- Create a new project and add the reference to DWG/DXF (x64) NuGet package
- Change the Target Platform of your Visual Studio project to x64*
*You can also target x86 platform and add the reference to DWG/DXF (x86) NuGet package.
- Use ReadAutodesk class in your code to load the file and WriteAutodesk class to save the file.
On end-user machines, you need to deploy the whole Bin\x64 content, and the latest Microsoft Visual C++ Redistributable version is also required.
An example of how to read/write DWG/DXF files can be found in the DraftingDemo source code sample.
Comments
Currently I'm trying to get this to work as advertised, but I keep having issues.
I'm building a WPF app that references a core app.dll library project. Both project use .Net 7.0.13. To this library I added the references using all thinkable ways:
However whatever option I choose, as soon as I build the app it only copies .dll files into the output directory. All the .tx files are left out.
This piece of code then crashes the app on the dcfFile.DoWork(); line, giving me the exception below:
Workaround is now copying all .tx files in my output directory manually. If I do that, it works.
Obviously I'd expect it to be able to put all necessary dependencies in the output folder by itself, so please tell me, is this a bug or am I missing something here?
Very strange! It suddenly all started working!
I now only have two nuget package references to the local nuget packages.
Maybe A clean build or a restart of VS2022 did the trick, I have no idea.
Now I only have to find out how I get this to build in my CI/CD pipeline :(
A quick tip if you want to use the direct inclusion route, take these steps:
Open your .csproj file and add the following ItemGroup somewhere near the end This will make sure all the files are inside are copied into the correct location, including the .tx files
Is it possible to open dwg files as read-only?Hi Richard,
Eyeshot does not alter the original DWG file while reading. Furthermore, if you require more control, you can use a Stream as input for our reader classes.
Is there any official way on how to solve this issue without the aforementioned work around?
It would be great to export DWG, DXF or 3D-PDF but none of them work. I get this exception all the time.
Hi Marco,
Suppose you are referring to the missing ODA DLLs error. In that case, I suggest checking the Deployment Guide topic of the Documentation, specifically the section “Applications with DWG/DXF file format import/export.” If you still experience issues, please feel free to open a support ticket.
Please sign in to leave a comment.