Author Topic: use drawings stored in database  (Read 3187 times)

0 Members and 1 Guest are viewing this topic.

jtoverka

  • Newt
  • Posts: 127
use drawings stored in database
« 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.

57gmc

  • Bull Frog
  • Posts: 365
Re: use drawings stored in database
« Reply #1 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.

kpblc

  • Bull Frog
  • Posts: 396
Re: use drawings stored in database
« Reply #2 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
Sorry for my English.

57gmc

  • Bull Frog
  • Posts: 365
Re: use drawings stored in database
« Reply #3 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
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.
« Last Edit: September 16, 2019, 02:35:32 PM by 57gmc »

jtoverka

  • Newt
  • Posts: 127
Re: use drawings stored in database
« Reply #4 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.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: use drawings stored in database
« Reply #5 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.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

57gmc

  • Bull Frog
  • Posts: 365
Re: use drawings stored in database
« Reply #6 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.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: use drawings stored in database
« Reply #7 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.

VovKa

  • Water Moccasin
  • Posts: 1628
  • Ukraine
Re: use drawings stored in database
« Reply #8 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

jtoverka

  • Newt
  • Posts: 127
Re: use drawings stored in database
« Reply #9 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.