Loft factory question

 From:  Michael Gibson
5493.6 In reply to 5493.1 
Hi Martin, your loft code has a typo on the very last line, the one I've marked here with a <<<<

code:
var list = moi.createList();
list.add( moi.vectorMath.createPoint( 0, 0, 0 ) );
list.add( moi.vectorMath.createPoint( 0, 1, 0 ) );
factory = moi.command.createFactory( 'loft' );
factory.setInput( 0, moi.geometryDatabase.getSelectedObjects() ); //ObjectList
//factory.setInput( 1, list ); //Orientations List ???
factory.setInput( 2, 'straight' ); //Loft style
factory.setInput( 3, true ); // Cap ends
//factory.setInput( 4, false ); // closed ????
factory.setInput( 5, 'Exact' ); // Profiles
factory.commit;    <<<<<<<<<<<<<<<<<<<<<<<< bug here


The bug is that you need to be executing the commit function, you're missing the parenthesis on it () which is needed for JavaScript to know that you want to invoke that property name as a function call. So the least line should read factory.commit();

This is a bit of a tricky area in JavaScript, because functions can be referred to by name as well in which case they're treated as property values, so what you have written there does not happen to be a syntax error, it just doesn't do anything, you need the () to be there to make it do what you wanted.

The orientation list can be left out - if it's missing a default one will be created. The orientation list is not just a list of points, it holds one IMoiCurveOrientation object for each input curve, and that orientation object has a "flipped" property and a "seam" value, which store whether the loft should use the curve reversed from its natural direction and what spot it should use as the start/end location on a closed curve for where to relocate its seam point, the seam is stored as a normalized parameter value with 0.0 being the start of the curve and 1.0 as the end of the curve.

If you leave out the orientation data, it will do the default calculation to try and figure out a whether it should flip and relocate the seam to a good spot to reduce twisting of the generated loft. If the user specifically adjusts the twist or flips which they can do at the last prompt in the Loft command, it updates those values. But for normal use unless you want to have the auto-twist-minimization mechanism specifically turned off you could just leave that to be blank and let it get calculated automatically.

- Michael