QCAD.org Forum

Discussion forum for contributors and developers who are using the QCAD version 3 ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Thanks that was easy and it worked well.my next question (sorry about all the questions) is how to add new layers and set the current layer so that when I use the apply function, the new entities are added to the current layer.

I tried declaring a new layer object as in OpenFile but it doesn't seem to work.

Could you advise me on how to convert a a series of lines and curves (that form a closed shape) that i've programmed using the Rdocumentinterface into a single polyline. So for example if I have all my line and curve entities in a single operation object can i convert then to a polyline before using the: operation.apply(document);

And then I'd like to be able to create a offset polyline like you can with the polyline equidistant command in the GUI.

ash120 wrote:Could you advise me on how to convert a a series of lines and curves (that form a closed shape) that i've programmed using the Rdocumentinterface into a single polyline. So for example if I have all my line and curve entities in a single operation object can i convert then to a polyline before using the: operation.apply(document);

The API does not work like that. If you add a line to an operation, the operation will add a line to the document. If you want to have a polyline, you need to add a polyline to the operation. Entities in an operation cannot be modified before the operation has been applied.

Possible solutions for your use case are:

- Update file PolylineFromSegments.js (see attachment).- Add loose line and arc entities to the drawing in one operation.- Convert those lines and arcs into a polyline in a separate operation using "PolylineFromSegments.createPolyline":

I want to use the polylinefromsegments function, but I need help in how to find particular entity that I have added to a Document through an operation. If for example I've added several RlineEntity objects to single operation and then applied that operation to a document, How do I then search the document to extract particular Entities that i can pass as an argument to the above function?

I assume its not working because i need to pass the Entity object itself not its Id to the polylinefromsegments script when i try to pass the line Entity in the above code directly, I get a different error.thanks for your continued help.

Note that although ECMAScript does not force you, it is strongly recommended to keep the first letter of all variable names small to keep them separate from class names (e.g. 'Polyline' is a class used in the QCAD 3 API. If you use a variable named 'Polyline' (e.g. 'var Polyline = new RPolyline(..)'), you actually overwrite that class which will break the QCAD 3 API. Good variable names are 'polyline', 'entity', 'upperLine', etc. Bad are 'Entity', 'Polyline', 'UpperLine', etc.