copy and paste
All  1-9  10

Previous
 From:  Michael Gibson
6181.10 In reply to 6181.9 
Hi propiro,

re:
code:
script:
/* Duplicate selected objects */
var gd = moi.geometryDatabase;
var objs = gd.getSelectedObjects();
if ( objs.length != 0 ) gd.copyToClipboard( objs );
moi.command.execCommand( 'paste' );
objs =gd.getSelectedObjects();
if ( objs.length != 0 ) moi.command.execCommand( 'Move' );


The problem is that execCommand is not synchronous, so as to avoid one command from running while still inside another one.

So execCommand sets some flags and then the command is only actually launched when on a clean call stack.

But instead of using execCommand( 'paste' ) you can use the direct script code for what the Paste.js command does internally which is:

code:
moi.geometryDatabase.pasteFromClipboard();


There are also some other already existing ways to duplicate objects similar to this - the Transform > Copy command or also holding down the Ctrl key when you click and drag on an object will drag off a duplicate.

- 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-9  10