Database

Database

autodeskprogrammer
Contributor Contributor
985 Views
7 Replies
Message 1 of 8

Database

autodeskprogrammer
Contributor
Contributor

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

0 Likes
986 Views
7 Replies
Replies (7)
Message 2 of 8

DiningPhilosopher
Collaborator
Collaborator

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().

Message 3 of 8

autodeskprogrammer
Contributor
Contributor

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 !!!

0 Likes
Message 4 of 8

DiningPhilosopher
Collaborator
Collaborator

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.

0 Likes
Message 5 of 8

autodeskprogrammer
Contributor
Contributor

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

0 Likes
Message 6 of 8

Hallex
Advisor
Advisor

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
Message 7 of 8

autodeskprogrammer
Contributor
Contributor

thanx a lot , I will check it Smiley Happy

0 Likes
Message 8 of 8

DiningPhilosopher
Collaborator
Collaborator

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.

 

 

0 Likes