TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jtoverka on September 16, 2019, 07:27:23 AM

Title: use drawings stored in database
Post by: jtoverka on September 16, 2019, 07:27:23 AM
Is it possible to retrieve a drawing from an access database that is storing drawings as an attachment? I am using AutoCAD Electrical and these drawings are whole circuits. AutoCAD Electrical has circuit builder and insert circuit tools, however, they are limited in functionality and does not scale with automation. I wrote my own circuit builder program, however, I would like a centralized location for all of my data. I would like to store these drawings in a database that AutoCAD can access. Is this possible? Additionally, I would prefer that speed be somewhat comparable or close to pulling a drawing out of the file system.
Title: Re: use drawings stored in database
Post by: 57gmc on September 16, 2019, 11:03:37 AM
I've worked with Access db's in AutoCAD, just not attachments. However, the object model does include them, so you should be able to access them. Keep in mind that the api is in VBA, not lisp.
Title: Re: use drawings stored in database
Post by: kpblc on September 16, 2019, 12:41:11 PM
I've worked with Access db's in AutoCAD, just not attachments. However, the object model does include them, so you should be able to access them. Keep in mind that the api is in VBA, not lisp.
Not quite. Using lisp you can access to any database (create connection string, then ADO.Connection, ADO.Recordset and execute your query - it's simple). As an example: https://adndevblog.typepad.com/autocad/2013/04/using-autolisp-to-read-an-access-database-via-ado.html
Title: Re: use drawings stored in database
Post by: 57gmc on September 16, 2019, 02:26:41 PM
I've worked with Access db's in AutoCAD, just not attachments. However, the object model does include them, so you should be able to access them. Keep in mind that the api is in VBA, not lisp.
Not quite. Using lisp you can access to any database (create connection string, then ADO.Connection, ADO.Recordset and execute your query - it's simple). As an example: https://adndevblog.typepad.com/autocad/2013/04/using-autolisp-to-read-an-access-database-via-ado.html (https://adndevblog.typepad.com/autocad/2013/04/using-autolisp-to-read-an-access-database-via-ado.html)
I wasn't saying that you Can't use lisp, just that the api is intended for VBA. It's just a little more difficult in lisp, since you don't have the advantages offered by the IDE, e.g. Intellisense. Besides, I'm not sure if ADO can access an attachment contents. That may be only available via the ActiveX api.
Title: Re: use drawings stored in database
Post by: jtoverka on September 17, 2019, 08:00:46 AM
Not quite. Using lisp you can access to any database (create connection string, then ADO.Connection, ADO.Recordset and execute your query - it's simple). As an example: https://adndevblog.typepad.com/autocad/2013/04/using-autolisp-to-read-an-access-database-via-ado.html

It is quite simple to connect to a database, I just don't know how to insert attachments from the database into AutoCAD, and to do it efficiently.

I would like to have a normalized database of data and electrical circuits. Right now I have half of that, the circuit is outside the database in a dwg file. This is okay, however, it means that I have to have a bunch of files to manage with no guarantee that my program will work since I could be missing a file somewhere. A database makes it much easier to find these anomalies.
Title: Re: use drawings stored in database
Post by: dgorsman on September 17, 2019, 04:49:26 PM
Just to be clear, because I'm having a hard time following: you cannot put a DWG file in an Access database.  You can store data structured to reconstruct a drawing or part of one, but not the drawing itself.
Title: Re: use drawings stored in database
Post by: 57gmc on September 17, 2019, 05:40:46 PM
Just to be clear, because I'm having a hard time following: you cannot put a DWG file in an Access database.  You can store data structured to reconstruct a drawing or part of one, but not the drawing itself.
You can if the data type of the column is "Attachment". You can then store multiple files per record as attachments.
Title: Re: use drawings stored in database
Post by: Lee Mac on September 17, 2019, 05:44:14 PM
Just to be clear, because I'm having a hard time following: you cannot put a DWG file in an Access database.  You can store data structured to reconstruct a drawing or part of one, but not the drawing itself.
You can if the data type of the column is "Attachment". You can then store multiple files per record as attachments.
You can also store them in a field whose data type is set to OLE Object.
Title: Re: use drawings stored in database
Post by: VovKa on September 17, 2019, 06:31:12 PM
one can also store the drawing as dxf sequence in a 'text' field
or even as an assoc list which you can entmake

but what is the point in all that?
why not just use a dwg file as a database?
keep all your data in that file and use odbx to import the stuff into current drawing
i personally do it this way
Title: Re: use drawings stored in database
Post by: jtoverka on September 18, 2019, 10:14:39 AM
That is the next best option, quite a simple solution too. The reason I am hesitant is that I am looking for data integrity, hence the database design.