Change draw preferences by script

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.

Post Reply
sinase
Active Member
Posts: 47
Joined: Sat Jan 30, 2021 11:12 pm

Change draw preferences by script

Post by sinase » Wed Mar 24, 2021 5:43 pm

Hello,

I have a problem when i receive a .dxf with the draw preferences in inches. Until this moment, i had worked with mm files, but i have a file with inch tolerances and, when i copy and paste in new file, this measure is changed x25,4 (find attached both files).

If i change that configuration to "none" in both file, the measurement is preserved and i think is correct for my project. Is it possible to change this configuration after open the file by script way?
unit.png
unit.png (28.62 KiB) Viewed 6630 times
Thanks.
Attachments
mm.dxf
(100.31 KiB) Downloaded 403 times
inch.dxf
(103.44 KiB) Downloaded 383 times

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 4935
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Change draw preferences by script

Post by Husky » Wed Mar 24, 2021 8:55 pm

Hi,
sinase wrote:
Wed Mar 24, 2021 5:43 pm
Hello,

I have a problem when i receive a .dxf with the draw preferences in inches. Until this moment, i had worked with mm files, but i have a file with inch tolerances and, when i copy and paste in new file, this measure is changed x25,4 (find attached both files).
Isn't that nice - QCAD converts correctly and knows that a inch is 25.4 mm :wink:
sinase wrote:
Wed Mar 24, 2021 5:43 pm
If i change that configuration to "none" in both file, the measurement is preserved and i think is correct for my project.
Please explain "correct for my project". In my understanding a converted unit from inch to mm by a multiplication of 25.4 times is correct. How can a change to none/none provide a correct calculated drawing info?
Work smart, not hard: QCad Pro
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."

sinase
Active Member
Posts: 47
Joined: Sat Jan 30, 2021 11:12 pm

Re: Change draw preferences by script

Post by sinase » Thu Mar 25, 2021 8:44 am

Hello,

I will receive .dxf or .dwg files and i need to merge all of them (these files have elements, text, dimensions... that i don't need). I do that helping my with the merge and bbox command, to try to organizate as much as possible all the figures (i use VB to programming this operations). That operations are executed on the bakground and, when i have the complete file with all draws, i need to select only the figures that i need to calculate different properties (area, perimeter, number of loops, ...). For that, is necesary to select each figure and put on other new file (cut and paste operation by script) and other secundary application is tasked to calculate the properties that i have told before.

Is for that because i need to asegurate that all measures must be in mm or none, because the intention isn't to check the draw unit measure in any moment, and that secoundary app will calculate all measures in mm.

Thank you.
Regards.

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

Re: Change draw preferences by script

Post by CVH » Thu Mar 25, 2021 10:06 am

Hi,
Among others,
https://www.qcad.org/doc/qcad/latest/de ... ument.html
document units can be set by script.
https://www.qcad.org/doc/qcad/latest/de ... f8e2780516

Important: That doesn't convert between units.
A value 101.123 stays 101.123 ... mm, inches, kilometers ....
In essence a dxf has no unit.

Using 'none' to merge would NOT convert at all when importing. :wink:

Regards,
CVH

sinase
Active Member
Posts: 47
Joined: Sat Jan 30, 2021 11:12 pm

Re: Change draw preferences by script

Post by sinase » Thu Mar 25, 2021 12:10 pm

Thank you, i think that i will can to work on this way, I can open every document, to change that parameter with getDocument().setUnit(RS.Millimeter); and save.

I will try to automatizate this.

I have found a post with similar topic:
https://qcad.org/rsforum/viewtopic.php? ... nit#p17723

Thank you again for your help.
Regards.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”