hi to all
I am new to qcad and need some help
in the ecma script shell
(right hand side)
i can draw a line with
addLine(0,0, 100,100)
but how do I rotate it inside the ecma script shell?
i am running on
QCAD Professional Trial
Version: 3.29.4.0 (3.29.4)
Internet: QCAD.org
Build Date: Feb 7 2024
Revision: 36a6423
Qt Version: 5.14.2
Architecture: x86_64
Compiler: gcc 5.4.0
kind regards
rolf kudelka
rotatae in ecma
Moderator: andrew
Re: rotatae in ecma
Hi, and welcome to the QCAD forum.
addLine(0,0, 100,100)
Is a method of the QCAD Simple API, that draws a line piece and done.
The Simple API is mentioned halfway https://www.ribbonsoft.com/en/tutorial- ... pt-actions
"This is slightly more complex than what we have seen in the simple API above." >> But there is nothing over it 'above' ...
More can be found here:
https://www.qcad.org/doc/qcad/latest/de ... imple.html
You could do:
That will draw a line piece and return a reference to the newly created object what is stored in a variable.
Then the new entity is moved over a certain distance in X and in Y.
The first line is not really required, not always ... But it doesn't hurt.
Both addLine(...) and move(...) have several alternative signatures.
Remind that this are two separate transactions, it requires 2 steps to fully undo for example.
After each transaction the displayed view is regenerated, the document in memory changes ...
... Together with several other time consuming processes.
In the end you will want to group actions (See: startTransaction(), endTransaction()) or use the more elaborated standard API.
Regards,
CVH
addLine(0,0, 100,100)
Is a method of the QCAD Simple API, that draws a line piece and done.
The Simple API is mentioned halfway https://www.ribbonsoft.com/en/tutorial- ... pt-actions
"This is slightly more complex than what we have seen in the simple API above." >> But there is nothing over it 'above' ...
More can be found here:
https://www.qcad.org/doc/qcad/latest/de ... imple.html
You could do:
Code: Select all
include("scripts/simple.js");
var newEntity = addLine(0,0, 100,100);
move(newEntity, 40, 10);
Then the new entity is moved over a certain distance in X and in Y.
The first line is not really required, not always ... But it doesn't hurt.
Both addLine(...) and move(...) have several alternative signatures.
Remind that this are two separate transactions, it requires 2 steps to fully undo for example.
After each transaction the displayed view is regenerated, the document in memory changes ...
... Together with several other time consuming processes.
In the end you will want to group actions (See: startTransaction(), endTransaction()) or use the more elaborated standard API.
Regards,
CVH
Re: rotatae in ecma
I'd recommend to create a line shape in memory only, then transform it as desired and only then add it:
Code: Select all
// create a new line shape in memory, this adds nothing to the drawing yet:
var line = new RLine(0,0, 100,100);
// rotate the line around point 50/50 by 30 degrees counter-clockwise (deg2rad converts degrees to radians):
line.rotate(deg2rad(30.0), new RVector(50,50));
// add the transformed shape to the drawing:
addShape(line);
Re: rotatae in ecma
hi to all on the qcad forum
thank you very much for the quick response
i really do appreciate this
i have got 2 replies in less than 24 hours
which is great and better than most
i am thankfull
oh, this all over my head atm
to CVH
the most detailed response
yeap i wish i was 1/2 as smart as you
all over my head brother
but thanks
to andrew
yeah sort of getting it
will have to play around with it
till it starts to sink in
thanks brother
thank you very much brothers and sisters
kind regards
rolfk
thank you very much for the quick response
i really do appreciate this
i have got 2 replies in less than 24 hours
which is great and better than most
i am thankfull
oh, this all over my head atm
to CVH
the most detailed response
yeap i wish i was 1/2 as smart as you
all over my head brother
but thanks
to andrew
yeah sort of getting it
will have to play around with it
till it starts to sink in
thanks brother
thank you very much brothers and sisters
kind regards
rolfk