"Hello - is it this you looking for - I can see it in your eyes - I can see it in your smile ..."
Not direct the closest distance, but more general. It is the project curve factory and it works also for points to curves. Please test and study. The direction mode takes the x-axis of the frame input. For closestpt it is not necessary.
code:
function Project()
{
this.addInput("Objects","objectlist");
this.addInput("Target","objectlist");
this.addInput("Frame","pointarray");
this.addOutput("Out","objectlist");
this.properties = {ProjectMode:["closestpt","closestpt","direction"]};
}
Project.title = "Project";
Project.desc = "Project";
Project.prototype.onExecute = function()
{
var obj = this.getInputData(0, moi.geometryDatabase.createObjectList());
var target = this.getInputData(1, moi.geometryDatabase.createObjectList());
var f = this.getInputData(2, new pointArray(true));
var output = moi.geometryDatabase.createObjectList();
//0 Object
//1 Objects
//2 projectmode
//3 basePt
//4 TargetPt
//5 delete inputs
//6 plane
//7
var frame = f.getFrame();
var pFac= moi.command.createFactory( 'project' );
pFac.setInput( 0, obj );
pFac.setInput( 1, target );
pFac.setDefaultDirection();
pFac.setInput( 2,this.properties.ProjectMode[0] );
pFac.setInput( 3, frame.origin );
pFac.setInput(4,frame.evaluate( 1, 0, 0 ) );
pFac.update();
output = pFac.calculate();
pFac.cancel();
this.setOutputData(0, output);
};
LiteGraph.registerNodeType("Construct2/Project", Project);
A nice day to all
Karsten
|