// speedyPolygon.ls by Felipe Esquivel // // This simple script creates a 4 point polygon based in the position of 3 selected // points, the 4 points are co-planar (all lie about the same plane). // // Use: Select 3 points and run the script. The first point is the tail // of the vectors, the 4th vector is the result of the sum of both vectors // (trust me, it works). @version 2.4 @warnings @script modeler main { loc1 = <0,0,0>; loc2 = <0,0,0>; loc3 = <0,0,0>; loc4 = <0,0,0>; selmode(USER); editbegin(); // check if 3 and only 3 points are selected numPts = pointcount(); if(numPts != 3) { error("You must have 3 points selected to perform this operation"); return; } if(numPts == 3) { loc1 = pointinfo(points[1]); loc2 = pointinfo(points[2]); loc3 = pointinfo(points[3]); // calculate the fourth point with vectors loc4 = loc2 - loc1 + loc3; // create the 4th point lastPoint = addpoint(loc4); // store the point IDs pointIDS[1] = points[1]; pointIDS[2] = points[2]; pointIDS[3] = lastPoint; pointIDS[4] = points[3]; // create the polygon addpolygon(pointIDS); } editend(); }