Page 1 of 1

csv import

Posted: Sat Jun 16, 2012 4:55 pm
by TheEnglishPatient
Is there an utility/option to import (a large number!) of xyz coordinates into Qcad 3.0? They come originally from a .kml file, and I recognise that a direct import would be probably too much to hope for, but I could make an intermediate csv file or such like. I don't need all the fancy stuff, just the raw points/lines in the dxf. Alternative, what is the minimal dxf into which I could copy/paste my coordinates - there is some thread in the 2.0 forum to this effect, but it does not work under 3.0/Win7 (or I am too thick to do it).

Any help appreciated.

Re: csv import

Posted: Sat Jun 16, 2012 6:12 pm
by andrew
Note that with QCAD being 2D, only X/Y coordinate pairs can be imported (no Z).

Depending on your programming skills, you could write a small import script that parses the KML (Keyhole Markup Language?) file and inserts the points into the current or a new drawing.

With KML being an XML dialect, I would recommend using the Qt QXmlSimpleReader / QXmlDefaultHandler classes to read the file.


QCAD 3 final will come with an example script that imports point pairs from a file in the simple format:

Code: Select all

x1,y1
x2,y2
x3,y3
...
You can install and use this script also with QCAD 3 RC5:

Installation:
- Quit QCAD
- Download the attached ZIP file
- Extract its contents to your QCAD installation directory into sub folder scripts/Examples
- This creates folder scripts/Examples/IOExamples/ExImportPoints

Usage:
- Start QCAD
- Choose menu Examples - Import / Export - Import Points
- Choose any file in the x,y format described above and click OK
- QCAD inserts a point entity for every line in the file containing an x,y coordinate. Other lines in the file are ignored.

Re: csv import

Posted: Sat Jun 16, 2012 7:08 pm
by TheEnglishPatient
Brilliant!

You are right about the z of course, it's in the kml but as I am doing some extensive geometry manipulation (curve fitting etc) in a separate program in between anyway, no problem to get to a simple flat x,y points file.

Now, ideally, it would also be nice to be able to import in a similar way lines etc...

However, in any case thanks very much for the present solution and the prompt answer!

Re: csv import

Posted: Wed Jun 20, 2012 9:43 am
by hungerburg
TheEnglishPatient wrote:Now, ideally, it would also be nice to be able to import in a similar way lines etc...
There is an ascii notation for this, its called SVG. QCAD already handles a subset of known entities.

Re: csv import

Posted: Wed Jun 20, 2012 10:19 am
by andrew
There is an ascii notation for this, its called SVG.
Good point, SVG import should indeed work for lines, arcs, circles, rectangles, ellipses, polygons, polylines and paths.

Unfortunately, point shapes are not supported by SVG as far as I know.

Note that the default SVG coordinate system is screen oriented (Y increases downwards), so Y coordinates are negated by QCAD on import.

Example SVG file for a line:

Code: Select all

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  <line x1="0" y1="0" x2="200" y2="200" />
</svg>
To import SVG files into QCAD, use the menu File - SVG Import.