Export Hatch Segments to CSV file

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

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

Export Hatch Segments to CSV file

Post by CVH » Sun Aug 30, 2020 12:09 pm

Based on this:
https://www.qcad.org/rsforum/viewtopic.php?f=30&t=7497

Especially for the 'Hatchers' among us. :wink:
As John Hyslop wrote, it is hard to get good numbers for hatch file definition from QCAD.
https://www.qcad.org/rsforum/viewtopic.php?f=33&t=7543

One could blow up everything with factor 1000000, take the numbers and correct the decimal point place. :roll:

The Addon documents the selected line entities (or all from the active layer) to a CSV file of choice.
Listed are:
- Line angle >> Hatch segment orientation (NOT normalized)
- Line Startpoint in X and Y >> Hatch segment startpoint in X and Y
- Line Length >> dash1
It uses standard hatch formatting with a dot and a comma by default. :wink:
It has leading zero if any and no trailing zero's.
More than 16 significant digits (disregarding the dP) is common, only 15.95 are correct. :shock: e_geek

I usually have that CSV file open in NPP (Notepad++)
As QCAD alters this file, NPP will propose to reload the file on getting the focus.
So in 4-5 clicks I have all numbers, and up to 15.95 significant digits precise. :P

I am not going to debate how accurate these are but let's say 'they are as good as they get'.
Important is that properties are much less accurate when the line props rely on or are keyed in as numbers.

Install in a new folder ...QCAD\scripts\Misc\Examples\IOExamples\DocHatchSegments (Mandatory)
The file is called ...QCAD\scripts\Misc\Examples\IOExamples\DocHatchSegments\DocHatchSegments.js (Mandatory)
No Icon yet ... I am not happy with the former CSV icon because red is associated with pdf.
Green maybe?

Regards,
CVH
Attachments
DocHatchSegments.zip
Addon scriptfile
(3.24 KiB) Downloaded 650 times
Last edited by CVH on Mon Aug 31, 2020 12:03 pm, edited 3 times in total.

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

Re: Export Hatch Segments to CSV file

Post by CVH » Sun Aug 30, 2020 12:22 pm

:oops: Forgot the shortcuts :oops:
Can't come up with a short one ....
The entry for setDefaultCommands should read:

Code: Select all

action.setDefaultCommands(["dochatch"]);    // An Array!
The zip is replaced.
CVH

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

Re: Export Hatch Segments to CSV file

Post by CVH » Wed Sep 02, 2020 11:19 am

Hi All,
Came up with new icons. Green it is.
(A little fight with Inkscape text and gradient fill) :wink:

Iconfile:
HatchLineCsvExport.svg
(30.31 KiB) Downloaded 680 times
Fast Install:
- Copy the svg over to the DocHatchSegments folder.
- Alter the Init section in DocHatchSegments.js so it reads:

Code: Select all

    action.setIcon(basePath + "/HatchLineCsvExport.svg");
All included in new zipper.

Regards,
CVH
Attachments
DocHatchSegments.zip
(20.76 KiB) Downloaded 646 times

John Hyslop
Premier Member
Posts: 474
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Export Hatch Segments to CSV file

Post by John Hyslop » Sat Sep 05, 2020 4:38 am

Hi CVH

I just found out today something I wasn't aware of.....
Each line in a pattern definition can contain up to 80 characters e_surprised
the script spits out a line up to 18 Characters per cell (that's including commas and points) if you except the max output
that would make 1 line (18x7)= 126 Characters 46 more than allowed? if you take into account the parts that need to be
added to create a Hatch Delta Shifts X,Y and Pen Up...& using the same number of Characters....
Is this correct?
Also found out that the name of the hatch can be no longer than 31 Characters..
Interesting :-)

Question is what happens after 80 limit, I'm guessing it's ignored :?
Cheers
John
PS I like the script :) very handy
Attachments
Hatches.jpg
Hatches.jpg (46.03 KiB) Viewed 15722 times
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

John Hyslop
Premier Member
Posts: 474
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Export Hatch Segments to CSV file

Post by John Hyslop » Sun Sep 06, 2020 5:46 am

Hi All

Here's something interesting, the limit stated for hatch pattern Name lengths on the internet
vary from 31 to 34 characters..... Well :roll:

AutoCad, I did some testing and can confirm it does have a limit of 34 characters it crashes if you select a pattern larger than this.
QCAD however does not have this limitation, I just tested and loaded a hatch pattern
file 100 characters long with no problems... I know this is not practical but I was interested
in it's limitations , I haven't gone beyond the 100 and don't intend to, just thought all the
Hatchers out there would find this interesting, I'm setting a limit on my "Basic Hatch Pattern Tool "
to 34 characters just to keep inline with other similar Cad software that use Hatch Patterns...

So bottom line is no need for string length counts on QCAD patterns as I couldn't imagine anyone going over 100 characters :lol:
or what ever the limit may be?

Cheers
John
Attachments
Hatch Pattern Name 100 Long.jpg
Hatch Pattern Name 100 Long.jpg (54.34 KiB) Viewed 15685 times
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

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

Re: Export Hatch Segments to CSV file

Post by CVH » Sun Sep 06, 2020 6:08 am

Sorry, can not agree.

With 34 you are not compatible with those soft that uses 31 strickt.

