Batch processing pointers

54 views
Skip to first unread message

Steve Davy

unread,
Jun 23, 2015, 2:09:32 AM6/23/15
to Maya Group
I have a project where I have a few batch type functions required, including:

1) Renaming and numbering a whole bunch of objects A based either on selection order or worldspace proximity to a bunch of other objects B.

2) Creating a unique blendshape for every member of objects A, with its corresponding object B

3) Renaming all of the blendshape attibutes to a common name for rigging purposes (so far as I can tell, Maya does not give you any control over what the blend attribute is called and automatically names it after the target object, WTF).


Since my scripting skills have completely atrophied (am currently trying to learn Python!), digging around on Creative Crash for some tools to help. There are lots of likely candidates but as usual I'll take personal recommendations over potentially wasting time on something that won't work. Any tips appreciated!

Stephen

unread,
Jun 23, 2015, 8:18:23 AM6/23/15
to maya...@googlegroups.com


1) Renaming and numbering a whole bunch of objects A based either on selection order or worldspace proximity to a bunch of other objects B.

 Well by selection is certainly easier to script or use cometRename.  But it sounds like you need the latter. Unless selection of your A group in order is just as easy as your B group so they match  
  You can use the Xform command and basically loop through all your A objects and test each one against all the B objects and when you find matches. Remove them from the arrays and rename them.  It's tedious but if you don't have to run it a lot.  Doesn't hurt to have something like that for when you need it.   And also could come in handy for the matching of your blendshapes and their targets 

2) Creating a unique blendshape for every member of objects A, with its corresponding object B
The blend shape command is pretty straight forward. You can give it -target and base name and it will make the blendshape. I tend to name the blendshape based on the base as well to make it easy to find and if need parse in a script later.  Ie base is gorilla27 so blendshape node is named gorilla27_blendshape. 

3) Renaming all of the blendshape attibutes to a common name for rigging purposes (so far as I can tell, Maya does not give you any control over what the blend attribute is called and automatically names it after the target object, WTF).


I actually like having my weight names match the target names.  Makes it easier to decipher if need be.  The majority of the time I'm never actively keying or affecting the blendshape node directly but rather with a curve or object control.  That way you can change multiple channels at once using the mmb slider as well as have control over naming of the channels.   If need be you can alias channels. But being that selecting blendshape nodes in the vp isn't quite so easy , especially multiples , I find it much easier to have a transform node that I can quickly select and affect.   
  In your case what I would probably do is add the channel to the base objects directly   So you can give each object the exact same named channel and be able to select all your objects and set the channels.  And also keep the number of objects down in the scene. 
  Blendshape channels can be accessed by target name but also by the weight array. So you can easily connect your base channel to the blendshape weight in a script 
  Ie  name the base channel "blend" and then use connectAttr  to connect from gorilla.blend to gorilla_blendshape.w[0]  

--
 What I also would recommend is making this into one script to create the blend , add the channel , and make the connection 
  The reason for this is so you don't have to go hunting for the blendshape node after the fact and make the connections , but rather capture it in the creation process. 

  Hope that helps and good luck. 

-=s

Steve Davy

unread,
Jun 23, 2015, 3:24:35 PM6/23/15
to Maya Group
Hi Steve,

Thanks for the help.

I managed to remember enough MEL to help me with 1)

I have 619 unique objects, so I was hoping that for 2) there might be some sort of batch utility out there that would allow me to simply load all my base and target objects into a couple of buffers and create blendshapes that way.

Likewise, because I then also need to connect controllers for each of these to their respective blendshape (as you say, not driving the blend attr. directly), ideally I want the blend attribute on each blend node to be named the same for 3). Got a script (jh_goodParenting.mel -- recommended!) that allows for making very easy connections to lots of objects this way.... provided the attributes are all named the same.


From: stephe...@gmail.com
Subject: Re: [maya_he3d] Batch processing pointers
Date: Tue, 23 Jun 2015 08:18:17 -0400
To: maya...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "maya_he3d" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maya_he3d+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nicolas Combecave

unread,
Jun 23, 2015, 3:46:47 PM6/23/15
to maya...@googlegroups.com
I don't know if it is applicable to your case, but you can make a blendshape between two groups, that each contains the same amount of objects. Those objects must follow a logical order in the groups:

group_bases:
  |_ obj_01_base
  |_ obj_02_base
  |_ obj_03_base
  |_ obj_04_base
  |_ obj_05_base
  |_ obj_06_base
  |_ etc...

target_01:
  |_ obj_01_target_01
  |_ obj_02_target_01
  |_ obj_03_target_01
  |_ obj_04_target_01
  |_ obj_05_target_01
  |_ obj_06_target_01
  |_ etc...

target_02:
  |_ obj_01_target_02
  |_ obj_02_target_02
  |_ obj_03_target_02
  |_ obj_04_target_02
  |_ obj_05_target_02
  |_ obj_06_target_02
  |_ etc...


Then you get a single blendshape which has two weights named target_01 and target_02.
Note that base objects can each have a different topology, but their 'equivalents' in the target groups must have the same topology for correct results.
You can have as many target groups as you want...

Note that I named the objects this way only for clarity, those names don't matter... But it's definitely a big plus if you need to process those objects via scripting to track/group them, etc...

Nicolas



Nicolas Combecave

unread,
Jun 23, 2015, 3:57:03 PM6/23/15
to maya...@googlegroups.com


