UPDATE: Centroids 0.31

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

UPDATE: Centroids 0.31

Post by CVH » Sat Nov 20, 2021 3:57 pm

Hi all,
again about the missing links: Centroids.

*** EDIT ***
For the latest version v0.32 refer to:
https://qcad.org/rsforum/viewtopic.php?f=30&t=8970
*** EDIT ***


I started a new topic because it are now 3 Addons in one package:
- Area centroid of surfaces with uniform density. (v0.31)
- Wire centroid of infinite small wires with uniform density. (v0.31)
- Summing markers of the above weighted by their individual density. (v0.11)
For snapshots/releases of QCAD Professional later than 3.26.4 only.

In the earlier releases, centroids for shapes with holes were already possible with a hatched area. 8)
Then one has two distinct densities: one apple/unit² or zero apples/unit². :wink:

Now it is possible to retrieve the center of mass of e.g. a plywood shape with a lead insert somewhere. 8)
... With a wire sticking out if that would be the case. :lol:
Or a paper kite with steel wiring.
To exploit this, one assigns a real world density to the custom property of the markers.
Then one sums these by selection. The tool excludes non markers and the Maths will do the rest. :wink:

Remark that a uniform wire centroid can't really replace a bend tube or bar what are in fact 3D shapes.
Still, given the scale, it can be a good approximation. :wink:

For more details about the fixes and changes I like to refer to the changelog:
ChangeLog.txt
Changed in InfoCentroids version 0.31
(2.52 KiB) Downloaded 408 times
Rather proud of the almost exact full ellipse circumference in addition to some closed forms for ellipses.

*** EDIT ***
Updated to v0.32
Version 0.31 was downloaded 33 times.
*** EDIT ***
InfoCentroids 0.31.zip
3 addons in one.
MiscInformation.xxx are copies from GitHub
and are included for convenience.
(45.35 KiB) Downloaded 392 times

Following the adoption by Andrew they appear in the Misc .. Information menu.
Really sorry for those who endorsed the placement under the Information menu and toolbars.
Not many will really need them at hand that often. (See downloads)


The Addons are donated to the QCAD project 'as is', Andrew may include it in a next release.


Immediate installation: :arrow:
Users that have installed earlier versions manually are advised to remove the added folders and files.
Ensure that the next path exists in your installation folder:
... QCAD\scripts\Misc\MiscInformation (QCAD or QCADCAM or whatever path that is used)
Copy over the files from the zip to that path.
The folder structure is mandatory, for reference: the changelog should be located here:
... QCAD\scripts\Misc\MiscInformation\InfoCentroids\ChangeLog.txt
Folder and file naming and the placement are quite logic.
Win users may require admin rights.

The shortcut 'IM' was already taken :oops: ... Reverted to "AM", "WM" and "CM".
aka: Area center of Mass, Wire(s) center of Mass and Combine centers of Mass

Let's say that this release is a more complete work.
More accurate and neater for sure. :wink:

Regards,
CVH
Last edited by CVH on Tue Dec 14, 2021 8:04 am, edited 2 times in total.

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

Re: UPDATE: Centroids 0.31

Post by Husky » Sat Nov 20, 2021 11:17 pm

1. The installation description fails in my case on a QCAD Version 3.26.4.13 and isn't logical. Unneeded subdirectories, Double menu entry's etc. ...

Husky-2021.11.20-02.png
Husky-2021.11.20-02.png (25.58 KiB) Viewed 8345 times

... yes, I realized why that happened.


2.
CVH wrote:
Sat Nov 20, 2021 3:57 pm
Now it is possible to retrieve the center of mass of e.g. a plywood shape with a lead insert somewhere. 8)
... With a wire sticking out if that would be the case. :lol:
Or a paper kite with steel wiring.
To exploit this, one assigns a real world density to the custom property of the markers.
Then one sums these by selection. The tool excludes non markers and the Maths will do the rest. :wink:
Sounds interesting but I'm zu dummzumzum. This tools (except Area Centroid) are not intuitive and there is no explanation at all how they are supposed to work. If somebody knows how to master this tools please enlighten me.
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: UPDATE: Centroids 0.31

Post by CVH » Sun Nov 21, 2021 8:25 am

Husky wrote:
Sat Nov 20, 2021 11:17 pm
... yes, I realized why that happened.
Great,
the Area Centroid without shortcut is a 'so said compiled' copy that can not be removed by me/us.

The price to pay for shifting it around, fiddling with groups and widgets.

It's all fine when Andrew does that once, or more ... Then the change is immediate, every time.
For us it is a round trip. Centroids as package was released just after Snapshot 3.26.4.13 ...
It is always too late and too early at the same instant, sorry for that.

