QCAD Utilities

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

Re: QCAD Utilities

Post by CVH » Sat Jul 30, 2022 6:21 pm

Husky wrote:
Sat Jul 30, 2022 10:56 am
Why is it scaled with an inch factor?
Isn't that right?
A 24" by 8" window would automatically convert to 609.6mm by 203.2mm in a millimeter unit drawing.
The same would happen if you import a dxf in inch into a drawing in mm ...

Regards,
CVH

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

Re: QCAD Utilities

Post by Husky » Sat Jul 30, 2022 10:41 pm

CVH wrote:
Sat Jul 30, 2022 6:21 pm
Isn't that right?
No, not even close ...
CVH wrote:
Sat Jul 30, 2022 6:21 pm
A 24" by 8" window would automatically convert to 609.6mm by 203.2mm in a millimeter unit drawing.
Why is it automatically converting the unit? There is no need to convert anything! I've used plain numbers for the window without a unit what means that it has to use the global unit set below Drawing Preferences. 24 by 8 would then be 24 mm by 8 mm and not 609.6mm by 203.2mm,

If you like you can compare the expected functionality of the Table Grid Widgets with the "Rectangle with size" tool (RS). In the rectangle tool - if you need to draw a rectangle 24 by 8 your input would be 24 by 8. Then your rightful expectation would be to get a 24 by 8 but not a 609.6 by 203.2 rectangle in Model_Space. No matter which unit is used.
CVH wrote:
Sat Jul 30, 2022 6:21 pm
The same would happen if you import a dxf in inch into a drawing in mm ...
No, that isn't the same! That is a completely different story because I did not import or Copy/Paste from one unit drawing to a different unit drawing. My drawing is set to mm and there is no need referring to the task to convert anything.

Long story short - The Tablet Grid widgets works only correctly with values if your drawing is set to inch. Using a different unit triggers an unwanted conversion of the used values.

BTW: Unit converting happens only by use of the Widgets - if I insert something with an Option bar dialog it sticks to the drawing unit.
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..."

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

Re: QCAD Utilities

Post by CVH » Sun Jul 31, 2022 5:42 am

Husky wrote:
Sat Jul 30, 2022 10:56 am
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.
Installed it on a 64-bit computer there the 32-bit installer won't run.

Got it just inverse.
Inserted in a mm drawing I get 24mm by 8mm.
In a drawing in inch it is 0.94488189" by 0.31496063".
metric test.dxf
(95.71 KiB) Downloaded 380 times
imperial test.dxf
(95.87 KiB) Downloaded 384 times

If I dig a little deeper I find that it is inserted as a ScriptItems.
That would explain the additional scaling.
Husky wrote:
Sat Jul 30, 2022 10:41 pm
If you like you can compare the expected functionality of the Table Grid Widgets with the "Rectangle with size" tool (RS).
I am comparing it with the library Browser ... :wink:
When I insert a CubeCuttingOut in the default size 10 in an inch drawing it is 0.39370079" over here what is indeed 10mm.

Another example from the default library items:
A doubled bed 200x100; The naming is in cm, the file is in meters and it inserts as 2000mm by 1000mm or as 78.740" by 70.866"...
Only here it is fully predictable because the source is a dxf file with a defined unit.

We could enter a bugreport on how ScriptItems are inserted ... :wink:
It might be that it has something to do with what the units for a new file are set to.
That is mm, mm, metric in my case.


What I find misleading is that the help file states "The Window utility is a block script to a draw bi-fold door ..."
First, it's not drawn as a block and second, it's not a door either ... :lol:

Regards,
CVH
Last edited by CVH on Sun Jul 31, 2022 9:43 am, edited 1 time in total.

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

Re: QCAD Utilities

Post by CVH » Sun Jul 31, 2022 6:00 am

CVH wrote:
Sun Jul 31, 2022 5:42 am
It might be that it has something to do with what the units for a new file are set to.
I think that this is confirmed ... ScriptItems are firts created on a new offline document.
https://github.com/qcad/qcad/blob/bc881 ... iptItem.js

The Option Toolbar icon and options are also the same for library script items and the window utility. :wink:

https://www.ribbonsoft.com/bugtracker/i ... sk_id=2385

Regards,
CVH

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

Re: QCAD Utilities

Post by CVH » Thu Aug 04, 2022 6:31 am

Mike,

