I need to draw a line with a relative angle of 90 degrees to an existing line. I output the angle of the existing line with getAngle(), which returns 3.372995491. When I view the line properties in the drawing the Angle is 193.258406.
I referred to the LineRelativeAngle.js for help and saw the getRelativeAngle(). Assuming my problem was a coordinate issue, I copied over parts of the .getLine function and included the Line.js at the top of my page. That was a complete failure.
I'm not sure where the 3.372995491 angle is coming from, so I don't know how to work with it. Can you clarify, please?
Thank you,
Lori
Line with Relative Angle in Code
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
-
- Full Member
- Posts: 84
- Joined: Sat Nov 03, 2012 2:00 am
-
- Full Member
- Posts: 84
- Joined: Sat Nov 03, 2012 2:00 am
Re: Line with Relative Angle in Code
Here's a couple more instances of my angle problems. I've taken images of the property editor after the entities are draw and here's the corresponding code snippets (there is a line and a text entity).
Code: Select all
var grainText = new RTextData(
lgrain.getMiddlePoint(), // position
lgrain.getMiddlePoint(), // alignment point
2.0, // height
2.0, // text width (ignored for now)
RS.VAlignBottom, // alignments
RS.HAlignLeft,
RS.LeftToRight,
RS.Exact,
1.0, // line spacing factor
"Grainline", // the text
"Arial", // font
false, // bold
false, // italic
90.0, // angle
false // simple text without formatting
);
Code: Select all
var grainX = markB.getX() - (lB_G.getLength() / 2);
var grainY = markB.getY() + (lA_B.getLength() / 6);
var grainLen = (lA_B.getLength()*0.67);
var mGrain = new RVector(grainX,grainY);
var lgrain = new RLine(mGrain,90.0,grainLen);
- Attachments
-
- Text.jpg (149.76 KiB) Viewed 6482 times
-
- LineUnderText.jpg (130.96 KiB) Viewed 6482 times
Re: Line with Relative Angle in Code
All angles used internally by QCAD are represented in radian, not degrees. Note that also the standard ECMAScript angle functions work in radian (Math.sin, Math.cos, etc).wildspidee wrote:I need to draw a line with a relative angle of 90 degrees to an existing line. I output the angle of the existing line with getAngle(), which returns 3.372995491. When I view the line properties in the drawing the Angle is 193.258406.
The angles displayed to or input by the user are converted to / from degrees.
-
- Full Member
- Posts: 84
- Joined: Sat Nov 03, 2012 2:00 am
Re: Line with Relative Angle in Code
With that, it was easy to fix my problems. One entire pattern is now being generated accurately from script. I've hard coded my variables at the top, so the next step is the QT XML work.
Thank you Andrew.
Thank you Andrew.