Page 1 of 1

How do I select all entities inside a box from script

Posted: Wed Oct 23, 2019 1:27 pm
by machinekoder
I want to select all entities inside a box using the cross selection option.

I tried:

Code: Select all

include("scripts/Select/SelectRectangle/SelectRectangle.js");

   var d = new RDocument(new RMemoryStorage(), new RSpatialIndexNavel());
    var di = new RDocumentInterface(d);
    if (di.importFile(inFile) != RDocumentInterface.IoErrorNoError) {
        di.destroy();
        print("Cannot import file:", inFile);
        return 1;
    }
    
    var ev = new SelectRectangle();
    ev.setDocumentInterface(di);
    ev.crossSelection = true;
    ev.point1 = new RVector(0, 0);
    ev.point2 = new RVector(3000, 200);
    ev.selectEntities();
Which works great in the script console. But once I run it via the CLI I get:
"TypeError: Result of expression 'doc' [undefined] is not an object."
at the selectEntities() line.

What is the correct way to achieve the selection with cross selection enabled?