Monday, 18 April 2016

Draw AutoCAD Polyline using Oracle Spatial Geometry

I found an interesting blog entry about drawing a polyline (straight line segments only) in AutoCAD by using Oracle Spatial Geometry. 

A quick test showed, that the SQL statement doesn't seem to be correct. It also uses an undocumented Oracle command which is not available anymore in 12c (according to this website).

I changed the SQL script using LISTAGG - which is only available in 11.2 and newer:

 -- only required if decimal separator is not a dot:  
 -- creates list of coordinates which can be easily copied and pasted into AutoCAD  
 SELECT  c.fid,   
 '_pline ' || LISTAGG(t.X || ',' || t.Y, ' ') WITHIN GROUP (order by as pline  
 FROM ww_line c, -- your table name  
 TABLE(SDO_UTIL.GETVERTICES(c.geom)) t -- your spatial column name  
 WHERE c.fid = 138900 -- your ID  
 GROUP BY c.fid;  

To finish the "pline" command you press "ESC". I don't know how to have something similar when you copy and paste the command into AutoCAD so I couldn't add it to the SQL result set.

1. run SQL script
2. copy result
3. paste result into AutoCAD
4. press "ESC" to finish pline command

Line in Oracle Spatial ( preview with Georaptor)

Line in AutoCAD

Map 2013, SP2

No comments:

Post a Comment