Page 1 of 1

Creating RHatchEntity

Posted: Thu Sep 06, 2018 3:58 pm
by pmbrull
Hello and thank you for your time,

I was looking around for a way of creating different objects into a drawing. As an example, I created a RPolyline with the following steps:

QList -> RPolyline -> RPolylineData -> RPolylineEntity
and adding the object to the document.

Code: Select all

var pList =  [new RVector(500, -525, 0, true), 
                  new RVector(-500, -525, 0, true), 
                  new RVector(-500, 525, 0, true), 
                  new RVector(500, 525, 0, true), 
                  new RVector(500, -525, 0, true)];

var poly = new RPolyline(pList, true);
var polyData = new RPolylineData(poly);
var polyEntity = new RPolylineEntity(document, polyData);
Then, I tried to apply the same schema to instantiate a RHatchEntity, using the variable *poly* as boundary:

Code: Select all

var hatchData = new RHatchData;
hatchData.setSolid(true);
hatchData.addBoundary(poly);
var hatch = new RHatchEntity(document, hatchData);
op.addObject(hatch);
getDocumentInterface().applyOperation(op);
But i do not see the created object. Can anyone point out what am I missing here?
Thank you!

Re: Creating RHatchEntity

Posted: Thu Sep 06, 2018 4:13 pm
by andrew
Have a look at HatchDialog which creates a simple hatch for preview:
https://github.com/qcad/qcad/blob/maste ... hDialog.js

Lines 199 and after.

Re: Creating RHatchEntity

Posted: Fri Sep 07, 2018 8:30 am
by pmbrull
Thank you for your reply.

What we are trying to do, however, is creating a filled hatch from any kind of closed polygon. Is that possible? Or Hatch are limited to regular polygons?

Thanks,
Pere

Re: Creating RHatchEntity

Posted: Fri Sep 07, 2018 8:57 am
by andrew

Code: Select all

data.addBoundary(anyKindOfPolygon);
Where anyKindOfPolygon is any irregular, closed RPolyline object.