undo a command (scripting)
All  1-12  13-15

Previous
Next
 From:  Michael Gibson
10939.13 In reply to 10939.12 
Hi Peer, try this:

code:
var index = 0;
var destinationPoint = moi.vectorMath.createPoint(1,1,1);

var rect_factory = moi.command.createFactory( 'rectangle' );
rect_factory.setInput( 0, moi.vectorMath.createFrame() );
rect_factory.setInput( 1, null );
rect_factory.setInput( 2, 5 );
rect_factory.setInput( 3, 5 );
rect_factory.setInput( 4, false );
var objList = rect_factory.calculate();
//moi.geometryDatabase.addObjects(objList);

var obj = objList.item(0);

obj.showPoints = true; // must show points to make them editable
obj.setEditPointSelected(index, true);

/*
non-interactive object picker with allowEditPoints()
simply to get edit point into an objectList so that it can be manipulated
*/
/*
var objectpicker = moi.ui.createObjectPicker();
objectpicker.allowEditPoints();
objectpicker.done();
var editPointInList = objectpicker.objects;
*/

var basePt = obj.getEditPoint(index);

var factory = moi.command.createFactory('move');
factory.setInput(0, objList);
factory.setInput(1, basePt)
factory.setInput(2, destinationPoint);

// remove the original object, gather up the newly moved object, and add to database
moi.geometryDatabase.removeObject(obj);
var movedObjInList = factory.calculate();
moi.geometryDatabase.addObjects(movedObjInList);

// re-hide the edit points
movedObjInList.item(0).showPoints = false;


That removes moi.geometryDatabase.addObjects(objList); , and removes the objectpicker piece
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pressure (PEER)
10939.14 In reply to 10939.13 
Thanks Michael for the edited code!

What you posted works for me by itself, but when I try incorporating it into the larger thing I'm working on I still have the same kind of problem with undo.

I removed the other instances of moi.geometryDatabase.addObjects() and don't have any object pickers, but the problem persists.

Is there a general principal I can use to troubleshoot this?

- Peer
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Michael Gibson
10939.15 In reply to 10939.12 
Hi Peer, it looks like there's a bug where undo can get confused in certain cases if you both add and remove the same object within the same command.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages: All  1-12  13-15