Hello James,
very untested - only some standard test:
code:
function network()
{
this.addInput("In", "objectlist");
this.addOutput("Out", "objectlist");
this.properties = { mode: ["normal", "normal","lighter", "exact","custom","uniform"], tolerance: [0.01], numPts: [10]};
}
network.title = "network";
network.desc = "network";
network.prototype.onExecute = function ()
{
var inObj = this.getInputData(0, moi.geometryDatabase.createObjectList());
var output = moi.geometryDatabase.createObjectList();
var temp = moi.geometryDatabase.createObjectList();
if (inObj.length > 3) {
var tempname=getUID(6);
for(var i=0;i<inObj.length;i++){temp.addObject(inObj.item(i));temp.item(i).name=tempname;};
moi.geometryDatabase.addObjects(temp);
var nFac = moi.command.createFactory( 'network');
nFac.setInput(0, temp);
if ( ! nFac.canDoCoonsPatch && this.properties.mode[0]=== "exact" ){moi.ui.alert("Network option exact not possible! switch back to normal ");this.properties.mode[0]="normal";};
nFac.disableUpdate( true );
nFac.setInput(4, this.properties.mode[0]);
// nFac.setInput(4, 'normal');
nFac.setInput(5, this.properties.tolerance[0]);
nFac.setInput(6, this.properties.numPts[0]);
// nFac.update();
output = nFac.calculate();
// nFac.commit();
nFac.cancel();
moi.geometryDatabase.selectNamed(tempname);
temp=moi.geometryDatabase.getSelectedObjects();
var delfac = moi.command.createFactory( 'delete' );
delfac.setInput( 0, temp );
delfac.commit();
}
this.setOutputData(0, output);
};
LiteGraph.registerNodeType("Construct2/Network", network);
Please make some experiments and report me about.
A nice day to all
Karsten
|