Hello James,
would you please check this code:
code:
// RemoveDup
function RemoveDup()
{
this.addInput("In", "objectlist");
this.addInput("Tolerance", "numarray");
this.addOutput("Out", "objectlist");
this.properties = {Tolerance: [0.005]};
}
RemoveDup.title = "RemoveDupCrv";
RemoveDup.desc = "RemoveDupCrv";
RemoveDup.prototype.onExecute = function ()
{
var inObj = this.getInputData(0, moi.geometryDatabase.createObjectList());
this.properties.Tolerance = this.getInputData(1, this.properties.Tolerance);
var output = moi.geometryDatabase.createObjectList();
var temp = moi.geometryDatabase.createObjectList();
if (inObj.length > 0) {
var tempname = getUID(6);
for (var i = 0; i < inObj.length; i++)
inObj.item(i).name = tempname;
moi.geometryDatabase.addObjects(inObj);
var fac = moi.command.createFactory('removeduplicates');
fac.setInput(0, inObj);
fac.setInput(1, this.properties.Tolerance[0]);
inObj = moi.geometryDatabase.createObjectList();
fac.commit();
moi.geometryDatabase.selectNamed(tempname);
temp = moi.geometryDatabase.getSelectedObjects();
var originXYZ = moi.VectorMath.createPoint(0, 0, 0); //Helppoint for a identical copy
output = factory('copy', temp, originXYZ, originXYZ, true);
var delfac = moi.command.createFactory('delete');
delfac.setInput(0, temp);
delfac.commit();
}
this.setOutputData(0, output);
};
LiteGraph.registerNodeType("Objects2/RemoveDupCrv", RemoveDup);
Have a nice day
Karsten
|