Creating RHatchEntity

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

Moderator: andrew

Post Reply
pmbrull
Junior Member
Posts: 14
Joined: Thu Aug 23, 2018 4:07 pm

Creating RHatchEntity

Post by pmbrull » Thu Sep 06, 2018 3:58 pm

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!

User avatar
andrew
Site Admin
Posts: 5604
Joined: Fri Mar 30, 2007 6:07 am

Re: Creating RHatchEntity

Post by andrew » Thu Sep 06, 2018 4:13 pm

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.

pmbrull
Junior Member
Posts: 14
Joined: Thu Aug 23, 2018 4:07 pm

Re: Creating RHatchEntity

Post by pmbrull » Fri Sep 07, 2018 8:30 am

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

User avatar
andrew
Site Admin
Posts: 5604
Joined: Fri Mar 30, 2007 6:07 am

Re: Creating RHatchEntity

Post by andrew » Fri Sep 07, 2018 8:57 am

Code: Select all

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

Post Reply

Return to “QCAD Developers and Contributors”