You may want to disable the old one in the App.Prefs tool section for now.
Clearing visibility and commands.
For some reason the new Addons are not listed under the Misc/Information section ... :?:
Husky wrote:
Sat Nov 20, 2021 11:17 pm
Sounds interesting but I'm zu dummzumzum.
WM sums centroid markers by their location, uniform area/length times their individual density.
Have a look at the custom properties of the odd inner shape of a marker.
The result is a sum of weights and a weighted position.
The tool doesn't care about what is in selection as long as it finds multiple markers.
At present I am not convinced that it should revert to all with no selection.

Some examples:
Summing Centroids.dxf
2 examples of summing centroid markers
(113.46 KiB) Downloaded 385 times
First we set up the uniform density centroids.
Then we set up their local density and apply those values as custom density for each marker.
Finally, we can retrieve the total mass and the center of mass by summing weighted ...
... All as a 2D representation of a 3D problem.
With clever manipulations we can tackle pretty complex problems.

Regards,
CVH

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

Re: UPDATE: Centroids 0.31

Post by petevick » Sun Nov 21, 2021 9:43 am

CVH wrote:
Sun Nov 21, 2021 8:25 am
You may want to disable the old one in the App.Prefs tool section for now.
Clearing visibility and commands.
The only problem doing that is that it removes both entries :?
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Qcad Pro 3.29.6

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

Re: UPDATE: Centroids 0.31

Post by Husky » Sun Nov 21, 2021 9:49 am

CVH wrote:
Sun Nov 21, 2021 8:25 am
Have a look at the custom properties of the odd inner shape of a marker.
The result is a sum of weights and a weighted position.
Ok - now I know where to play with. Thanks.

Question: Is there a way that I can change the decimal and thousands separators? It is confusing if you normally don't use them on that given way. We and a few other countries use them reversed ...
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..."

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

Re: UPDATE: Centroids 0.31

Post by Husky » Sun Nov 21, 2021 9:59 am

@ petevick
petevick wrote:
Sun Nov 21, 2021 9:43 am
The only problem doing that is that it removes both entries :?
Try instead to delete the folder "InfoAreaCentroid" in CVH's download.

Husky-2021.11.21-10.png
Husky-2021.11.21-10.png (23.72 KiB) Viewed 8293 times

As we learned now the tool "InfoAreaCentroid" exist already in QCAD ... :wink:
If the shortcut AM is missing - Application Preferences / Tool Setting can fix that ...
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: UPDATE: Centroids 0.31

Post by CVH » Sun Nov 21, 2021 10:36 am

