Importing Ascii files

Use this forum for all posts and questions about the free QCAD Community Edition version 3

Moderator: andrew

John W
Newbie Member
Posts: 9
Joined: Sat May 29, 2021 8:05 am

Importing Ascii files

Post by John W » Sat May 29, 2021 8:13 am

As a programming hobbyist, I am thinking about the idea of extending QCAD's facility to import ascii points. The most practical approach would be to further develop the existing facility but I need to know how the relevant source code can be accessed and where it resides in the binaries. Can anyone help me with that?

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

Re: Importing Ascii files

Post by andrew » Sat May 29, 2021 9:44 am

You can find the example scripts under "scripts" in your QCAD installation or in our git repository:
https://github.com/qcad/qcad/tree/maste ... portPoints

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Importing Ascii files

Post by CVH » Sat May 29, 2021 10:00 am

hi,
Points from a CSV file ... kinda ASCII with a certain format ... can be imported with DrawFromCSV.
The tools allows importing most basic shapes from a CSV file. Usually sourced from a spreadsheet.
https://qcad.org/rsforum/viewtopic.php?t=8135

Also, one could simply use the multi line capabilities of the command line. 8)
Copy the point data, start the point tool (PO) and paste the list in the command line.

The list should then be formatted according your QCAD native settings.
Menu .. App.Prefs .. General .. Coordinate Format (Ctrl.+,)
  • x.xxx,y.yyy (Comma/Dot)
    x.xxx;y.yyy (Semicolon/Dot)
    x,xxx;y,yyy (Semicolon/Comma)
Regards,
CVH
Last edited by CVH on Mon May 31, 2021 7:49 am, edited 1 time in total.

John W
Newbie Member
Posts: 9
Joined: Sat May 29, 2021 8:05 am

Re: Importing Ascii files

Post by John W » Mon May 31, 2021 7:09 am

Thank you for your response. My intention is not only to plot points but also labels for the point name, elevation and code. Librecad has an excellent facility for that and my idea is to replicate that.

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Importing Ascii files

Post by CVH » Mon May 31, 2021 7:56 am

Hi,
If look that up then I come to: https://forum.librecad.org/ASCII-file-f ... 07429.html
N,X,Y,Z,C
Well, I didn't include the Z value throughout the DrawFromCSV tool for the obvious reason that QCAD is 2D.

What are you going to use for N and C?
DFC supports Layers, text and custom properties.

Regards,
CVH

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Importing Ascii files

Post by CVH » Mon May 31, 2021 8:22 am


John W
Newbie Member
Posts: 9
Joined: Sat May 29, 2021 8:05 am

Re: Importing Ascii files

Post by John W » Mon May 31, 2021 9:04 am

Land surveyors use CAD to plot topographic maps from ASCII coordinate files that typically list points in the format N,X,Y,Z,C for example: 1,100,25,50,CLR. Here 1 is the point name (N), 50 is the elevation (Z) and C is a description (e.g. CLR = Centreline of Road). The Z value is not plotted as a coordinate but as a label (same as N and C) which gives the spot height of the point. All of this information is contained in an ASCII file supplied by the surveyor.

The requirement is that N, Z and C must all be plotted adjacent to their point location. Is QCAD able to do that?

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

Re: Importing Ascii files

Post by andrew » Mon May 31, 2021 9:09 am

John: thanks for the details. Sounds straightforward. Do you have a screenshot how this should be rendered? This would be a simple script that imports the CSV and plots the data accordingly.

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Importing Ascii files

Post by CVH » Mon May 31, 2021 9:12 am

John W wrote:
Mon May 31, 2021 9:04 am
The requirement is that N, Z and C must all be plotted adjacent to their point location. Is QCAD able to do that?
Sure, with clever programming, all can be achieved.

The point was that before none provided a certain general format with requirements.
The code of 'tomek' should work out: https://qcad.org/rsforum/viewtopic.php?t=7425

Regards,
CVH

John W
Newbie Member
Posts: 9
Joined: Sat May 29, 2021 8:05 am

Re: Importing Ascii files

Post by John W » Mon May 31, 2021 10:38 am

The rendering is per tomek's original post. As mentioned, my intention is to replicate the facility provided by Librecad which is coded in QML/C++. I also see from the documentation that it is possible to extend QCAD by means of C++ extensions. Perhaps that will be better than using JavaScript but I will need a sample of the C++ format. To get a better idea of my intention, may I suggest you take a look at the Librecad facility in the top menu >> Plugins >> Read ascii points.

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Importing Ascii files

Post by CVH » Mon May 31, 2021 11:08 am

John W wrote:
Mon May 31, 2021 10:38 am
The rendering is per tomek's original post.
And that is imported as such with the script lower in the topic.
John W wrote:
Mon May 31, 2021 10:38 am
Perhaps that will be better than using JavaScript
Most/All tools are implemented in EMCAScript: https://github.com/qcad/qcad
Can't keep you from doing it over in C++

Regards,
CVH

John W
Newbie Member
Posts: 9
Joined: Sat May 29, 2021 8:05 am

Re: Importing Ascii files

Post by John W » Mon May 31, 2021 12:19 pm

Because the Librecad plugin is coded in C++ it makes sense to stay with that if possible. The next step is locating a sample QCAD addon coded in C++ that nserts a menu item and links to the main program with a method to add points/text to the drawing (all in C++ instead of JavaScript). Do you know where I can find that?

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

Re: Importing Ascii files

Post by andrew » Mon May 31, 2021 9:16 pm

This has come up a few times. We will likely add a more universal import of points / labels from CSV for the next release.

John W
Newbie Member
Posts: 9
Joined: Sat May 29, 2021 8:05 am

Re: Importing Ascii files

Post by John W » Tue Jun 01, 2021 5:14 am

The existing "Draw from CSV" doesn't work for me.

With entries as follows I get the message : Unsupported entry. Text line x.

12.5,5.4
7.3,2.5
23.5,5.6

I'd include a screen shot if there was a convenient way of doing that.

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Importing Ascii files

Post by CVH » Tue Jun 01, 2021 5:41 am

DrawFromCSV is set up different.
It can draw most basic shapes from a csv usually sourced from a spreadsheet.
Documentation can be found in the pdf: https://qcad.org/rsforum/viewtopic.php?t=8135#p32813
Example files are included.

A list like:
12.5,5.4
7.3,2.5
23.5,5.6
can be imported by Menu .. Misc .. Import/Export .. Import points.
Or simply by starting the point command and pasting the list in the command line.

If you install the code by 'tomek' as ImportPoints.js under ...\QCAD\scripts\Misc\MiscIO\ImportPoints
Then the standard ImportPoints script is superseded by import survey points.


Regards,
CVH

Post Reply

Return to “QCAD Community Edition”