473,320 Members | 2,189 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

reading autocad parameters in c#.net

3
Hi friends,
I want to open an autocad file using C# program in asp.net and read the parameters of that .dwg file.I could able to open the .dwg file but dont know how to read the parameters like length,height of wall,doors,window and number of windows etc.
I opened the file by following code
Expand|Select|Wrap|Line Numbers
  1. using AutoCAD;
  2.  
  3. public static AcadApplication gbl_open;
  4.     public  static AcadApplication gbl_app;
  5.     public static AcadDocument gbl_doc;
  6.     public static AcadModelSpaceClass gbl_modSpace;
  7.     public static AcadAcCmColor gbl_color;
  8.     public static double gbl_pi = 3.14159;
  9.     public static AcadLayer TerminalsLayer;
  10.     public static AcadLayer SwitchLayer;
  11.     public static AcadLayer TerminationPoints; 
  12.  
  13. public void OpenDocument(string DocumentName)
  14.     {
  15.         gbl_open = new AcadApplication();
  16.         gbl_doc=gbl_open.Documents.Open(DocumentName,true,"gg");
  17.         gbl_open.Application.Visible = false;
  18.         ExtractData();
  19.     }
  20.     public void ExtractData()
  21.     { 
  22.     // Create some settings for the extraction
  23.         int height=gbl_doc.Height;
  24.         int width = gbl_doc.Width;
  25.  
  26.  
  27.     }
(Purpose is that by reading those parameter the program must be able to calculate the cost.)

I'm new to autocad.so I'm confused.can anyone help me?

dim505
Apr 18 '08 #1
1 10518
Hi, the below code can be useful to you..
Expand|Select|Wrap|Line Numbers
  1. using AutoCAD;
  2.  
  3. public string ExtractContent()
  4.         {            
  5.             AcadApplication app = null;
  6.             AcadDocument doc;
  7.             AcadModelSpace modelspace;
  8.             StringBuilder buf = new StringBuilder();
  9.             try
  10.             {
  11.                 string inFileName = "DocumentName(file path...)";
  12.                 app = new AcadApplication();
  13.                 //To open the file in readonly mode
  14.                 doc = app.Documents.Open(inFileName, true, string.Empty);
  15.                 app.Application.Visible = false;
  16.                 modelspace = doc.ModelSpace;
  17.  
  18.                 for (int i = 0; i < modelspace.Count; i++)
  19.                 {
  20.                     AcadEntity entity = modelspace.Item(i);
  21.                     if (entity.EntityType == 32)
  22.                     {
  23.                         AcadText text = (AcadText)entity;
  24.                         buf.Append(text.TextString);
  25.                         buf.Append(' ');
  26.                     }
  27.                 }
  28.                 return buf.ToString();
  29.             }
  30.             catch (Exception ex)
  31.             {
  32.                 Trace.WriteLine("Exception in indexing asset" + asset.AssetId + ex.Message);                
  33.             }
  34.             finally
  35.             {
  36.                 if (app != null)
  37.                 {
  38.                     app.Documents.Close();
  39.                     app.Quit();
  40.                 }
  41.             }
  42.             return buf.ToString();
  43.         } 

Model space gives the entity objects like line, rectangle, circle and text etc. using that entities we ill get the parameters

-jyothi
Jul 7 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Bruce | last post by:
Hi: I was interested in installing AutoCAD 2005 on my computer with Win XP Pro. I went to the AutoCAD website, and it said something like "Windows XP Pro, and Service pak 2 are compatible with...
0
by: paii, Ron | last post by:
I have a table listing Part numbers and a full path to the Autocad drawing. I need a report that will print the drawing, Zoomed to a fixed sized window on the report. Has anyone done OLE with...
0
by: Kathy | last post by:
Hi and Thanks for you help! Several years ago I created a Product Specification db that displayed AutoCad 2000 drawings in a report (The Spec Sheet) Recently we upgraded our AutoCad to the 2004...
3
by: perspolis | last post by:
I want to open Autocad files from my application and edit them there like Insert object in word
2
by: john m | last post by:
Hello, I downloaded the beta vb8 express thing and since installing it none of my AUTOCAD vba routines work anymore. I tried the AcadVBA newsgroup but no one else seems to have had this. My...
1
by: john m | last post by:
i want to write a vb dotnet program to see if autocad is running and if not start it then just start to manipulate the application what is the correct method to do this? can anyone point...
4
by: ARF | last post by:
I'm testing AutoCAD 2005 automation via VS2005 Pro C++/CLR and I'm getting fatal compiler errors. I start with a default C++/CLR class library project and modify it by adding the following...
3
by: Aman | last post by:
hi, im trying to draw some rectangles,lines in autocad using c, is their any function that can be used, plz help, also is it possible to read values from a ms excel file in c
3
by: shaiful | last post by:
Hi all, I have a problem with opening and closing AutoCAD in VB6 properly. I opened AutoCAD in VB by Dim AcadApp As Object, acadDoc As Object and close it by Set acadDoc = Nothing Set AcadApp...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.