Husky wrote:
Sun Nov 21, 2021 9:59 am
petevick wrote: ↑Sun Nov 21, 2021 9:43 am
The only problem doing that is that it removes both entries
Try instead to delete the folder "InfoAreaCentroid" in CVH's download.
It seems to be a bigger mess at your sides ... :(
All I can add at this moment, is that when you initiate the latest version of 'AM' it reports its version (v0.31) as a verification.

Each time we learn a little more. :wink:
With little steps, one by one.
Already happy with your interest in evaluating it. :D

Regards,
CVH

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

Re: UPDATE: Centroids 0.31

Post by petevick » Sun Nov 21, 2021 11:03 am

Husky wrote:
Sun Nov 21, 2021 9:59 am
Try instead to delete the folder "InfoAreaCentroid" in CVH's download.

If the shortcut AM is missing - Application Preferences / Tool Setting can fix that ...
Yep, that did the trick Husky :wink: e_ugeek
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Qcad Pro 3.29.6

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

Re: UPDATE: Centroids 0.31

Post by Husky » Mon Nov 22, 2021 1:36 am

Still zu dumzumzum ... :oops:
CVH wrote:
Sun Nov 21, 2021 8:25 am
Have a look at the custom properties of the odd inner shape of a marker.
I did - was that wrong?

What I tested:
Selected the wire,
launched Wire centroid,
selected marker,
Property Editor displays Custom Property's,
CVH wrote:
Sat Nov 20, 2021 3:57 pm
To exploit this, one assigns a real world density to the custom property of the markers.
Then one sums these by selection. The tool excludes non markers and the Maths will do the rest. :wink:
Changed "Density" from 1 to 0.0137,
Value "Weighted" unchanged!!!
How do I get the Weight ...
... and why is there no "Height/Length/Diameter" field? Or at least a cross-section field.
... and why do I not get a Marker for "Sum centroids weighted"
... and why do I don't get Custom Property's for "Area Centroid" (wasn't that part of the last QCAD Snapshot?

What surprised me is that Area and Weighted is identical? Coincidence?

Husky-2021.11.21-01.png
Husky-2021.11.21-01.png (35.3 KiB) Viewed 8238 times

... or even Length could be identical with Weighted? I guess I have to dig out my pocket calculator .... :wink:

Husky-2021.11.21-02.png
Husky-2021.11.21-02.png (34.39 KiB) Viewed 8238 times
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: UPDATE: Centroids 0.31

Post by CVH » Mon Nov 22, 2021 10:12 am

Husky wrote:
Mon Nov 22, 2021 1:36 am
Changed "Density" from 1 to 0.0137,
Value "Weighted" unchanged!!!
Husky,
Custom properties are plain text fields in QCAD, like a memo ... a note.
There is nothing inherited to them like e.g. the 'Length' property of an arc entity.
For arcs, the length property will adapt when one changes: radius or start or end angle ... All properties related to that arc shape.

The custom property 'Weighted' is the recorded result (area/length) for a uniform density of 1.00 of the shape(s) in question.
All condensed in an infinite small point. How the shape(s) looked liked is of no meaning anymore.
A weighted value ... Not to be confused with a weight, meaning the mass.
The location of that point is recorded as the X and the Y value.
There is no link to the shape(s) either and the text values will not adapt to any change applied on that/those shape(s) afterwards.
If you translate the marker as entity that will make no change to the recorded text in the custom properties ...

Recording the calculated results is way more convenient than that the user has to write them down for later usage. :wink:
Believe me when I say that while developing I did that several hundreds times and more. :roll:

The mass of an object is 'Weighted' times 'Density' and remark that both are unit-less.
For areas, 'Weighted' is in squared units and 'Density' would then be in mass/squared units.
For wires that would be units and mass/unit.
In both cases the product is a mass. 8)

Such a product for one to a few should be easy enough to calculate yourself.
1515.298units long times 0.0137apples/length unit = 20.7595826 apples :lol:
The value to weigh with remains 1515.298... (units long), one can still use a steel wire having another density than the 1,5mm² copper wire.

It gets more complicated when combining several centroid results.
Total mass is straightforward: The sum of all the products 'Weighted' times 'Density'.
X & Y on the other hand are combined weighted.
The running sum of Xn times its mass, and that divided by the overall mass. The same for Y values. e_geek
Husky wrote:
Mon Nov 22, 2021 1:36 am
I guess I have to dig out my pocket calculator ....
Currently CM requires two or more markers to be combined.
:idea: I'll change its action for 1 selected marker so that it reports the simple mass product.
Husky wrote:
Mon Nov 22, 2021 1:36 am
... and why do I don't get Custom Property's for "Area Centroid" (wasn't that part of the last QCAD Snapshot?
You probably removed the newer art of the 0.31 release.
I think that only Andrew can solve this mess for the next snapshot/release of QCAD.
(Update was committed 1 hour ago, thanks Andrew)

acentroids 0.31.png
acentroids 0.31.png (15.91 KiB) Viewed 8220 times
Yep, my QCAD scripting projects folder is called 'Crazy' ... :lol:
Husky wrote:
Mon Nov 22, 2021 1:36 am
... and why do I not get a Marker for "Sum centroids weighted"
Early adoption CM version 0.11 ... Still twisting my mind over that.
We can't really mix 'Weighted' values, 'Density' and total mass.
  • What would be the combined density value for the Kite in the example file?
    Even as an average density, that would have no valid meaning at all.
    The average density over [Amm² + Lmm] :!: with unit ... :?:
As a completely different kind of markers, yes.
A point mass located at position X/Y. Again combinable with others :)

At the moment CM v0.11 beats dragging data to a spreadsheet. :wink:
Husky wrote:
Mon Nov 22, 2021 1:36 am
... and why is there no "Height/Length/Diameter" field? Or at least a cross-section field.
Don't really understand the question(s) ... A centroid is an infinite small point.
As if all the mass is condensed in one single point in space.
And a point has no dimensions, right?

True that you have to come up with the local 2D density yourself, similar as in the steel insert example.
Including the required units conversions for the gathered material specific data.
It is not a 3D tool and a material properties list is out of the question.

Now I am going to let rest my center of mass. :lol:
Regards,
CVH

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

Re: UPDATE: Centroids 0.31

Post by Husky » Tue Nov 23, 2021 12:58 am

CVH wrote:
Mon Nov 22, 2021 10:12 am
Custom properties are plain text fields in QCAD, like a memo ... a note.
Yes I know but I thought you came up with something fancy. Never mind.

I admit that I was obviously under a wrong impression. Why? If I see an example drawing with Density (Paper/Cooper) field and weight annotation than I assume it is calculated by the new add on. That was one of the reason for you to promote this add on, or not? As I learned now it turns out it was calculated by hand.
The other thing: Why a Marker, produced by the add on, creates a preset Field (Custom Property) for Density with a value of 1 (what is plain wrong) will stay a mystery to me. In my opinion empty filled fields serves a user better than a field with a wrong value. How will a user figure out (after a month or so working on this drawing) if this field was automatically and wrong filed by an Add on or manually filed on purpose by the user? And what makes you thinking that "Density" is a field what every user needs.

Question: For what is this confusing language good?
1. In the Custom Property's you call it "Weighted:". For the same "thing"in the drawing you use the term "Total length:". Same "thing" should have the same name - or not?
2. If I explode the Kite Polyline and select the lines for "Area Centroid" then a error message pops up that I have a multiple selection. Well, yes I know that but why isn't the tool working? Maybe a warning could help which tells me that I only can use Polylines ... :wink:
3. I assume it makes cense to me to stop further investigation until the tool is fully integrated in a next QCAD snapshot ...

However - the whole centroid thing is a great addition to QCAD. Well done! The till now misleading "Density" thing has room for improvements. :wink:

I'll wait and see!
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..."

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

Re: UPDATE: Centroids 0.31

Post by Husky » Tue Nov 23, 2021 8:59 am

There is no need to shift this conversation to a PM level. Please stop PM me!

In short - the tool is not working as expected. It makes no sense to me to play with a broken tool.

Example: You told me in PM:
CVH wrote:
Tue Nov 23, 2021 5:58 am
Local densities, yes, the more complex math is done by the tool.
For the Kite, select both markers and hit CM, the result will be the values in green(lime).
The weighted point will be where the green(lime) arrow is pointing to.
Same for the insert with a compound density or any amount of selected markers.
Nope - no "complex" math is done if you test it in a new drawing.

New drawing,
Selected two marker!
CM
Result in Command line:
Command: sumcentroid
Centroids weighted sum script (v0.12) by CVH
One marker selected, point mass = 1515.3

For the records - two marker were selected!

Same test in your example drawing.
Result in Command line:
Command: sumcentroid
Centroids weighted sum script (v0.12) by CVH
Weighted mass (2): 23.9596
Combined mass centroid position: (1000.0000000000000, 222.06533962930012)

Your example drawing - deleted original marker - created two new marker (AM, WM)
Result in Command line:
Command: sumcentroid
Centroids weighted sum script (v0.12) by CVH
One marker selected, point mass = 1515.2982

Did I mention that AM doesn't creates Custom Property's at all.

Do you now understand why I did this statement?
Husky wrote:
Tue Nov 23, 2021 12:58 am
I assume it makes cense to me to stop further investigation until the tool is fully integrated in a next QCAD snapshot ...
With other words - I'm out until a revised edition is in the next QCAD update / Snapshot available. :wink:
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: UPDATE: Centroids 0.31

Post by CVH » Tue Nov 23, 2021 9:31 am

All,

An everlasting misconception, I think.
There might be a language barrier too. :wink:

The mass of objects is expressed in kg or lbs or ...
The weight of objects is expressed in Newtons.
Putting an object on a balance would read the acting force divided by (about) 9.81(m/s²).
In fact, the readout is the object its mass instead of its weight.
Then we say that the object its weight is so much in kg or lbs or ... What is the mass ... :lol:
In general we don't mind that at all.

Here we use "weight" in yet another meaning.
'Weighted' is how much that point will weigh in further calculation, the weight of its other properties.
For convenience unit-less so we can mix areas and lengths according the type of the centroid.
https://en.wikipedia.org/wiki/Weighted_arithmetic_mean
https://en.wikipedia.org/wiki/Weight_function
'Density' is again unit-less and must also be expressed according the type.

The area or length for a single centroid is simply equal to its unit-less 'Weighted' value.
But we can't really say that the point is 123.45km long or 123.45in² wide ... :lol:
The centroid labels diversify on the used type, instead of displaying a plain and dull number.
Somewhat similar in Command History info messages.


Any correction or replacement for the term 'Weighted' is welcome. :P
I would also gladly adopt any replacement for 'Density' in the sense of:
The 'Local (compound) relative surface mass density' for the AM tool
or the 'Local (compound) relative linear mass density' for the WM tool.

Regards,
CVH
Last edited by CVH on Tue Nov 23, 2021 10:19 am, edited 2 times in total.

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

Re: UPDATE: Centroids 0.31

Post by CVH » Tue Nov 23, 2021 9:54 am

Husky wrote:
Tue Nov 23, 2021 8:59 am
Do you now understand why I did this statement?
CVH wrote:
Mon Nov 22, 2021 10:12 am
You probably removed the newer art of the 0.31 release.
Please undelete or re-install the content of the updated script folder for AM.
I encourage you to avoid the broken (old) version that has no shortcut listed.

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”