How to create Hatch with script

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

mpele
Newbie Member
Posts: 7
Joined: Mon Jan 02, 2017 9:57 am

How to create Hatch with script

Postby mpele » Tue Feb 21, 2017 11:59 am

I am trying to modify HatchFromSelection.js to create simple hatch for "virtual triangle" but there is no result.
Could anyone help me with this code?

Code: Select all

HatchFromSelection.prototype.beginEvent = function() {
    EAction.prototype.beginEvent.call(this);

    var doc = this.getDocument();
    var di = this.getDocumentInterface();

    var hatchData = new RHatchData();
    hatchData.setDocument(doc);
   
   hatchData.setLineweight(RLineweight.Weight015);

   hatchData.newLoop();
   hatchData.addBoundary(new RLine(new RVector(0,0), new RVector(100,0)));
   hatchData.addBoundary(new RLine(new RVector(100,0), new RVector(200,0)));
   hatchData.addBoundary(new RLine(new RVector(200,0), new RVector(0,0)));
   
   EAction.handleUserWarning(qsTr("hatchData.getExploded: "+hatchData.getExploded()), true);

    hatchData.setSolid(true);
    hatchData.setScale(1);
    hatchData.setAngle(10);
    hatchData.setPatternName("Test");

    var hatch = new RHatchEntity(doc, hatchData);
    var op = new RAddObjectOperation(hatch, false, false);
   
    di.applyOperation(op);

    di.autoZoom();
EAction.handleUserWarning(qsTr("beginEvent finished"), true);
    this.terminate();
   
};

mpele
Newbie Member
Posts: 7
Joined: Mon Jan 02, 2017 9:57 am

Re: How to create Hatch with script

Postby mpele » Wed Feb 22, 2017 8:35 am

I have found problem - there is no problem. The coordinates of triangle are on one line so, there are no visible hatch :oops:


Return to “QCAD Developers and Contributors”

Who is online

Users browsing this forum: No registered users and 1 guest