copy and paste
All  1-5  6-10

Previous
Next
 From:  Marc (TELLIER)
6181.6 
Hi,

Here's a small script Michael wrote a while ago:

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

I use it a lot, set on shift+D shortkey.

Marc
  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:  Chuck (ROCKFORD)
6181.7 In reply to 6181.5 
I've noticed that the Ctrl-drag method of duplicating an object does not select the new object. You have to click off the parent and then select the new object. So, I guess that hitting copy and then paste is still the fastest way to execute a simple duplication. (two clicks to a selected object that's ready to move)
  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:  Chuck (ROCKFORD)
6181.8 In reply to 6181.7 
Hey,

Thanks Marc!
  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:  propiro
6181.9 
Hello,
Sorry for digging up old thread.
Im new to moi scripting, i do however have some maxscript and c# experience.
For now, I have no idea why the modification of above script doesnt work, and im not sure if its related to moi behaviour, or my rusted skills:

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' );

all i want is for this script AFTER pasting the copy to immidiately enter move command - it enters, but for original object, and actually doesnt duplicate the the object. If i remove last 2 lines (i've already tried just simply "moi.command.execCommand( 'Move' );" ) and "move" assuming it should be already selected, but result was identical.
Any help welcome, thanks!
  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
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-5  6-10