csv import

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
TheEnglishPatient
Active Member
Posts: 35
Joined: Sun Feb 19, 2012 12:56 pm

csv import

Post by TheEnglishPatient » Sat Jun 16, 2012 4:55 pm

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.

User avatar
andrew
Site Admin
Posts: 9036
Joined: Fri Mar 30, 2007 6:07 am

Re: csv import

Post by andrew » Sat Jun 16, 2012 6:12 pm

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.
Attachments
IOExamples.zip
(2.74 KiB) Downloaded 727 times

TheEnglishPatient
Active Member
Posts: 35
Joined: Sun Feb 19, 2012 12:56 pm

Re: csv import

Post by TheEnglishPatient » Sat Jun 16, 2012 7:08 pm

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!

User avatar
hungerburg
Premier Member
Posts: 160
Joined: Fri May 28, 2010 7:35 pm

Re: csv import

Post by hungerburg » Wed Jun 20, 2012 9:43 am

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.

User avatar
andrew
Site Admin
Posts: 9036
Joined: Fri Mar 30, 2007 6:07 am

Re: csv import

Post by andrew » Wed Jun 20, 2012 10:19 am

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.

Post Reply

Return to “QCAD 'How Do I' Questions”