Hi Max,
>> added Style property in the Output node
Thank you very much for this new feature!
It's exactly what i wanted.
P.S.
I noticed that the "Circle" node only generates one single circle whatever the input "pointarray" is.
So i wrote a little modified version called "Circles" that generates as many as the points contained in the array.
Furthermore, it is possible to limit the total number of generated circle, to a specified amount.
This amount can be >=1 AND <= the number of points contained in the array.
And is also possible to specify a step amount for the for-loop.
Here's the code :
code:
// Circles
function Circles()
{
this.addInput("Center","pointarray");
this.addInput("Radius","number");
this.addInput("Elements","number");
this.addInput("Step","number");
this.addOutput("Out","objectlist");
this.properties = { radius:1, elements:1, step:1 };
}
Circles.title = "Circles";
Circles.desc = "Circles";
Circles.prototype.onExecute = function()
{
var output = moi.geometryDatabase.createObjectList();
var centers = this.getInputData(0, new pointArray());
var len = centers.getLength();
this.properties.radius = this.getInputData(1, this.properties.radius);
this.properties.elements = this.getInputData(2, this.properties.elements);
if (this.properties.elements <= 0) this.properties.elements = 1;
this.properties.step = this.getInputData(3, this.properties.step);
if (this.properties.step <= 0) this.properties.step = 1;
if (this.properties.step > len) this.properties.step = len;
for (i = 0; i < len && i < this.properties.elements; i += this.properties.step) {
var cir = factory( 'circle', true, centers.getFrame(i), null, this.properties.radius );
output.addObject(cir.item(0));
}
this.setOutputData(0, output);
}
LiteGraph.registerNodeType("Curves/Circles", Circles);
I've also done the "GetBBoxes" node that follow the same logic.
Here's the code :
code:
function GetBBoxes()
{
this.addInput("In","objectlist");
this.addInput("Elements","number");
this.addInput("Step","number");
this.addOutput("Out","objectlist");
this.addOutput("BBox Center","pointarray");
this.properties = { elements:0, step:1 };
}
GetBBoxes.title = "BoundingBoxes";
GetBBoxes.desc = "Get BoundingBoxes";
GetBBoxes.prototype.onExecute = function()
{
var input = this.getInputData(0, moi.geometryDatabase.createObjectList());
var len = input.length;
var bbox = new pointArray();
this.properties.elements = this.getInputData(1, this.properties.elements);
if ((this.properties.elements <= 0) || (this.properties.elements > len)) this.properties.elements = len;
this.properties.step = this.getInputData(2, this.properties.step);
if (this.properties.step <= 0) this.properties.step = 1;
if (this.properties.step > len) this.properties.step = len;
this.setOutputData(0, input);
for (i = 0; i < len && i < this.properties.elements; i += this.properties.step) {
bbox.pushPoint(input.item(i).getBoundingBox().center);
}
this.setOutputData(1, bbox);
}
LiteGraph.registerNodeType("Objects/GetBBoxes", GetBBoxes);
Have a nice day.
Marco.