Hi Max, re: offset
One problem there is that offset is one of the factories that does an "asynchronous" calculation - that's where it the work actually happens over on a separate moi_commandprocessor.exe process which is used for potentially long running calculations so the main UI does not just freeze while the long calculation is happening.
For async factories it is required that the objects that it use should be in the geometry database and not just a "loose object" which is what .calculate() returns back.
I'll try in v4 to remove this restriction, but for now if you put in moi.geometryDatabase.addObjects( output ); before doing the offset that will be one step that will be needed.
Then in addition to that there is another input that is required on the offset factory in order for it to work, which is the coordinate frame input. The various inputs on the offset factory are like this:
Offset inputs:
0 : object list - objects to offset
1 : number - distance to offset for distance mode, leave unset for "through point" mode.
2 : coordinate frame - point and coordinate frame for "through point" or "which-side" point for distance mode with curve offset
3 : string - corner type for curve offset either "sharp" or "round".
4 : boolean - Trim, true = trim curve results
5 : boolean - Flip, true = flip offset side (for solid/surface offsets not curve offsets)
6 : boolean - Both sides, true = offset curves to both sides
7 : boolean - Cap ends, true = add line segments between ends of open offsets.
Here's an offset example that works:
var factory = moi.command.createFactory( 'line' );
factory.setInput( 0, moi.vectorMath.createPoint( 3,1,0 ) );
factory.setInput( 1, moi.vectorMath.createPoint( 10,10,0 ) );
var output = factory.calculate();
moi.geometryDatabase.addObjects( output );
var factory = moi.command.createFactory('offset'); //Calculating the offset of line
factory.setInput( 0, output);
factory.setInput( 1, 3 );
// Creates a coordinate frame with origin at 0,0,0 and with x/y axes along world x/y axis directions.
var frame = moi.vectorMath.createTopFrame();
factory.setInput( 2, frame );
factory.commit();
- Michael
|