Auto dimensions

 From:  Michael Gibson
11637.7 In reply to 11637.6 
Hi Peticel

> Are they controlled through << factory.setInput( 3, 0 ); /* Input 3 - index of Dimension properties preset to use *>> ?

They can be controlled through that or set directly on the object.

To do it by preset, go to Options dialog > "Dimensions" and set up a preset that has the properties how you want them, then pass the index of that preset as the 2nd parameter to setInput, like this: factory.setInput( 3, preset_index );

Accessing the dimension object and setting properties on it directly can be done like this:
code:
var factory = moi.command.createFactory( 'dimhorizontal' );
var frame = moi.vectorMath.createTopFrame();
frame.origin = moi.vectorMath.createPoint(10,0,0);
factory.setInput( 0, frame );                               /* Input 0 - coordinate frame for dimension plane, frame origin at start point. */
factory.setInput( 1, moi.vectorMath.createPoint(20,0,0) );  /* Input 1 - end point */
factory.setInput( 2, moi.vectorMath.createPoint(15,10,0) ); /* Input 2 - text through point */
factory.setInput( 3, 0 );                                   /* Input 3 - index of Dimension properties preset to use */
factory.update();
var dim = factory.getCreatedObjects().item(0);
dim.text = '<> units';
factory.commit();

Probably it would be easiest to set up a preset for the size and alignment properties since there's a UI for those under Options > Dimensions but you can't control the text to include units in a preset yet so for that part set the text directly on the dimension object as above.

- Michael