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":
- Code: Select all
var op = new RMixedOperation();
var polylineEntity = PolylineFromSegments.createPolyline(op, entity, document, new RVector(1.0e-3, 1.0e-3));
polylineEntity = op.addObject(polylineEntity, false);
documentInterface.applyOperation(op);
- Note that entity has to be a valid entity with an ID that is part of the document (check entity.getId()).
Or:
- create a polyline entity directly instead of loose line and arc entities.
BTW: I assume that by 'curve' you mean arcs and not splines. Polylines can only contain line and arc segments, not spline segments.