Scripting API

 From:  Joe (CTKJOSE)
10944.1 
Im on MacOS with MoI V4, just got MoI for Xmas and wanted to play a little with scripting.

I want to select a point in a curve and be able to move it precisely by an offset (x, y, z) provided by the user.

I'm a bit stock, I have searched and looked at most of the scripts in "commands" folder in the app bundle, multiple samples in the forums, among others like http://kyticka.webzdarma.cz/3d/moi, http://moi3d.com/forum/lmessages.php?webtag=MOI&msg=7238.5, http://moi3d.com/wiki/MaxScriptArchive

So far I can select objects using the point picker, then get the associated objects (forcing selection to be on curves and snapping on end points). From there I get all the points of the curve then find the point that was selected with the pointpicker.

To move the point I tried `point.set(x,y,z)` but that doesn't work. I have grep the app files and the scripts I have collected from the forum and the internet for all sort of related things, looked at scripts and the only related thing is is "move"/"offset" but none that actually edits a point.

Any pointers and help will be greatly appreciated...

PS I also wonder what js engine is used in MoI, is it V8, duktape, mugs, etc?

var targets = [];
//var objects = sketch.objects;
for( i in points ){
var pt = points[i];
var o = sketch.pointPickedObject(pt);
if(!o) continue;
if(o.type !== 2 && o.type !== 1) continue; //is curve or segment?

//plugin.showAlert("OBJ.TYPE=" + o.type);


var opoints = sketch.getCurvePoints(o);
for(var k in opoints){
var pt1 = opoints[k];
//plugin.showAlert("OBJPOINT[" + k + "]=" + pt1.toString(3));

if(pt1.x == pt.x && pt1.y == pt.y && pt1.z == pt.z){
targets.push({obj: o, pt: pt1});
continue;
}
}
}

for(i in targets){
var e = targets[i];
var pt = e.pt;

var x = pt.x, y = pt.y, z = pt.z;
if( dx != 0.0 ) x += dx;
if( dy != 0.0 ) y += dy;
if( dz != 0.0 ) z += dz;
pt.set(x, y, z);
}