Question

Convert DWG to PostgreSQL

  • 4 December 2017
  • 3 replies
  • 27 views

Badge +1

There is a wonderful page that states that this is possible, https://www.safe.com/convert/dwg/postgresql/ , but I haven't found any additional documentation. I am not super experienced with AutoCAD, nor PostgreSQL. The page states that this can be done retaining details "such as annotation and symbology during the DWG to PosgreSQL translation".

Ultimately, I am trying to take multiple DWGs and write them to our PostgreSQL DB into a "Master File" that could be imported, clipped, etc. back into AutoCAD for reuse.

Any help on what formats to write to, etc. would be greatly appreciated. Thank you in advance.


3 replies

Userlevel 5
Badge +25

First of all you'll have to have the PostGIS extension on your PostgreSQL database (this will allow you to store geometry in the database).

Now, stuff like annotation and symbology from the original DWG is stored in several attributes (autocad_color and autocad_linestyle for example) which can indeed be written to your PostGIS database. You'll need to set up a workflow that retains those attributes.

To get the data back into AutoCAD you would either need to connect to the PostGIS database directly (I don't know enough about AutoCAD to tell you whether that's possible) or create a second workflow that takes a small section of the data in the database and write it back out to a DWG, using the colors and styles that you've stored.

There's a couple of tutorials on AutoCAD handling on the Knowledge Base to get you started.

Badge +1

First of all you'll have to have the PostGIS extension on your PostgreSQL database (this will allow you to store geometry in the database).

Now, stuff like annotation and symbology from the original DWG is stored in several attributes (autocad_color and autocad_linestyle for example) which can indeed be written to your PostGIS database. You'll need to set up a workflow that retains those attributes.

To get the data back into AutoCAD you would either need to connect to the PostGIS database directly (I don't know enough about AutoCAD to tell you whether that's possible) or create a second workflow that takes a small section of the data in the database and write it back out to a DWG, using the colors and styles that you've stored.

There's a couple of tutorials on AutoCAD handling on the Knowledge Base to get you started.

@redgeographics Thank you. I am positive that the PostGIS extension is already present. I am already performing a similar workflow for all of our GIS submission data. Just to be clear, you are suggesting that the DWG Layers be written to an ArcSDE Feature Class, that retains the attributes you mentioned, in the PostGIS DB, correct?

 

Userlevel 2
Badge +17

Hi @dane_stephenson,

To expand a little on the answer by @redgeographics, you can pack all of the AutoCAD symbology into a single clob or text field using the AttributeJSONPacker for more efficient storage in PostGIS (or any other spatial database). When writing back to AutoCAD, use the corresponding AttributeJSONUnpacker to restore the autocad symbology attributes.

To store all the AutoCAD symbology attributes, use the prefix 'autocad_' in the AttributeJSONPacker.

Reply