Issue with scripting and an object's 'locked' property

 From:  run
6317.1 
Hi Michael,

Hope you and everyone else on the forum had a nice Thanksgiving.

I've been doing some MoI scripting and it's been going pretty well, but I think I've found a bug
with an object's 'locked' property that's triggered when using the factory 'move' command.

This is on Windows (XP 32bit & Win7 64bit) and happens in the most recent betas and v2.
You should be able to reproduce the problem with the embedded scripts.

Two questions about forum code embedding. First: Is there a way to control the width of the code box?
Second: Double clicking on the box to grab all the code will get will get a 2nd blank line so pasting that
directly into a MoI shortcut is a no go. Is there a way to avoid this?


* Start with a completely empty MoI project.

* Add one object. The scripts assumes there's only one object so things will get messed up if there's
any more. The type doesn't matter. It can be a solid, a curve, a point, whatever you'd like.

* Add the first script to a key. This is just a test to show that the locking unlocking code does work for
this object without a factory move command. Pressing the key should toggle the objects locking on and off.
code:
 script:/*tester_01*/ var gd = moi.geometryDatabase; gd.deselectAll(); var pts = gd.getObjects(); var leng = pts.length; for(var i = 0; i < leng; i += 1) { if(pts.item(i).locked === true) pts.item(i).locked = false; else pts.item(i).locked = true; };

* Add the second script to a key. In theory the object should be moved to 16,16,16 and it's locked state should
be switched. Run it a couple times. Notice it will never toggle to 'locked' in the UI. Also note if you start locked, it will unlock it.
code:
script:/*tester_02*/ var gd = moi.geometryDatabase; gd.deselectAll(); var test  = 0;  var sds = gd.getObjects(); var bb =  sds.getHighAccuracyBoundingBox();  if(sds.item(0).locked === true) test = 1;  var vm = moi.vectorMath; var target = vm.createPoint(16,16,16);  sds.item(0).locked = false; sds.item(0).selected = true;  var factory = moi.command.createFactory( 'move' ); factory.setInput( 0, sds); factory.setInput( 1, bb.center ); factory.setInput( 2, target ); factory.commit();  if(test === 1) { sds.item(0).locked = false; } else { sds.item(0).locked = true; };  gd.deselectAll(); moi.copyTextToClipboard(sds.item(0).locked );

In the 2nd script there's an added 'copyTextToClipboard' for the object's locked property. If you start with the
object unlocked, so that the end result should be a locked object at 16,16,16, then run the script and paste the
clipboard into a text document, you'll see the property's value is indeed set to 'true'. Internally the object thinks
it's locked. Externally and in practice it's not locked at all, just a bit confused.

-Jeff