Steve Davy

unread,
Jun 23, 2015, 6:11:28 PM6/23/15
to Maya Group
Actually that's pretty much exactly what I need to do, only simpler as there is only one target shape per object.

But the gist is the same -- a list of base objects and a list of target objects. I'm simply looking for a way to A) Batch create blend shapes in such a way that each object gets the correct target (currently renaming 619 objects for this purpose!). So my lists would be base_001-base_619, and target_001-target_619.

Then, hopefully, B) rename the blend attributes on each of the resulting 619 blendshape nodes to something uniform so I can also easily batch connect my controller attributes to each one (using jh_goodParenting.mel).

I'm not quite clear how you'd go about the approach you're suggesting though? Does this require scripting? That's sort of the root of my problem. My scripting skills are not good enough to create the two arrays I assume you'd need to automate this.


Date: Tue, 23 Jun 2015 21:57:01 +0200

Subject: Re: [maya_he3d] Batch processing pointers

Nicolas Combecave

unread,
Jun 23, 2015, 6:42:21 PM6/23/15
to maya...@googlegroups.com
If you want each blendshape to have a different value, then you'll need to have as many blendshape as there are objects. But if you plan to have them all synced via connection to a controller that feeds them the same value, your only concern is to order  your bases and your targets the same way into separate groups and blendshape the two groups together, you'll end up with a single blendshape with a single attribute to drive/animate...

Steve Davy

unread,
Jun 23, 2015, 7:27:26 PM6/23/15
to Maya Group
Sorry, I wasn't clear about that. Yes, I do need each blendshape to be independent so that values can be different.

So I have 619 base shapes with 619 targets = 619 blendshape nodes.

My controllers on the base shapes will have an attr. driving those blendshapes.

The question then is how to create these 619 blendshapes without having to do it manually one by one, and also how to then rename each blend attribute so I can easily hook up my custom attribute.


Date: Wed, 24 Jun 2015 00:42:20 +0200

Nicolas Combecave

unread,
Jun 24, 2015, 3:40:25 AM6/24/15
to maya...@googlegroups.com
Sorry when you said you wanted a common attribute to drive the blendshapes I understood you wanted a single attribute driving all the blendshapes.
So I don't have much to add that Stephen has already said...

Will try to find some time to help with searching closest object later.

Nicolas


stephenkmann

unread,
Jun 24, 2015, 11:09:57 AM6/24/15
to maya...@googlegroups.com
for finding closest. 
 I put all the main objects in an array, and all the ones that you want to find in a second array
then for each in the first Array, I get its worldspace position using xform -q -rp -ws 
and then iterate through all the Second array positions. finding the smallest difference each time, and each time
I get a smaller distance, I make that the answer. 
at the end. you should be left with the object that is the shortest distance away. 
 also at that point, i remove it from the second array, so it doesn't keep getting checked. 

 granted this isn't the most efficient way, but it does work. 

 and from that I create a new array that is a matched pair

 pairArray[0] = gorilla1Base ; pairArray[1] = gorilla1TGT ;  pairArray[2] = gorilla2Base ; pairArray[3] = gorilla2TGT ;

 ( obviously the names won't line up.. but I do recommend renaming them to match .. it just helps so much ) 

 often, I will match the target with the same name as the base. but with just TGT added, 
 this makes it easier to script and find. and it's always easier to add to a name, then search, parse and replace. 
 ie:   string $basename = "gorilla" ; string $targetname = ($basename + "TGT");


so , lets say all the names line up  like above.. 
 now you can run a simple loop script to make the blendShapes

for ($base in $sel)
        string $bss[] = `blendShape -n ($base + "_blendShape") ($base + "TGT") $base`;


Add your channel to the base and connect the attributes

connectAttr ($base + ".blendChannel") ($bss[0] + ".w[0]");



hope that helps
 -=s












Steve Davy

unread,
Jun 24, 2015, 12:45:18 PM6/24/15
to Maya Group
Thanks Steve.

This would help if I understood all the correct syntax but as mentioned my scripting skills are rusty. So, while I understand the principals you're explaining, actually writing the code to do it is beyond me at the moment.

I'm hoping that Python will be a little easier to use than MEL, which I've never really fully managed to grasp. So far the syntax alone seems a lot more human friendly.


Date: Wed, 24 Jun 2015 11:09:55 -0400

Subject: Re: [maya_he3d] Batch processing pointers

Steve Davy

unread,
Jun 24, 2015, 12:58:33 PM6/24/15
to Maya Group
In particular I'm not getting the blendshape creation code:


for ($base in $sel)
        string $bss[] = `blendShape -n ($base + "_blendShape") ($base + "TGT") $base`;

I know this is a simple for-in loop,  but I'm unclear exactly what's going on here...

Like I said, syntax!

Cheers.


Date: Wed, 24 Jun 2015 11:09:55 -0400

Subject: Re: [maya_he3d] Batch processing pointers

Steve Davy

unread,
Jun 24, 2015, 3:36:04 PM6/24/15
to Maya Group
Never mind -- with a bit more coffee I figured out what's going on here. Thanks again.


From: stevi...@hotmail.com
To: maya...@googlegroups.com
Subject: RE: [maya_he3d] Batch processing pointers
Date: Wed, 24 Jun 2015 09:58:31 -0700
Reply all
Reply to author
Forward
0 new messages