Using GlobalWidth

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
jcn
Newbie Member
Posts: 7
Joined: Thu Apr 08, 2021 8:14 pm

Using GlobalWidth

Post by jcn » Thu Jun 03, 2021 4:01 am

I'm trying to use the GlobalWidth property for Polylines in a script.

I found the setGlobalWidth(double w) function and was hoping/expecting to also find getGlobalWidth(), but it seems that function does not exist.

So, I looked into using getProperty() instead. Below is some diagnostic code where chkEnt is a PolylineEntity:

Code: Select all

var chkProp = chkEnt.getProperty(REntity.PropertyLayer);
EAction.handleUserMessage("getProperty = " + chkProp);

var chkProp = chkEnt.getProperty(REntity.PropertyLinetype);
EAction.handleUserMessage("getProperty = " + chkProp);

var chkProp = chkEnt.getProperty(REntity.PropertyDrawOrder);
EAction.handleUserMessage("getProperty = " + chkProp);

// var chkProp = chkEnt.getProperty(REntity.PropertyGlobalWidth);
// EAction.handleUserMessage("getProperty = " + chkProp);
For the PropertyLayer, PropertyLinetype, and PropertyDrawOrder, the corresponding settings are returned without any errors.

However, if the // are removed from the last two lines, the debugger reports:

Wrong number/types of arguments for RPolylineEntity.getProperty(). <native>(undefined) at -1

Is there something special about PropertyGlobalWidth that I am missing? Or, if there is a better way to read the GlobalWidth value, I will appreciate the advice.

Thanks.
jcn

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

Re: Using GlobalWidth

Post by CVH » Thu Jun 03, 2021 5:32 am

Hi,
I think you got away with .getProperty(REntity ...) for the first 3 props as those are common.
For the global width of a polyline .getProperty(RPolylineEntity.PropertyGlobalWidth) returns a Qlist

The first entry of that:
= 0 : Lineweight is used
> 0 : Globalwidth is used
= "" : Mixed widths

Regards,
CVH

jcn
Newbie Member
Posts: 7
Joined: Thu Apr 08, 2021 8:14 pm

Re: Using GlobalWidth

Post by jcn » Thu Jun 03, 2021 8:25 pm

At first, I didn't notice the "RPolylineEntity" in your reply:

.getProperty(RPolylineEntity.PropertyGlobalWidth)

After some checking, I see that is the key which is actually simple in hindsight. The other three lines worked because I happened to pick properties found in all REntity elements. The uniqueness of the PropertyGlobalWidth is that it is only found for RPolylineEntity entities, which is basically just rewording your reply.

What had confused me was that all four properties are in the Static Public Attributes list at:

https://www.qcad.org/doc/qcad/latest/de ... ntity.html

so I was expecting that if 3 worked, the 4th should also work. My mistake was not realizing that they all work with RPolylineEntity, but not with REntity.

Thanks for the help.
jcn

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”