draw ellipse using script
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
draw ellipse using script
can someone help me draw a ellipse with a java script?
Re: draw ellipse using script
One method is to duplicate the functionality of the EllipseCPP.js or EllipseArcCPPA.js scripts.
Analog to this story:
https://qcad.org/rsforum/viewtopic.php?&t=6801
EllipseCPP.js ends up calling the EllipseArcCPPA.js script.
The major part of the script is data collection.
That data you have at hand.
Seems we need a REllipse
EllipseArcCPPA.prototype.getEllipse Line 487.
Adapted:
The operation ('op' in this case) is prepared in:
EllipseArcCPPA.prototype.getOperation Line 258-287.
Adapted:
As last this operation has to be casted:
Where 'di' is your document interface; 'op' the generated operation.
It occured to me in the recent past that this.getDocument() failed. Ifso replace it with your document.
The other method would be to preset all the data and parse it to the Ellipse script.
Analog to this story:
https://qcad.org/rsforum/viewtopic.php?&t=6649
But rather undocumented it can be harder to figure out how.
See:
https://qcad.org/rsforum/viewtopic.php?f=32&t=7106
Regards,
CVH
Analog to this story:
https://qcad.org/rsforum/viewtopic.php?&t=6801
EllipseCPP.js ends up calling the EllipseArcCPPA.js script.
The major part of the script is data collection.
That data you have at hand.
Seems we need a REllipse
EllipseArcCPPA.prototype.getEllipse Line 487.
Adapted:
Code: Select all
var newEllipse = new REllipse(center, majorPoint, ratio, param1, param2, reversed)
EllipseArcCPPA.prototype.getOperation Line 258-287.
Adapted:
Code: Select all
var shape = Ellipse.postProcess(newEllipse);
var entity = shapeToEntity(this.getDocument(), shape);
var op = new RAddObjectOperation(entity, yourToolTitle);
Code: Select all
di.applyOperation(op);
It occured to me in the recent past that this.getDocument() failed. Ifso replace it with your document.
The other method would be to preset all the data and parse it to the Ellipse script.
Analog to this story:
https://qcad.org/rsforum/viewtopic.php?&t=6649
But rather undocumented it can be harder to figure out how.
See:
https://qcad.org/rsforum/viewtopic.php?f=32&t=7106
Regards,
CVH