How to change the size of the RLeaderData or RLeaderEntity arrowhead in a script

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
mrhickman53
Junior Member
Posts: 19
Joined: Thu Sep 07, 2023 1:17 am
Location: USA

How to change the size of the RLeaderData or RLeaderEntity arrowhead in a script

Post by mrhickman53 » Tue Apr 30, 2024 2:08 pm

I can change arrowhead sizes interactively, but cannot find any methods in the dev guide or example scripts that inform me how to do so when creating the leader in a script.

Is there a source other than QCADdev, this forum and the source code for the scripts that I should be consulting?

In the meantime, is there a method through the methods accessible in scripts to modify the arrowhead size?

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

Re: How to change the size of the RLeaderData or RLeaderEntity arrowhead in a script

Post by CVH » Tue Apr 30, 2024 4:26 pm

Hi,

I think this should be possible ...

Both the entity and the data have a method to set the scale:
https://qcad.org/doc/qcad/3.0/developer ... ntity.html
https://qcad.org/doc/qcad/3.0/developer ... _data.html

To overide the standard Dim settings you probably need
- setDimScaleOverride()
- setDimaszOverride()

How a Leader is added can be found in:
https://github.com/qcad/qcad/blob/maste ... /Leader.js

Regards,
CVH

mrhickman53
Junior Member
Posts: 19
Joined: Thu Sep 07, 2023 1:17 am
Location: USA

Re: How to change the size of the RLeaderData or RLeaderEntity arrowhead in a script

Post by mrhickman53 » Tue Apr 30, 2024 6:15 pm

Thanks. You have been consistently responsive to my questions. I appreciate that.

What I found is that, for RLeaderData,
dimaszOverride
double RLeaderData::dimaszOverride
private
Arrow size.

Finding this I decided "asz" must be "arrowhead size".

The method setDimaszOverride() does not appear to be implemented on either RLeaderData or RLeaderEntity.
RLeaderData.dimaszOverride returns 'undefined', probably due to its being private as mentioned above.

The method RLeaderData.getDimasz() works and in my case returns 2.5, even though the drawn arrow is size 20 in the interactive Property Editor.

I tried RLeaderData.setDimasz( 1 ) as a test, even though the method is not documented and it shrank the arrow to a nearly imperceptible size compared to my .140 line. Using setDimasz( 2.5 ) draws a still small arrow that, by the report from getDimasz(), should have been drawn initially. Repeating with setDimasz( 5 ) scales appropriately. The interactive Property Editor reports the Arrow size: 5.

Interestingly, I setDimasz( 20 ) and the arrowhead is not drawn but the interactive Property Editor reports "Arrow size: 20". The line segment the arrow is drawn over is 25mm. It is interesting that the original arrow size 20 is drawn if setDimasz() is never executed. I had noticed that the size 20 arrow is only drawn when the script is run. If the resulting drawing is saved and subsequently reloaded, the arrowhead disappears.

Is there an action I can take to at least document or influence getting setDimasz() documented? I don't know if setDimaszOverride() is supposed to be a separate method or if a name-change of both set and get methods was only performed on the set method.

Regards,
Mark

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

Re: How to change the size of the RLeaderData or RLeaderEntity arrowhead in a script

Post by CVH » Wed May 01, 2024 3:34 am

mrhickman53 wrote:
Tue Apr 30, 2024 6:15 pm
I tried RLeaderData.setDimasz( 1 ) as a test, even though the method is not documented
It seems that: https://qcad.org/doc/qcad/3.0/developer/annotated.html is not up to date ... :shock:
(Not the first time that I encounter this ... Sorry for not having checked that :oops: )


At the bottom of: https://qcad.org/doc/qcad/3.0/developer ... _data.html is stated:
The documentation for this class was generated from the following files:
- src/entity/RDimLinearData.h
- src/entity/RDimLinearData.cpp



And if we look at the current content of that CPP file:
https://github.com/qcad/qcad/blob/maste ... ata.h#L143
It sets the dimasz property and calls for an update. (Not to be confused with drawing entity properties in the Property Editor.)
https://github.com/qcad/qcad/blob/maste ... a.cpp#L152
This calls for an REntityData::update() and updateArrowHead().
https://github.com/qcad/qcad/blob/maste ... a.cpp#L135
And that last will clear the arrowhead when it doesn't fit on the first segment.
https://github.com/qcad/qcad/blob/maste ... ta.cpp#L62
This segment must be longer or equal to dimasz * dimscale * 2.

From this we can deduct that dimasz and dimscale are the entity override values.
And that getDimasz() returns dimasz * dimscale.

Although it is a bit more complicated:
https://github.com/qcad/qcad/blob/maste ... ata.h#L116
https://github.com/qcad/qcad/blob/maste ... ata.h#L148
dimasz and dimscale are not set (-1.0) if the document global Dimension preferences are to be used.
Removing overides: https://github.com/qcad/qcad/blob/maste ... ata.h#L236
Default Leader: https://github.com/qcad/qcad/blob/maste ... ta.cpp#L22


setDimScaleOverride() and setDimaszOverride() are indeed deprecated.
What can be seen in a 2-3 year old commit :!: :?: ... One can lookup the history of a file on GitHub (Top right of the page)
https://github.com/qcad/qcad/commits/ma ... aderData.h ...
https://github.com/qcad/qcad/commits/ma ... erData.cpp ...
... Look for 'style overrides'
>>
https://github.com/qcad/qcad/commit/10a ... 6fb1341191

Filed a Task Request on QCAD Bugtracker: https://qcad.org/bugtracker/index.php?d ... sk_id=2567


While setting a certain arrowhead size you probably need to account for the active scale: document global Dimension scale or the override scale.
setDimasz() sets an override size ... getDimasz() gets a default (2.5), a global or an override size and that times a scale by getDimscale().
The returned scale factor is the override, a default (1.0) or a global scale.
getDimasz() is in fact getDimasz(scale) where scale is true by default.

Hoping this sheds some light in the dark.

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”