Debugger only Displayed on Errors?

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
wildspidee
Full Member
Posts: 84
Joined: Sat Nov 03, 2012 2:00 am

Debugger only Displayed on Errors?

Post by wildspidee » Wed Jan 21, 2015 5:30 am

Things are coming along very nicely in my script. The drawing is exactly what it should be. I've attached the .js page for reference. Here is the excerpt where I'm having issues:

Code: Select all

    var slopeInt = cB_6.getIntersectionPoints(l4);
    qDebug(slopeInt);
    // ERROR - var m6 = new RVector(cB_6.getIntersectionPoints(l4));
I tried to throw the intersection point into a new RVector because I thought that was what was returned. That didn't work so I put in the qDebug() (as you mentioned in a previous forum post) to see what exactly comes back. Unfortunately, I don't get anything with this qDebug(slopeInt). The debugger doesn't even open.

If I create an error, the debugger will open up and show the problem, but it won't otherwise. Have I invoked it properly?

Thank you,

Lori
Attachments
FMBodice.js
(3.1 KiB) Downloaded 468 times

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

Re: Debugger only Displayed on Errors?

Post by andrew » Wed Jan 21, 2015 10:54 am

qDebug prints the argument to stderr (i.e. the Terminal you used to start QCAD). For example:

Code: Select all

/Applications/QCAD-Pro.app/Contents/MacOS/QCAD-Pro -enable-script-debugger
Debug:    RDwgPlugin::init 
Debug:    RDxfPlugin::init 
Debug:    RHelpPlugin::init 
Debug:    RProScriptsPlugin::init
...[all output printed with qDebug is shown here]...
To launch the debugger at any point, use the debugger command instead:
var i = 0;
debugger;
if (...) {...}
Note that getIntersectionPoints(...) returns an array of intersection points, even if there is only one:
var res = line1.getIntersectionPoints(line2);
if (res.length>0) {
    var intersectionPoint = res[0];
    ...
}

wildspidee
Full Member
Posts: 84
Joined: Sat Nov 03, 2012 2:00 am

Re: Debugger only Displayed on Errors?

Post by wildspidee » Wed Jan 21, 2015 5:19 pm

I'm an idiot. Starting QCAD with an AppleScript doesn't allow the qDebug() return. You can start the app in Terminal on a Mac with parameters, I just wasn't doing it correctly. I erased my instructions on the prior post. I'm getting the qDebug() feedback now.

Using your code, I was able to accomplish the final line. Here it is, if anyone else needs a reference. Please note that cB_6 is a Circle Shape and l4 is a Line Shape. Works beautifully.

Code: Select all

var slopeInt = cB_6.getIntersectionPoints(l4);
    if(slopeInt.length > 0){
        var m6 = slopeInt[0];
    }
    var l6 = new RLine(m6,markB);
Thanks Andrew.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”