Transfer SRTs from one group to the other

Discussions concerning programming of SOFTIMAGE©
Post Reply
Pancho
Posts: 659
Joined: 19 Sep 2010, 11:28

Transfer SRTs from one group to the other

Post by Pancho » 23 Feb 2014, 13:31

Could somebody please help me out with a script that transfers SRTs from one group to another? Both groups have the same amount of objects with the same name. Actually I need to transfer the static pose of a model at a certain frame to another model with a similar rig (same amount of controletrs, but differently placed). So I want to copy the SRTs of the controler group a to group b.

# Python
xsi = Application
collSel = xsi.Selection

obj1 = collSel(0)
obj2 = collSel(1)

xformTemp = XSIMath.CreateTransform()
xform1 = obj1.Kinematics.Local.GetTransform2(None)
xform2 = obj2.Kinematics.Local.GetTransform2(None)

xformTemp.SetTranslation(xform2.Translation)
xformTemp.SetRotation(xform1.Rotation)

obj2.Kinematics.Local.PutTransform2(None, xformTemp)

That's the only thing I found on thre google group. It seems to transform only the rotation from selection a to b. I would need it to work for the whole SRT and from group a to group b.

No idea how to program this.

Anybody?

Cheers
Thomas

User avatar
mattmos
Posts: 445
Joined: 02 Dec 2009, 16:59

Re: Transfer SRTs from one group to the other

Post by mattmos » 23 Feb 2014, 13:51

Do you need to program this? How many times will you need to repeat it? You could just save an action for the first model with all the controllers included, copy the action into the mixer of the new model and apply action with new one selected. If named the same it should transfer across fine.

Pancho
Posts: 659
Joined: 19 Sep 2010, 11:28

Re: Transfer SRTs from one group to the other

Post by Pancho » 23 Feb 2014, 14:02

Didn't think of that so far. Might be fine. Probably I can make things easier with a text application to replace and replicate some stuff.

Thought there's an easy way to use the script if there is something like a "iterate over group members" in python.

Thanks, Matt.

User avatar
myara
Posts: 403
Joined: 28 Sep 2011, 10:33

Re: Transfer SRTs from one group to the other

Post by myara » 23 Feb 2014, 17:14

Of course you can iterate group members with a simple for loop group.members. As obvious as it sounds.

Code: Select all

x = Application
sel = x.Selection
l = x.Logmessage
if sel.count == 2 and sel(0).type == "#Group":
    groupA = sel(0)
    groupB = sel(1) #source
    for objA in groupA.members:
        objB = groupB.members(objA.name)
        if objB :
            objA.Kinematics.Global.Transform = objB.Kinematics.Global.Transform
        else :
            l ("["+ str(objA.name) + "] doesn't exist in " + str(groupB.name) )
What this does:
condition: only works if you have 2 selected objects and the first one is a group.
copy the global transform (SRT) from each member of the first selected group to the object of the same name in the second selected group if it exists.
M.Yara
Character Modeler | Softimage Generalist (sort of)

Pancho
Posts: 659
Joined: 19 Sep 2010, 11:28

Re: Transfer SRTs from one group to the other

Post by Pancho » 24 Feb 2014, 09:39

Thanks! I'll give it a try asap!

Pancho
Posts: 659
Joined: 19 Sep 2010, 11:28

Re: Transfer SRTs from one group to the other

Post by Pancho » 24 Feb 2014, 22:49

Excellent!!! Thanks so much!

Kine.global didn't work nicely, but kine.local did it!!!

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests