[SOLVED] Calculate total area

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
SM_MaGa
Junior Member
Posts: 10
Joined: Tue Apr 13, 2021 3:20 pm

[SOLVED] Calculate total area

Post by SM_MaGa » Tue Apr 13, 2021 3:42 pm

Hi,

i am using the Command Line Tool dwg2csv.bat to export and process information about the entities of a .dxf File.
What i am missing is the total area of the Component.

For that i would like to use a self-made script (or any other means to get access to that information) that calculates the total area and exports it
to a file.

Is there any method i can use to achieve that without having to develop everything from scratch or maybe an example that i can use?

Greetings,
SM_MaGa
Last edited by SM_MaGa on Thu Apr 22, 2021 2:25 pm, edited 1 time in total.

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

Re: Calculate total area

Post by andrew » Tue Apr 13, 2021 5:05 pm

What exactly would a "Component" be? Can you please attach a DXF file or screenshot? Thanks for any clarification you can provide.

SM_MaGa
Junior Member
Posts: 10
Joined: Tue Apr 13, 2021 3:20 pm

Re: Calculate total area

Post by SM_MaGa » Wed Apr 14, 2021 10:55 am

Hi @andrew,

thanks for taking your time.
I attached attached a .dxf as a sample.

By Component i mean the whole thing described by the .dxf File.
Even better if i could exclude Measurement Information (Entities) thats included in the .dxf file, but thats not necessary.

Using the QCAD UI i can use the Polygonal Area tool to calculate the Area but in a script i am not sure about that.

Greetings,
SM_MaGa
Attachments
Treppe Halle-2.dxf
(3.34 KiB) Downloaded 382 times

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

Re: Calculate total area

Post by andrew » Thu Apr 15, 2021 1:29 pm

As a first step, I would suggest to create a solid fill from the contents. This will only succeed if the file exclusively contains closed contours:

Code: Select all

dwghatch -o file_solid_fill.dxf file.dxf
Although currently not included in QCAD Pro, we do have a command line script here that can then output the area of all solid fills or hatches per layer. This would look like this:

Code: Select all

dwghatcharea file_solid_fill.dxf

0 : 64717.33669359441
1 : 0
2 : 0
3 : 0
4 : 0
5 : 0
6 : 0
7 : 0
8 : 0
Usage info about dwghatcharea at:
https://qcad.org/en/products/qcad-comma ... ghatcharea

I'm happy to send this to you. Do you have a license for QCAD Professional or are you evaluating the trial version?

SM_MaGa
Junior Member
Posts: 10
Joined: Tue Apr 13, 2021 3:20 pm

Re: Calculate total area

Post by SM_MaGa » Thu Apr 15, 2021 6:41 pm

That looks very promising!
Yes, please send the command line script to me.

I am using a licensed version of QCAD/CAM on one of my Customers Systems.

SM_MaGa
Junior Member
Posts: 10
Joined: Tue Apr 13, 2021 3:20 pm

Re: Calculate total area

Post by SM_MaGa » Thu Apr 22, 2021 1:18 pm

The script provided by @andrew provides exactly what i needed. Thus this thread can be closed. Thank you.

User avatar
petevick
Premier Member
Posts: 392
Joined: Tue May 19, 2020 9:34 am
Location: North Norfolk coast UK

Re: Calculate total area

Post by petevick » Thu Apr 22, 2021 2:23 pm

SM_MaGa wrote:
Thu Apr 22, 2021 1:18 pm
The script provided by @andrew provides exactly what i needed. Thus this thread can be closed. Thank you.
you cam mark the thread closed yourself by adding [SOLVED] to the title of your original post --> [SOLVED] Calculate total area
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Qcad Pro 3.29.6

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”