Modify text's X scale property

This forum is for 'Work-in-Progress' QCAD user developed script Add Ons and Plug-ins.

Please use this forum to request/submit your script Add-Ons & Plug-in idea's.

Moderators: andrew, Husky, J-J

Post Reply
wdfortee
Junior Member
Posts: 10
Joined: Fri Mar 23, 2018 3:18 pm

Modify text's X scale property

Post by wdfortee » Sun Aug 09, 2020 9:12 pm

I'm using QCAD Pro 3.21.3 on Windows 10 x64.

I'm trying to modify a text entities X scale but it seems I have no idea what I'm doing wrong.

I've created a text entity using:

Code: Select all

text = new RTextEntity(document, new RTextData( [text values here]);
Looking at the reference material, doesn't look like there's a way to modify X scale in RTextData, so I was trying different variants of

Code: Select all

text.setProperty("PropertyXScale", "1.0");
and:

Code: Select all

text.setProperty(new RPropertyTypeId("PropertyXScale"), "1.0");
Using script debugging, the first results is

Code: Select all

Error: :-1:-1: Wrong number/types of arguments for RTextBasedEntity.setProperty(). <native>('PropertyXScale', 0.5) at -1
and the second doesn't crash, but doesn't modify X scale.

Any help is appreciated.

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

Re: Modify text's X scale property

Post by CVH » Mon Aug 10, 2020 1:16 am

Hi,
If there is a 'Properties' way I don't know.
And indeed, no examples of the use off XScale.

I would look for Set & Get functions in the Class list:
https://qcad.org/doc/qcad/3.0/developer/annotated.html

Those looks to be implemented by RTextBasedData.
RTextData inherited those.
And I come to:

Code: Select all

    var document = this.getDocument();
    var di = this.getDocumentInterface();
    var op = new RAddObjectsOperation(false);
    var textPos = new RVector(23,16);
    var textData = new RTextData(
                textPos,            // position
                textPos,            // alignment point
                0.35,               // height
                1.0,                // text width (ignored for now)
                RS.VAlignTop,       // alignments
                RS.HAlignLeft,
                RS.LeftToRight,
                RS.Exact,
                1.0,                // line spacing factor
                "MyText",           // the text
                "Courier",          // font
                false,              // bold
                false,              // italic
                0.0,                // angle
                false               // simple text without formatting
		);

    // Set XScale:
    textData.setXScale(0.88);

    var text = new RTextEntity(document, textData);
    op.addObject(text);
    di.applyOperation(op);
:P
Regards,
CVH

wdfortee
Junior Member
Posts: 10
Joined: Fri Mar 23, 2018 3:18 pm

Re: Modify text's X scale property

Post by wdfortee » Mon Aug 10, 2020 1:32 am

Worked perfectly, thanks so much. I guess I need to spend more time looking at reference.

In the past, I've only coded python scripts and simple programs from various languages. The API for QCAD is a little overwhelming for me and not exactly sure how to always track down the getters and setters.

Thanks again. This probably won't be the last post.

Post Reply

Return to “QCAD 'Script Add-On & Plug-in challenge' - Work in Progress”