Scripting

 From:  Michael Gibson
7238.36 In reply to 7238.35 
Hi dune1982 - the problem is that your triangle and helix object lists are empty. That's because the factory has not created anything yet at the time that you call factory.getCreatedObjects(). Insert a call to factory.update() before you call factory.getCreatedObjects() and that should fix up your script, here I've marked the added lines with >>> <<<<<:

code:
var length = 100;
var sradius = 28
var steigung = 5

factory = moi.command.createFactory( 'helix' );
var frame = moi.vectorMath.createFrame();
frame.origin = moi.vectorMath.createPoint( 0, 0, 0 );
factory.setInput( 0, frame);
factory.setInput( 1, moi.vectorMath.createPoint( 0, 0, length ));
factory.setInput( 2, moi.vectorMath.createPoint( 1, 0, 0 ));
factory.setInput( 3, sradius);
factory.setInput( 5, sradius);
factory.setInput( 7, steigung);
factory.setInput( 8, 'pitch');
factory.setInput( 9, false);
>>>>factory.update();<<<<
var helix = factory.getCreatedObjects();
factory.commit();

function drawLine(x1,z1,x2,z2)
{
var linefactory = moi.command.createFactory( "line" );
linefactory.setInput( 0, moi.vectorMath.createPoint( x1, 0, z1 ) );
linefactory.setInput( 1, moi.vectorMath.createPoint( x2, 0, z2 ) );

var objlist = linefactory.calculate();
var line = objlist.item(0);
moi.geometryDatabase.addObject( line );
return line;
}

var linelist = moi.geometryDatabase.createObjectList();
linelist.addObject(drawLine(sradius, -steigung/2, sradius, steigung/2));
linelist.addObject(drawLine(sradius, steigung/2, sradius+5, 0));
linelist.addObject(drawLine(sradius+5, 0, sradius, -steigung/2));

var factory = moi.command.createFactory( 'join' );
factory.setInput( 0, linelist );
>>>>factory.update();<<<<
var triangle = factory.getCreatedObjects();
factory.commit();

//erstellt sweep
var factory = moi.command.createFactory( 'sweep' );
factory.setInput( 0, triangle );
factory.setInput( 1, helix );
factory.setInput( 4, 'none' );
factory.setInput( 5, 'flat' );
factory.setInput( 6, true );
factory.setInput( 7, true );
factory.setInput( 8, true );
factory.commit();


- Michael