BrianZ111 wrote: ↑Fri Jun 09, 2023 1:18 am
Is it possible to write a script to do the following:
Yes, for sure, but there are some conditions to meet.
The entities on the layer in question should form one or more perfectly closed contours.
Entities in the drawing are of the type
REntity() or more specific
RLineEntity,
RArcEntity, ...
Not all types of entities can readibly be part of a polyline, e.g. ellipses, blocks, text, ...
You need to merge them at shape level to an
RPolyline.
Matching endpoints, reversing if required and chaining them until you have a closed contour.
In the GUI we do that with Polyline from Selection (OC) what is part of QCAD Pro.
https://www.qcad.org/rsforum/viewtopic. ... 567#p36567
Make sure you have read Andrew's last entry there.
This will turn everthing in selection to one or more polyline entities if possible and closed if so.
That starts with selecting everything on a given layer.
Calling
PolylineFromSelection.js (= QCAD Pro)
Filtering the resulting selection on closed
RPolylineEntity
These closed polylines can then be hatched with again a Pro feature.
Or directly by creating one or more
RHatchEntity as in the given example.
Remark that a hatch has loops and boundary shapes.
boundary shapes can be one closed polyline or a list of proper chained and oriented shapes.
One could already set the specific layer of the newly formed
RHatchEntity before adding it.
Changing the layer of an entity is not a big deal.
After querying it from the drawing simply change the layer and put it back.
Best done with an
RModifyObjectOperation.
Regards,
CVH