Scripting

 From:  dune1982
7238.39 
As I'm learning more and more I always meet a function which doesn't work like I think it would.

Today I tried to do a booleanunion on two cylinders. I get a typeerror, but why and how can I make it better?

var cylinders = moi.geometryDatabase.createObjectList();

/*make cylinder 1*/
frame = moi.vectorMath.createTopFrame();
frame.origin = moi.vectorMath.createPoint( 0, 0, 0 );
factory = moi.command.createFactory( 'cylinder' );
factory.setInput( 1, frame );
factory.setInput( 3, 30 );
factory.setInput( 4, moi.vectorMath.createPoint( 0, 0, 60 ) );
factory.update();
var cyl1 = factory.getCreatedObjects();
factory.commit();
cylinders.addObject(cyl1);

/*make cylinder 2*/
frame = moi.vectorMath.createTopFrame();
frame.origin = moi.vectorMath.createPoint( 0, 0, 0 );
factory = moi.command.createFactory( 'cylinder' );
factory.setInput( 1, frame );
factory.setInput( 3, 60 );
factory.setInput( 4, moi.vectorMath.createPoint( 0, 0, 30 ) );
factory.update();
var cyl2 = factory.getCreatedObjects();
factory.commit();
cylinders.addObject(cyl2);

/*cyl1 plus cyl2*/
moi.geometryDatabase.deselectAll();
factory = moi.command.createFactory( 'booleanunion' );
factory.setInput( 0, cylinders );
factory.update();
factory.commit();

Thanks for all the help so far