[solved] dwg2svg layer bug introduced in 3.27

If you are having problems with QCAD, post here. Please report bugs through our Bug Tracker instead.

Always attach your original DXF or DWG file and mentions your QCAD version and the platform you are on.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
bastiaan.schaap
Registered Member
Posts: 2
Joined: Mon Jan 17, 2022 5:24 pm

[solved] dwg2svg layer bug introduced in 3.27

Post by bastiaan.schaap » Mon Jan 17, 2022 6:05 pm

I am converting the attached Floor Plan.dxf file to svg using dwg2svg, using command:

Code: Select all

dwg2svg -f -g -flat -w 1 -c 2 -layer '^xref-Bishop.*' -o /tmp/test.svg /tmp/Floor\ plan.dxf
In QCad Pro trial 3.26.4 this worked perfectly, including the correct layer selection (see attached test_326.svg):

Code: Select all

QCAD version  3.26.4


You are using a trial version of QCAD Professional.
If you would like to use this software productively,
please purchase the full version for a small license fee from our
Online Shop at:
https://qcad.org/shop
Thank you for trying this add-on!

Your script will start in 15 seconds...


17:42:30: Debug:    cadFile:  /tmp/Floor plan.dxf
17:42:30: Debug:    svgFile:  /tmp/test.svg
17:42:30: Debug:    calling odInitialize
17:42:30: Debug:    dropped global XDATA (no value):  "ASEBlockHierarchyIndexRecord"

Options:
  Unit                             : mm
  Preserve Geometry                : true
  Minimum lineweight               : 1
  Export Points                    : as circles, radius=2mm
Converting
  from: /tmp/Floor plan.dxf
  to  : /tmp/test.svg
Warning:  Populating font family aliases took 362 ms. Replace uses of missing font family "Archquik.shx" with one that exists to avoid this cost.
17:42:32: Debug:    closing file
Conversion finished.
However, in my purchased Pro 3.27.1, I get warnings, and layer selection doesn't work (all layers are exported, see attached test_327.svg):

Code: Select all

QCAD version  3.27.1
17:41:01: Debug:    cadFile:  /tmp/Floor plan.dxf
17:41:01: Debug:    svgFile:  /tmp/test.svg
17:41:01: Debug:    calling odInitialize
17:41:02: Debug:    dropped global XDATA (no value):  "ASEBlockHierarchyIndexRecord"
Warning:  cannot assign original handle to object
Warning:  collision with object of type: 2
Warning:  cannot assign original handle to object
Warning:  collision with object of type: 2
Warning:  cannot assign original handle to object
Warning:  collision with object of type: 2
Warning:  cannot assign original handle to object
Warning:  collision with object of type: 2
Warning:  cannot assign original handle to object
Warning:  collision with object of type: 2
Warning:  cannot assign original handle to object
Warning:  collision with object of type: 2

Options:
  Unit                             : mm
  Preserve Geometry                : true
  Minimum lineweight               : 1
  Export Points                    : as circles, radius=2mm
Converting
  from: /tmp/Floor plan.dxf
  to  : /tmp/test.svg
Warning:  Populating font family aliases took 367 ms. Replace uses of missing font family "Archquik.shx" with one that exists to avoid this cost.
17:41:04: Debug:    closing file
Conversion finished.
This problem occurs both on Mac OSX Monterey 12.1, as well as the same QCad versions on Ubuntu 12.04 LTS.

Output above is as executed on Mac OS. Note: -layer regex works on 3.26.4 OSX, but doesn't on 3.26.4 Linux :roll:

Any ideas on how/what caused this, and how to fix it? Since we need it badly for our production application. We bought the license specifically for this functionality....
Attachments
test_327.svg
converted using 3.27.1 Licensed
(443.83 KiB) Downloaded 245 times
test_326.svg
converted using 3.26.4 Trial
(97.17 KiB) Downloaded 233 times
Floor plan.dxf
Sample DXF used
(1.07 MiB) Downloaded 219 times

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

Re: dwg2svg layer bug introduced in 3.27

Post by andrew » Mon Jan 17, 2022 8:48 pm

Please try:

Code: Select all

dwg2svg -f -g -flat -w 1 -c 2 -layer='^xref-Bishop.*' -o /tmp/test.svg /tmp/Floor\ plan.dxf
Note the equal sign (=) after -layer. Long switches require an equal sign between the switch and the argument value. I don't think this has changed from 3.26.4 to 3.27.1 though.

bastiaan.schaap
Registered Member
Posts: 2
Joined: Mon Jan 17, 2022 5:24 pm

Re: dwg2svg layer bug introduced in 3.27

Post by bastiaan.schaap » Tue Jan 18, 2022 8:58 am

Hi Andrew, thank you for your response!
I've tried the equal sign like you suggested, and indeed, this seems to work!

Is there any documentation available on how to produce correct regex? I remember reading that PerlRE syntax is used, is that correct?
Also, if we instead of regex supply a comma separated list of layers, how do we escape special characters like '$'?

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

Re: [solved] dwg2svg layer bug introduced in 3.27

Post by andrew » Tue Jan 18, 2022 11:03 am

JavaScript regular expressions are used:
https://www.w3schools.com/jsref/jsref_obj_regexp.asp

The list of layers is split at the comma before regular expression patterns are applied. This has the only limitation that you cannot use a comma in your regular expression (e.g. [,], [^,], n{X,}, etc.).

$ in layer names may need to be escaped as \$ if you're running it for example on bash. This is to circumvent the shell expansion for variables, not QCAD or JavaScript.

Post Reply

Return to “QCAD Troubleshooting and Problems”