Hi Michael,
what is the correct way to assign objects to variables? So far I use factory.commit which adds the object to the scene, then I select it somehow (which is not always easy) and assign the selection to a variable. It works but I think there must be a better way. I saw that you use factory.calculate() to assign an object to a variable followed by factory.cancel() and tried the following script:
code:
/*draw cylinder*/
var factory = moi.command.createFactory( 'cylinder' );
factory.setInput( 1, moi.vectorMath.createFrame() );
factory.setInput( 3, 20 );
factory.setInput( 4, moi.vectorMath.createPoint( 0, 0, 40 ) );
var cylinder1 = factory.calculate();
cylinder1.name = 'Zylinder 1';
factory.cancel();
moi.geometryDatabase.addObject(cylinder1);
The script above crashes MoI so I assume my understanding of how this all works is wrong :-)
|