Inserting ScriptItem without unit conversion

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: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Inserting ScriptItem without unit conversion

Post by CVH » Sat Aug 06, 2022 5:05 am

Referring to:
Husky wrote:
Sat Jul 30, 2022 10:56 am
@ MikeJ,

I tested in a mm unit drawing the Architecture / Window feature. With a scale of 1, a 24 by 8 window turns out to be 609.6 by 203.2 in size. That is 25.4 times larger than it should be. Why is it scaled with an inch factor?
And what follows.

Referring to:
MikeJ wrote:
Thu Aug 04, 2022 8:48 am
Also, go catch on the unit conversion issue. I've always wondered why items what convert rather than draw what was entered (like the MyRectangle.js). I use InsertScriptItem.js as well for the insertion of scripts in the Tablet Grid ...
Referring to:
https://www.ribbonsoft.com/bugtracker/i ... sk_id=2385
And the possible fix proposed.

I added lines 47-49 in InsertScriptItem.prototype.beginEvent of ...scripts\Block\InsertScriptItem\InsertScriptItem.js

Code: Select all

45 ...
46    this.docItem = new RDocument(ms, si);
47    // # Issue fixed # Unit conversion may occur depending App.Prefs. units for new documents and those of the target drawing.
48    // Fixed with setting no unit.
49    this.docItem.setUnit(RS.None);
50 ...
Script items are now inserted without unit conversion. :P

Meaning that:
Inserting a ‘CubeCuttingOut’ with the default size 10 would result in a cube sized 10mm or 10inch depending the target document units.
Regardless of the App.Prefs. units for new documents.
The same is true for the Architecture / Window feature of the QCAD Utilities by MikeJ.

Had to tweak the include on line 21 there dotdot isn't functional over here in a copy of the script.

Code: Select all

21    include("../InsertBlockItem/InsertBlockItem.js");
21    include("scripts/Block/InsertBlockItem/InsertBlockItem.js"); 
Regards,
CVH

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

Re: Inserting ScriptItem without unit conversion

Post by CVH » Sat Aug 06, 2022 6:19 am

The only issue now is which default values were hard-coded when developing a library script item ...
... And that any change by a user is not saved persistent.

'DiningTable' is 160x100units by default, which doesn't make sense on a mm drawing, nor in inches.

Without the fix that would be in units for new documents and even then it would only make sense if that was set to cm.

BTW: Table Type isn't used internally by the script.

Regards,
CVH

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

Re: Inserting ScriptItem without unit conversion

Post by CVH » Wed Aug 17, 2022 4:53 pm

This should be fixed for the next release ...

Thanks Andrew.
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”