Scripting

 From:  dune1982
7238.24 In reply to 7238.23 
Thank you so much Martin and MAX, this helped a lot understanding more and more. I wonder how you find these answers in the forum? everytime I use the search function it returns nothing interesting.

I hate to bother you guys again with my questions, I tried to figure it out by my self put didn't solve it.

I'm still learning the basics. So I made this script which should draw a polygon and then extrude it to 5

function drawpolygon() {
polygonfactory = moi.command.createFactory( 'polygon' );
var frame = moi.vectorMath.createFrame(); //erzeugt das Koordinatensystem für den Zylinder
frame.origin = moi.vectorMath.createPoint( 0, 0, 0 ); //Uhrsprungspunkt
var direction = frame.evaluate( 7.2, 0, 0 ); //Radius des Poligon
polygonfactory.setInput( 0, frame );
polygonfactory.setInput( 1, direction );
polygonfactory.setInput( 2, 6 );
polygonfactory.commit();
}
drawpolygon(); //until here It works, I see the polygon

var objects = moi.geometryDatabase.selectAll(); // the polygon is selected


var extrudefactory = moi.command.createFactory( 'extrude' );
extrudefactory.setInput( 0, objects ); //in my mind this should take the selected polygon to extrude
extrudefactory.setInput( 2, 5 ); // distance 5mm
extrudefactory.setInput( 3, moi.vectorMath.createPoint( 0, 0, 1 ) ); //direction to extrude
extrudefactory.setInput( 1, true ); //cap ends? yes
extrudefactory.commit();

Where is my mistake?