Scripting the OrientLineToLine factory:
======================================
The interactive command Orient Line/Line, under the Transform menu,
is a powerful command which can do copying, scaling, and aligning.
The "complex" interactive script is in the OrientLineToLine.js and .htm files.
The underlying factory can also be used non-interactively, in other scripts,
by setting up the 6 indexes, as described below.
var orientV; // Will hold the orientF.calculate objectList results.
var orientF = moi.command.createFactory( 'orientlinetoline' );
orientF.setInput( 0, objects ); //objectList.
orientF.setInput( 6, 'scale, uniform' ); // choice 1 of 3.
orientF.setInput( 1, basept0 ); // basepoint0
orientF.setInput( 2, basept1 ); // basepoint1
orientF.setInput( 3, targetpt0 ); // targetpoint0
orientF.setInput( 4, targetpt1 ); // targetpoint1
Index 0, objects:
objects is an objectList of various geometric objects.
someOtherFactory.calculate(); can be used to create such an objectList.
Index 1, basepoint0:
basepoint0 can be created by using: moi.vectorMath( x0, y0, z0 );
Index 2, basepoint1:
basepoint1 can be created by using: moi.vectorMath( x1, y1, z1 );
The two basepoints can be held in an array.
The two basepoints are associated with the objects to be copied.
Index 3, targetpoint0:
targetpoint0 can be created by using moi.vectormath( x2, y2, z2 );
Index 4, targetpoint1:
targetpoint1 can be created by using moi.vectormath( x3, y3, z3 );
The two targentpoints can be held in an array.
The two targetpoints indicate where the objects will be copied, scaled and aligned.
Index 6, Type of Scaling:
There are 3 choices for type of scaling:
'scale, uniform'
'scale, stretch'
'scale, none'
Index 5, Make Multiple Copies using the same factory:
orientF.setInput( 5, true );
Using index 5 takes several lines of code, as shown in OrientLineToLine.js.
Multiple copies would require a for loop, with a range of pairs of targetpoints.
The OrientLineToLine factory will be used in a forthcomming Gosper script.
A node editor version might be useful.
- Brian
|