Converting documents from US Survey units

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
CVH
Premier Member
Posts: 2146
Joined: Wed Sep 27, 2017 4:17 pm

Converting documents from US Survey units

Post by CVH » Fri Sep 23, 2022 7:24 am

Referring to:
https://qcad.org/rsforum/viewtopic.php?f=8&t=9493
https://www.qcad.org/bugtracker/index.p ... sk_id=2390
https://www.qcad.org/bugtracker/index.p ... sk_id=2272

I took the liberty to adapt ConvertUnit.js to include US Survey units.
And that only for a document as a source.

It is of no use to fully support US Survey units because by the end of this year the use of these units should be avoided.
I have no intentions to support a custom conversion factor as requested in the forum topic mentioned above.
For that one can better scale the whole drawing with a factor.
Files can't be saved again in US Survey units like Anđa has proposed in FS 2272.

The main idea is that one can convert documents from US survey units to common supported units.
And that one leaves such files as they originally are for historic and legacy applications as advised by NIST.

I don't have access to such a document, I only presume it opens with the Drawing unit = 'None'.
It would be great if someone would like to test this update or share such a document.

The package is intended to supersede the existing Convert tool.
ConvertUnit.zip
(12.64 KiB) Downloaded 53 times

The 7 files in the zipper must be installed in your QCAD installation path under ...\scripts\Edit\ConvertUnit\
Or in the local data location, see Changelog ... 3.26.2 (2021/04/15):
https://www.ribbonsoft.com/en/documentation/changelog
The folder construction is mandatory, the path to the main script itself should read:
...\scripts\Edit\ConvertUnit\ConvertUnit.js

Andrew may include this update in a next release of QCAD.
The current version is 3.27.6.0.
In such a case it is not required to install this package or if so one can remove it completely including emptied folders.

Regards,
CVH

Anda
Newbie Member
Posts: 5
Joined: Sat Jan 29, 2022 11:16 am

Re: Converting documents from US Survey units

Post by Anda » Fri Sep 23, 2022 9:42 am

Allowing a proper conversion is good for sure, however I think FS#2272 (https://www.qcad.org/bugtracker/index.p ... sk_id=2272) should still be implemented:
  • Converting is not always an option, sometimes you want/need to keep within the given system.
  • If the US states transition from US survey foot to international foot (which I think is a horrible idea), it should get more important to be able to distinguish them.
  • Let's see how "should be avoided" looks in reality, I think this unit will still haunt us for years.
Also, if the units are not properly detected/configured, things like automatic conversion when copying elements from one drawing to another do not work correctly, right?

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

Re: Converting documents from US Survey units

Post by CVH » Sat Sep 24, 2022 6:47 am

Anda,

I hear your frustrations, but there's nothing I can do about that myself. :oops:
I am also just a user who voluntarily shares his scripts.

The QCAD side is just a matter of expanding the unit lists in ...\src\core\RUnit.cpp
Too simple to not fix this in over one year time.

The other player here are the OpenDesign libraries used by QCAD.
'Open' seems like a big word, apparently I can't even create an account to consult the technical data. :shock:

I have a related topic here:
https://qcad.org/rsforum/viewtopic.php?t=9506&p=38295
There are no replies there but understand that I investigated this in depth as far as I am able to.
Only the conversion factor for RS.Lightyear is picked up somehow.
https://github.com/qcad/qcad/commits/ma ... /RUnit.cpp

The presented conversion fix is based on:
https://qcad.org/rsforum/viewtopic.php? ... 493#p38249
Now, one can at least fully convert such a drawing and take it from there.
Leaving the original file 'as is' as advised by NIST.
And true, you need to know yourself that such a document uses US Survey units.
I even doubt that units 21-24 were defined in the 80s.
If so, they should be part of the dxf standard to start with.


And I really tried to stretch this.
With the script at hand, what is textual, one can tryout forcing docVars to be set for units 21-24.

Code: Select all

