.NET

Reply
Contributor
autodeskprogrammer
Posts: 21
Registered: ‎08-20-2008
Message 1 of 8 (320 Views)

Database

320 Views, 7 Replies
12-28-2012 12:32 PM

I have question ,
Do you think that I can use Autocad Database structure instead of an external database. because now I combine .DWG file and .MDB file and made .ATNX file because I should save my data in a table structure.
But now I am thinking that can I save my MDB file in Auto Cad's internal data structure?

 

THANX

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 2 of 8 (306 Views)

Re: Database

12-28-2012 06:13 PM in reply to: autodeskprogrammer

Not entirely sure this is what you're trying to do, but if you are storing .DWG files in some data structure or blob, there is no way to read that data directly into a Database. The Database class doesn't provide a way to read a DWG file from a stream or any other source aside from disk files, so the data must be written to a file first, and then read using ReadDwgFile().

Contributor
autodeskprogrammer
Posts: 21
Registered: ‎08-20-2008
Message 3 of 8 (283 Views)

Re: Database

12-29-2012 02:00 PM in reply to: DiningPhilosopher

why should I save data in to a file ? now we read data directly from DWG file for example BLOCK or other Objects that we save them in internal data structure of Autocad? I want to use this internal data struture !!!

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 4 of 8 (257 Views)

Re: Database

12-30-2012 12:00 PM in reply to: autodeskprogrammer

Sorry, your description doesn't really tell much about exactly what it is you're trying to achieve. If you want to offer a more detailed explaination, feel free to do so.

Contributor
autodeskprogrammer
Posts: 21
Registered: ‎08-20-2008
Message 5 of 8 (246 Views)

Re: Database

12-30-2012 02:59 PM in reply to: DiningPhilosopher

OK, let me to explain

 

In fact I save some data in Autocad internal data structure or internal database (Extension Dictionary) and I save a lot of data in MDB file and then I make a combination of dwg and mdb files and finally a combination and make a ATNX file.

 

it's a part of my code to show where I save my data now

 

 DBObject dbObject = tr.GetObject(SelectedObjectId, OpenMode.ForRead);
                    if (dbObject.ExtensionDictionary == ObjectId.Null)
                    {
                        dbObject.UpgradeOpen();
                        dbObject.CreateExtensionDictionary();
                    }

                    DBDictionary ExtensionDictionary = (DBDictionary)tr.GetObject(dbObject.ExtensionDictionary, OpenMode.ForWrite);
                    Xrecord xrec = new Xrecord();
                    xrec.Data = new ResultBuffer(
                        new TypedValue((int)DxfCode.Text, ParentCode),
                        new TypedValue((int)DxfCode.Text, NodeCode),
                        new TypedValue((int)DxfCode.Int32, NodeType),
                        new TypedValue((int)DxfCode.Int32, ProductCode),
                        new TypedValue((int)DxfCode.Real, Angle));

                    ExtensionDictionary.SetAt("AT_INFO", xrec);

 

 

now I want to know if is it possible to save my external data (the data that I save in MDB) in Autocad?

 

actually this DLL is very complicated and it's a worked on it about three year and now I want to improve it and I prefer not to use MDB file and instead I want to use Autocad's abilities

 

 

 

THANX

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 6 of 8 (206 Views)

Re: Database

12-31-2012 06:04 AM in reply to: autodeskprogrammer

Take a look at :

Autodesk.AutoCAD.DatabaseServices.DataTable class

this is the same as Xdata you can edit rows and columns of this table

within the drawing but could not delete it, after you add this table

in to NOD dictionary as named instance it would be persistent but editable

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Contributor
autodeskprogrammer
Posts: 21
Registered: ‎08-20-2008
Message 7 of 8 (201 Views)

Re: Database

12-31-2012 06:28 AM in reply to: Hallex

thanx a lot , I will check it :smileyhappy:

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 8 of 8 (152 Views)

Re: Database

01-03-2013 12:02 AM in reply to: autodeskprogrammer

You can store almost anything in a drawing file, but if it is not types that AutoCAD recognizes (e.g., binary data), then it becomes more difficult, but not impossible.  You can store binary data in chunks within xrecords, subject to some size limits, and there's code floating around that allows you to binary-serialize/deserialize.NET objects to/from a DWG file as well.

 

 

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.