Can scripts output to a text file?

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
JSRoy
Junior Member
Posts: 11
Joined: Fri Sep 22, 2017 9:28 pm

Can scripts output to a text file?

Post by JSRoy » Fri Feb 22, 2019 10:55 pm

Hi all,

I am developing a script to draw lines. When I run my script, qCad is not drawing what I am expecting.

I would like to review all values I am using in my script when calling addLine(). Is there a way for me to create a text file and output my data into it? I have over 700 points, so having a text file would make it easier to review my data and find out what is wrong.


Regards,

Jean-Sebastien Roy

RR88
Full Member
Posts: 51
Joined: Sun Apr 29, 2018 7:04 am
Location: Leinefelde

Re: Can scripts output to a text file?

Post by RR88 » Fri Feb 22, 2019 11:50 pm

Arch Linux, QCad 3.22.0 Prof.

JSRoy
Junior Member
Posts: 11
Joined: Fri Sep 22, 2017 9:28 pm

Re: Can scripts output to a text file?

Post by JSRoy » Sat Feb 23, 2019 2:57 am

Thank you RR88,

With your help I managed to figure out my problem. The Math.sin() function expect an angle expressed as a radiant. I was giving it an angle in degrees.

Would you know where to find the Math class in the document? I found RMath, but no mentions of Math.


Thank you,

Jean-Sebastien Roy
Last edited by JSRoy on Sat Feb 23, 2019 2:03 pm, edited 1 time in total.

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

Re: Can scripts output to a text file?

Post by andrew » Sat Feb 23, 2019 10:29 am

Note that Math is part of the JavaScript API, not QCAD:
https://www.w3schools.com/js/js_math.asp

RR88
Full Member
Posts: 51
Joined: Sun Apr 29, 2018 7:04 am
Location: Leinefelde

Re: Can scripts output to a text file?

Post by RR88 » Sat Feb 23, 2019 5:20 pm

JSRoy wrote:
Sat Feb 23, 2019 2:57 am
The Math.sin() function expect an angle expressed as a radiant. I was giving it an angle in degrees.

Code: Select all

Math.sin(angle*Math.PI/180)
:P
Arch Linux, QCad 3.22.0 Prof.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”