The norm states 32 chars starting with a '*' >> 31.
This is from the days that filenames could be 31 + dot + 3 (an enhancement over 8 + dot + 3)

My point of view.
CVH

John Hyslop
Premier Member
Posts: 474
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Export Hatch Segments to CSV file

Post by John Hyslop » Sun Sep 06, 2020 6:42 am

Hi CVH

What Software uses 31?
DO they use the same format? I know Revit is Close but the header would need changed to work..
Are you talking about AT PCs 486 with Math Coprocessors From way back... software that wouldn't run on PC's nowadays? :!:
If you point me to it I'll update to max 31 to comply ..
Someone posted on AutoCad Forum 31 Limit but this is incorrect
I already tested in AutoCad... it is confirmed 34 max..

https://forums.autodesk.com/t5/autocad- ... -p/8751694

QCAD works with 100 Characters or more e_surprised


Also the 34 does not include the Dot and the 3 characters in PAT :roll:
So String Count of the File Name Would Be 38 Max ( Including the dot and file extension PAT )
Tested & Proved working as stated above..

Cheers
John
Last edited by John Hyslop on Sun Sep 06, 2020 7:06 am, edited 1 time in total.
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

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

Re: Export Hatch Segments to CSV file

Post by CVH » Sun Sep 06, 2020 7:04 am

I can agree in that QCAD is tolerant up to a point it is not conflicting with anything else.

QCAD reads long pattern names.
It even writes long pattern names into a dxf file.
And it reloads those.
Super tolerant it seems. That is very good indeed.
ACAD isn't. 34 max.
So it's up to us pattern designers.

The same goes for line entry length maxed at 80.
QCAD will read any string of numbers on a line and split it up at the comma's.
In writing it in a dxf that differs.
QCAD includes the float value not the actual string.

Another exception:
QCAD converts names into uppercase.
The allowed chars are both [A-Z] & [a-z].
The text comparisons is twofold.
Listing patterns is case depending
Use is case independent.

Hatch patterns files for general use, have to comply with:
https://knowledge.autodesk.com/support/ ... E-htm.html
dxf is their norm.

QCAD patterns don't but are in uppercase.
(until Andrew decides otherwise)

Regards,
CVH

John Hyslop
Premier Member
Posts: 474
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Export Hatch Segments to CSV file

Post by John Hyslop » Sun Sep 06, 2020 7:10 am

Hi CVH

I still cannot see any 31 character limit in this link, please advise on the software that requires that limit?

Cheers
John
Attachments
AutoCadPattenrLimit.jpg
AutoCadPattenrLimit.jpg (226.8 KiB) Viewed 15667 times
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

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

Re: Export Hatch Segments to CSV file

Post by CVH » Sun Sep 06, 2020 7:29 am

Why are you shouting?

About 1 scrolltick down:
Regardless of where a definition is stored, hatch patterns have the same structure.
They have a header line with a name, which begins with an asterisk and is no more than 31 characters long, and an optional description.
Cheers,
CVH

John Hyslop
Premier Member
Posts: 474
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Export Hatch Segments to CSV file

Post by John Hyslop » Sun Sep 06, 2020 7:30 am

Hi CVH

Where is this information and to what software does this apply?
And should we comply with solid works Draftsight :) 15 Limit LOL
Cheers
John
http://help.solidworks.com/2019/english ... definition.
Attachments
DraftSight.jpg
DraftSight.jpg (199.5 KiB) Viewed 15663 times
Last edited by John Hyslop on Sun Sep 06, 2020 7:41 am, edited 1 time in total.
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

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

Re: Export Hatch Segments to CSV file

Post by CVH » Sun Sep 06, 2020 7:40 am

In the link where you said you could find it.
Again:
https://knowledge.autodesk.com/support/ ... E-htm.html

Scroll a little down.
Heading: Hatch Pattern Definitions

Just above:
*pattern-name, description
CVH

John Hyslop
Premier Member
Posts: 474
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Export Hatch Segments to CSV file

Post by John Hyslop » Sun Sep 06, 2020 7:45 am

Hi CVH

Are you going to comply also to AutoCads Biggest competitor DraftSight? 15 ?

That information I can guarantee is incorrect...
would you like a screen video capture of AutoCad reading in a 34 Character filename?
A string length of 38...

Cheers
John
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

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

Re: Export Hatch Segments to CSV file

Post by CVH » Sun Sep 06, 2020 7:50 am

No, to the guys who started with it and set the standards (about 40 years ago)
Pls
313131.png
313131.png (66.52 KiB) Viewed 15658 times

John Hyslop
Premier Member
Posts: 474
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Export Hatch Segments to CSV file

Post by John Hyslop » Sun Sep 06, 2020 7:53 am

Hi CVH

This information is wrong... I have and others have proved this.. the limit is 34 file name length :roll:

Cheers
John
Hatch Pattern applied in AutoCad [ JOHN_JOHN_JOHN_JOHN_JOHN_JOHN_JOHN.PAT ] 34 Characters
See name in screenshot it comes up when hovered over ... I used my name and an underscore for count of 5
if i add 1 more Character it crashes.. so 34 is the limit... here's the proof... :shock:

31 limit is incorrect... end of story..
Attachments
34-NAME.jpg
34-NAME.jpg (670.9 KiB) Viewed 15656 times
Last edited by John Hyslop on Sun Sep 06, 2020 8:09 am, edited 3 times in total.
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”