Simple VBS scripting question (Multiple object CopyPaste)

Discussions concerning programming of SOFTIMAGE©
Posts: 1
Joined: 06 May 2017, 19:59

Simple VBS scripting question (Multiple object CopyPaste)

Post by perrin26 » 10 May 2019, 21:10

I have almost 0 knowledge regarding scripting, but I am trying to create a script to make my life easier. One part of the script needs to select multiple objects, and paste them. I have no problem selecting objects using a string like:
SelectObj "Scene1.Tracker*"
but something like
CopyPaste "Scene1.Tracker*", , "Trackers", 1
Doesn't work.
(Copying all the objects with the prefex tracker out of the Scene1 node and into a node called Trackers)
I spent time trying to find examples of doing multiple copy paste commands, but I can't figure it out.
also, curious... what is the , , in that command (shouldn't there be something between? and why , 1.
Ah well.

User avatar
Posts: 1672
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: Simple VBS scripting question (Multiple object CopyPaste)

Post by rray » 11 May 2019, 14:35

About the "arg1, ,arg2", this is an empty argument which in this case means use the default value (VBS Syntax)
softimage resources section updated Feb 7 2019

User avatar
Posts: 384
Joined: 28 Sep 2011, 10:33

Re: Simple VBS scripting question (Multiple object CopyPaste)

Post by myara » 11 May 2019, 14:56

I don't know why you are trying VBS. I'd suggest to start with Python even if that's harder at the beginning.
I think VBS might be the easiest one at first, but it gets pretty nasty when you try to do more advanced things.

Anyway, the problem using CopyPaste is that it doesn't have a return value. Meaning you don't have any control of that new object in the rest of your script, so personally I don't use it for duplicate objects. This could be a problem if you want to rename the duplicated object.

I'd use Duplicate and then ParentObj to change it's parent.

A sample code :

Code: Select all

'Get Selection
set obj = Selection(0)

'Duplicate and Rename
set dup = Duplicate( obj )(0)
dup.Name = obj.Name & "_Duplicated"

'Re Parent
ParentObj "Camera_Root", dup
This would Duplicate your object, and reparent under the Camera_Root.
By using set statement you are declaring that variable as an object, not a simple string. Meaning you'll be able to use it's object properties. In this case I'm using Name to rename it.
Note : Duplicate returns you a Collection even if you have duplicated only 1. That's why I'm using (0) to get only the first object of that collection.

After writing this, I realized that maybe you just want to re-parent the Object right ? If that's the case, then you just need the command ParentObj.

For more info about the commands you should check the SDK manual ... Paste.html
Character Modeler | Softimage Generalist (sort of)