150    docVars.setUnit(22);
Converting a mm drawing to A: Inch, B: Yard, C: Foot, and saving all trials with docVars = 21 to 24 ...
... $INSUNITS is equal to 1 in all 12 cases and the reported unit when re-opening them is Inch.

Regards,
CVH

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

Re: Converting documents from US Survey units

Post by Husky » Sat Sep 24, 2022 8:37 am

CVH wrote:
Fri Sep 23, 2022 7:24 am
Andrew may include this update in a next release of QCAD.
I don't think that that script is a suitable solution.
Anda wrote:
Fri Sep 23, 2022 9:42 am
Allowing a proper conversion is good for sure, however I think FS#2272 (https://www.qcad.org/bugtracker/index.p ... sk_id=2272) should still be implemented:
I agree.
Anda wrote:
Fri Sep 23, 2022 9:42 am
Also, if the units are not properly detected/configured, things like automatic conversion when copying elements from one drawing to another do not work correctly, right?
Right.
Anda wrote:
Fri Sep 23, 2022 9:42 am
  • Converting is not always an option, sometimes you want/need to keep within the given system.
  • If the US states transition from US survey foot to international foot (which I think is a horrible idea), it should get more important to be able to distinguish them.
  • Let's see how "should be avoided" looks in reality, I think this unit will still haunt us for years.
Yes, yes, nope ........... I'm sure it will hunt us for decades!

In short: Simplest solution in my opinion would be to integrate that missing unit in the QCAD unit list / Converting tool and yes - QCAD needs to be able to detect that unit itself if existent. In the case that a drawing is set to Unit "None" but you know that is in a US Survey unit drawn then you need simply to change the drawing unit below "Drawing Preferences". The advantage of that would be that from now on it is a piece of cake to convert the drawing to the new standards

The whole idea is not to keep this outdated US Survey unit alive - the idea is to make it easy to transform drawings from the old world to the new world. :wink:
Work smart, not hard: QCad Pro

If a thread is considered as "solved" please change the title of the first post to "[solved] Title...". Thanks!

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

Re: Converting documents from US Survey units

Post by CVH » Sat Sep 24, 2022 8:34 pm

Husky wrote:
Sat Sep 24, 2022 8:37 am
Simplest solution in my opinion would be to integrate that missing unit in the QCAD unit list / Converting tool
I can't add it to the units list but I included US Survey units and their factor to meters in the Converting tool.
Husky wrote:
Sat Sep 24, 2022 8:37 am
QCAD needs to be able to detect that unit itself if existent.
Anda reported that drawings with $INSUNITS = 21 are openend with unit 'None' =0.
I can add that QCAD does reads the value perfectly, I would not have expected anything else.
Husky wrote:
Sat Sep 24, 2022 8:37 am
In the case that a drawing is set to Unit "None" but you know that is in a US Survey unit drawn then you need simply to change the drawing unit below "Drawing Preferences".
When you open a file with $INSUNITS = 21 ... 24 the tool can detect that.
Internally QCAD will know that the file is in US Survey units.
Because Convert.js is also used to convert on the fly, one can copy/paste or import regarding the target document its unit.

If "Drawing Preferences" Units could be set, and saved, that would also mean that new files can be created in the 'outdated US Survey units'.
Further, I am not that skilled to adapt the preference page where that will default to 'None'.
The source for the combo's is hard-code there and not constructed from RUnit.cpp lists.
Husky wrote:
Sat Sep 24, 2022 8:37 am
The advantage of that would be that from now on it is a piece of cake to convert the drawing to the new standards.
The whole idea is not to keep this outdated US Survey unit alive - the idea is to make it easy to transform drawings from the old world to the new world.
What you explain here is what the adapted tool does.
It only converts between units whenever required.
One can open, copy from or import files created in US Survey units.
One can not create such files.

But you are right,
"I don't think that that script is a suitable solution"
One should NEVER make an attempt to UPDATE files created in US Survey units.
The file is stored as inches without that unit conversion was involved.

Regards
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”