Page 1 of 1
how to use ecmascript drawing tools within a script??
Posted: Fri May 24, 2019 10:23 am
by simon-2
Hi,
i'm stuck trying to construct a "CircleTPR" in my script. Isn't it possible to use this class of drawing tools from scripts?
would like to use it like
Code: Select all
var Walze= new CircleTPR(this.curve, points[i],85.0);
,
but that does not seem to work.
what did i do wrong?
regards,
Simon
Re: how to use ecmascript drawing tools within a script??
Posted: Fri May 24, 2019 10:05 pm
by andrew
CircleTPR is an interactive tool that requires the user to enter a radius, click a shape (for the tangential requirement), click a point and then choose one of the two possible solutions. You cannot use such an interactive tool in a script that presumably runs fully automatically without any user interaction.
You can find the ArcTPR script with the relevant calculations to find the two candidate arcs / circles at:
https://github.com/qcad/qcad/blob/maste ... /ArcTPR.js
You'd still need a logic to choose one of the two possible solutions.
Re: how to use ecmascript drawing tools within a script??
Posted: Wed May 29, 2019 7:38 am
by simon-2
hi Andrew,
thanks for your explanation; choosing one of the possible solutions is what i did not have in mind, but totally intelligible.
i tried to construct it in a different way now, using getAngleAt(), but still don't get it working.
Code: Select all
tangAng= this.curve.getAngleAt(i*spacing, from=0);
EAction.handleUserWarning("Tangent Angle: "+tangAng.toFixed(2)); //for debugging only
but i get
.
The curve is a polyline and does exist, as the following line works fine:
Code: Select all
points[i]=this.curve.getPointWithDistanceToStart(i*spacing);
, but the tangent line does not.
could you please point me to my error, once again?
Re: how to use ecmascript drawing tools within a script??
Posted: Thu May 30, 2019 10:19 am
by andrew
For polylines, you have to use the RS.AlongPolyline flag:
Code: Select all
this.curve.getAngleAt(distance, RS.AlongPolyline|RS.FromStart);
Re: how to use ecmascript drawing tools within a script??
Posted: Wed Jun 05, 2019 1:02 pm
by simon-2
thanks alot, that's the missing piece.
I'm not too familiar with JS yet, so some things are not obvious to me. Next question is already evolving..