Some short remarks picked up on the Win10 64bit PC ... All in a hurry :wink:
(32bit msi fails to run :( )

- I would prefer a combobox for an elbow with an arbitrary angle.
I also like the RMathLineEdit functionality throughout QCAD.

- I understand that appendages can be added aligned at any line or line segments.
The size is then related to the selected line/segment and not to the options what is not grayed out.
On a duct 100mm by 2m (a polyline) that may also propose a 2m wide elbow. :shock:
Could the appendages tools made so that the length of a duct is omitted as candidate ...
... Thinking of adding a custom property 'Width' ...

- Structural Pipe: What does endpoint do? :?

- "The Layer Manager tools database has most common combinations of layers ... "
My dropdowns are empty and do not accept editing. :shock:
>aia.db< Seems to hold relevant textual readable data.
No copy of >aia.db< under C:\Users\
Must I copy that over myself?

Regards,
CVH

MikeJ
Junior Member
Posts: 16
Joined: Mon Feb 15, 2021 9:29 am

Re: QCAD Utilities

Post by MikeJ » Thu Aug 04, 2022 8:48 am

Thanks for the feedback!
Some short remarks picked up on the Win10 64bit PC ... All in a hurry :wink:
(32bit msi fails to run :( )
That is concerning.. it sounds like a Windows Installer issue... I may of messed up in my steps in deployment doing both 64 and 32 bits.
- I would prefer a combobox for an elbow with an arbitrary angle.
I also like the RMathLineEdit functionality throughout QCAD.
I've set the duct fitting angles as fixed to align with SMACNA's angles. So when doing duct loss calculations you are going by what's available. What I want to do in the future is have a utility to export ductwork to an external app to run calculations (equal friction, equivalent length, static regain) so the duct fittings must align to SMACNA. The only issue I have is running vertical ductwork atm.. but I have an idea ;)
- I understand that appendages can be added aligned at any line or line segments.
The size is then related to the selected line/segment and not to the options what is not grayed out.
On a duct 100mm by 2m (a polyline) that may also propose a 2m wide elbow. :shock:
Could the appendages tools made so that the length of a duct is omitted as candidate ...
... Thinking of adding a custom property 'Width' ...
I agree, I need to change so that the width is grayed out when selecting and perhaps a custom property as you said.
- Structural Pipe: What does endpoint do? :?
I does absolutely nothing! :) I use a common core for all the structural scripts so I'll have to bypass the getAuxPreview in this case.
- "The Layer Manager tools database has most common combinations of layers ... "
My dropdowns are empty and do not accept editing. :shock:
>aia.db< Seems to hold relevant textual readable data.
No copy of >aia.db< under C:\Users\
Must I copy that over myself?
Darn.. missed that. It's suppose to copy the AIA.db from the ../QCAD/utility/data folder to your RSettings.getDataLocation (so that it can be edited by the user). It currently uses the basePath to determine the location of the original and then copy it to the RSettings.getDataLocation()... I need to change it from the basePath to the QCoreApplication.applicationDirPath.

You can copy the AIA.db manually to that location and it should work.
What I find misleading is that the help file states "The Window utility is a block script to a draw bi-fold door ..."
First, it's not drawn as a block and second, it's not a door either ... :lol:
For the life of me I don't know where I got the term Block Script.... I'll change that to Browser Script I think.

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. I understand the concept of why it does and it makes sense but the only way to make your base units without conversion to something else is by setting it through the Application Preferences first then creating a new drawing (at least it appears that way).

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

Re: QCAD Utilities

Post by CVH » Thu Aug 04, 2022 4:09 pm

MikeJ wrote:
Thu Aug 04, 2022 8:48 am
I've set the duct fitting angles as fixed to align with SMACNA's angles.
I do understand that ... Your tools can be used to draw piping too.
There are occasions that we modify a 90° elbow to lets say 87° or any custom size ....

Tools for QCAD should be all-round, you can never predict what a user might want to do with them ... :wink:

RSettings.getDataLocation() works in all my custom scripts.
I had issues with the folder separator until I used QDir.separator instead of slash or backslash.
MikeJ wrote:
Thu Aug 04, 2022 8:48 am
the only way to make your base units without conversion to something else is by setting it through the Application Preferences first then creating a new drawing (at least it appears that way).
I think that it is no good idea to change the App.Prefs. unless you correct it back ... See DrawFromCSV beginEvent.
Another way would be to retrieve what it would be and then counteract that.

Code: Select all

unit = RSettings.getIntValue("UnitSettings/Unit", RS.Millimeter);
You can also retrieve the current active document its drawing unit.
Still, I think it is a bug that should be addressed by Andrew.

Regards,
CVH

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

Re: QCAD Utilities

Post by CVH » Sat Aug 06, 2022 3:44 am

MikeJ wrote:
Thu Aug 04, 2022 8:48 am
I need to change it from the basePath to the QCoreApplication.applicationDirPath.
Mike,
I knew I had something scribbled down about this but couldn't pinpoint where.
But I found it again, it had to do with fixing CreateLibraryItem.js
https://qcad.org/rsforum/viewtopic.php? ... 979#p34979

RSettings.getApplicationPath()
RSettings.getLaunchPath()
Both return "C:/Program Files/QCAD" in my case.

The difference is explained here:
https://qcad.org/rsforum/viewtopic.php?f=30&t=8772

Still, CreateLibraryItem.js revert to RSettings.getLaunchPath(), I count 11 hits in 9 scriptfiles, 26 in total.
None for RSettings.getApplicationPath(), 17 in total.

In RSettings.cpp I find that:
RSettings::getApplicationPath() returns QApplication::applicationDirPath()
And for RSettings::getLaunchPath() I read:
Path from where the application was launched (can be any path).

Regards,
CVH
Last edited by CVH on Sat Aug 06, 2022 5:42 am, edited 1 time in total.

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

Re: QCAD Utilities

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

MikeJ wrote:
Thu Aug 04, 2022 8:48 am
Also, go catch on the unit conversion issue. ...
Please refer to:
https://qcad.org/rsforum/viewtopic.php?f=30&t=9466

Regards,
CVH

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

Re: QCAD Utilities

Post by CVH » Sat Aug 06, 2022 7:36 am

MikeJ wrote:
Thu Aug 04, 2022 8:48 am
For the life of me I don't know where I got the term Block Script....
Could it be because InsertScriptItem is located under .../scripts/Blocks?
:wink:

Regards,
CVH

MikeJ
Junior Member
Posts: 16
Joined: Mon Feb 15, 2021 9:29 am

Re: QCAD Utilities

Post by MikeJ » Mon Aug 08, 2022 6:39 pm

I've created a new installs (version 3.1.10) and put them on the initial post.

I tested the 32 bit install on a different computer (Windows 10) and worked ok.

BTW, I found out one reason that the Layer Manager doesn't populate the dropdowns is because the AIA.db doesn't get copied to your QCAD user folder (suppose to be located at ...\AppData\Local\QCAD\QCAD. This is where RSettings.getDataLocation points to. So as I mentioned before when you start up Layer Manager it checks if the AIA.db is found in your local folder and if not, it copies it from the program files location.

What I found when I installed QCAD on another computer is that the ...\AppData\Local\QCAD\QCAD didn't exist so it couldn't copy the database over. It appears that this folder doesn't get created until you check for updates in QCAD (Help > Check for QCAD Pro Updates..). Once you click that then QCAD creates the ...\AppData\Local\QCAD\QCAD folder and creates an updates.html file. After the folder is created by QCAD then Layer Manager will work.

Is there an API to have QCAD create the folder that RSettings.getDataLocation will point to or is it best just to create the folder in my code?

Thanks

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

Re: QCAD Utilities

Post by CVH » Mon Aug 08, 2022 7:25 pm

MikeJ wrote:
Mon Aug 08, 2022 6:39 pm
What I found when I installed QCAD on another computer is that the ...\AppData\Local\QCAD\QCAD didn't exist so it couldn't copy the database over.
In my case it existed ... On both computers.
There I have several trial scripts, some custom 'fixed' scripts and a vast amount of hatch patterns.
I have a functional tool that creates hatch patterns from almost anything.
See some to more of John Hyslop pat file headers.
A rebuild of FlexPainter stores its patterns there.
....
..
.

In any case, good practice would be to check if it exist.
Found in Library.js:

Code: Select all

    var destDir = new QDir(destDirPath);
    if (!destDir.exists()) {
        destDir.mkdir(destDirPath);
    }
I'll will test the 32bit msi within a few days

Regards,
CVH

MikeJ
Junior Member
Posts: 16
Joined: Mon Feb 15, 2021 9:29 am

Re: QCAD Utilities

Post by MikeJ » Tue Aug 09, 2022 2:50 pm

Found the API to create the RSettings.getDataLocation() if not found (this is used in the CheckForUpdates.js):

Code: Select all

downloadToFile(QUrl.fromLocalFile(sourceName).toString(), RSettings.getDataLocation(), "AIA.db", 10000);
The downloadToFile function is part of RScriptHandler class. So does this very nicely in one line of code.

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

Re: QCAD Utilities

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

Husky wrote:
Sat Jul 30, 2022 10:56 am
Why is it scaled with an inch factor?
Should be fixed in the next release :wink:

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”