Click here to Skip to main content
15,944,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to open and manipulate.dwg file in c# windows application.All the solutions i have read are opening the file in autocad .Any suggestions would be appreciated.Thanks in advance

What I have tried:

open a .dwg file in c# windows application
Posted
Comments
Richard MacCutchan 19-Nov-23 7:14am    
You need to write the code to manage the file's content, or find a library that can do it for you.

It depends what you mean by manipulate?

No matter what you do with the file you will need to know the file format, see DWG File Format[^]

From there you can directly edit the raw text or visually modify the data.

In either case it is a daunting effort that has taken teams of experts many the man hours to do.
 
Share this answer
 
You showed no effort by showing us your code, you need to reference autocad, which is the correct app to open .dwg, to "manipulate it as you state.

Another solution is to use DWG TrueView - View and convert 2D and 3D DWG files \ Free (as they state)[^]

Your code will then start with -

C#
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Windows;
using Autodesk.AutoCAD.Interop;

public class DWGViewer
{
//My code follows...
}
 
Share this answer
 
By manipulate i want to edit the drawing using .net code change colors or apply labels etc.my main task is to open a dwg file in c# in picture box or in form etc.i have tired many methods but they are opening file in autocad.
 
Share this answer
 
Comments
Richard MacCutchan 20-Nov-23 6:01am    
Firstly, this is not a solution. if you wish to reply to someone's post, the use the Have a Question or Comment? link below a Solution entry, or if you wish to reply to a comment then please use the Reply button above the message.

And secondly, you have been given two possible lines of enquiry which you need to follow yourself.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900