Website Youtube GitHub

mGear Framework Forum

Batching using the new guide placement feature

Could anyone share information on being able to batch process rig building in mgear 3.5 utilising the relative guide placement.

I have about 100 characters to build and little time.
Eeeek!
:sleepy:

Thanks in advance
B.

Hello

Do all of the characters have a universal mesh in common?

Hey Rafael.

Thanks for responding.
All the character do indeed share a universal mesh.

Hey,

So what you are going to want to do is start with a character that already has the guides well placed. A character that is generic as possible to help with the transfer to all the remaining characters.

You mentioned the word “build”, as in place the guides and then build the rig. But I would do that in a separate batch function as that can be really time-consuming and there is more chance for something to go wrong when all we want to do is place the guides.

list_of_scenes = [r"path/to/modelA", r"path/to/modelB"]

# import the guide placement from the first character and guides
(relativeGuide_dict,
ordered_hierarchy) = relative_guide_placement.importGuidePlacement(filepath)

for scene in list_of_scenes:
	# open the scene with the no character and model
	# import the guides used to record the initial guides
	# once both the guides and the model are present call this to place guides
	relative_guide_placement.updateGuidePlacement(ordered_hierarchy,
												  relativeGuide_dict)
	# save scene and then move ontothe next character, if you do decide to build, now would be the time.

Here is pseudo code to help get you going. Please remember that the guides will be placed as best they can but may still require an eye to look the results over. But for getting you started, this will do the trick.

Let me know if this helps at all.

3 Likes

Ahhh man this is so helpful.
I shall keep this post updated on what I can get out.

Yes please do, we’d love to see a success story with this new tool. Especially with a 100 or so characters.

1 Like

Hello @Benn

Have you test this out? How is it going? As @Rafael I am curios to hear from you on this matter.

Cheers

I think I maybe stuck :frowning:

import mgear.shifter.custom_step as cstp
from mgear.core import skin
import os
import pymel.core as pm
import maya.cmds as mc

list_of_scenes = [r"C:/Users/BennGarnish/Desktop/mgearBatching/file_01.mb", 
					r"C:/Users/BennGarnish/Desktop/mgearBatching/file_02.mb"]

filepath = "D:/P4/P4Root/ART/Projects/Rigging/Rigging_Characters/custom_steps/data/guide.sgt"

#import the guide placement from the first character and guides
(relativeGuide_dict,
ordered_hierarchy) = relative_guide_placement.importGuidePlacement(filepath)

for scene in list_of_scenes:
	# open the scene with the no character and model
	mc.file(scene, open = True, force = True)
	# import the guides used to record the initial guides
	relative_guide_placement.importGuidePlacement(filepath)
	# once both the guides and the model are present call this to place guides
	relative_guide_placement.updateGuidePlacement(ordered_hierarchy,
												  relativeGuide_dict)
	# save scene and then move ontothe next character, if you do decide to build, now would be the time.
	mc.file(scene, save = True, force = True, type='mayaAscii')

Based on my first attempt at coding this little bad boy I have only been able to open up the file…
Im not sure of what calls I need to grab next.

Based on the guide from Jerome I need to import various the guide. Is this a manual import or can this be called using the script?

What I have done at the moment:

Opened up the first file and imported the guide using the mgear menu - > import guide template.
Then i made some test maya files and added their locations into the dictionary.

I am lost in the section above the for loop.
And after running the open file command I am also lost again.

Any further guidance would be amazing.

Hey @Benn sorry for the delayed response. I did not get any notifications on this thread for some reason.

You still having an issue with this? If so let me know.

Hey Rafael.

I am indeed still struggling.
I don’t think I know enough about the mgear library in order to make the right calls.

I think the issue is coming from the fact that you are not importing the relative_guide_placement in your script no?

Okay, so a couple of issues with the script posted.
But before we get to that, you need to export an .rgp (Relative guide placement) file.

  1. Name of the mesh
  2. Record
  3. Export .rgp file (We’ll need this)

Then with the script @Jerome was correct as well. But there are some other issues.
I corrected them here.

from mgear.shifter import relative_guide_placement
from mgear.shifter import io
# import mgear.shifter.custom_step as cstp
import maya.cmds as mc

list_of_models = [r"C:/Users/BennGarnish/Desktop/mgearBatching/file_01.mb",
                  r"C:/Users/BennGarnish/Desktop/mgearBatching/file_02.mb"]

guides_filepath = r"D:/P4/P4Root/ART/Projects/Rigging/Rigging_Characters/custom_steps/data/guide.sgt"
rgp_filepath = r"location/to/.rgp"

# import the guide placement from the first character and guides
(relativeGuide_dict,
 ordered_hierarchy) = relative_guide_placement.importGuidePlacement(rgp_filepath)

for scene in list_of_models:
    # open model scene (Nothing but the model in here.)
    mc.file(scene, open=True, force=True)
    # import the guides used to record the initial guides
    io.import_guide_template(filePath=guides_filepath)
    # once both the guides and the model are present call this to place guides
    relative_guide_placement.updateGuidePlacement(ordered_hierarchy,
                                                  relativeGuide_dict)
    # save scene and then move ontothe next character
    # if you do decide to build, now would be the time.
    mc.file(scene, save=True, force=True, type='mayaAscii')

There were a couple of wrong calls in there, but it is understandable why.
This will only update the guide placement to fit the model in the scene with universal mesh.

Let me know how it goes.

2 Likes

Ok I am able to batch through the scenes, however, the placement of the guides are not being adjusted to variations in the uni mesh.

Do you have any more information on this? Any errors?

Any images of the result of one of the batches?

No errors and when I try and step through the code, there’s no action on:

relative_guide_placement.updateGuidePlacement(ordered_hierarchy,
                                              relativeGuide_dict)

Show me an image of the original guides and source universal mesh that you used to export the rgp file from.

Original guide placement with geo

And can you paste the code you have so I can see if there have been any changes that may have caused this

Edit:
Or better yet, detail to me all the steps you are taking in this process. Starting from using the UI to using the script

Hey mate,
I went through this setup:

  • Open up maya file with uni mesh
  • Using mgear menu option to import guide template
  • Next step was to run through the Relative Guide Placement as you stated above

Once I had this information and the exported guide I run this python code:

mgear.shifter import relative_guide_placement
from mgear.shifter import io
import mgear.shifter.custom_step as cstp
import maya.cmds as mc

list_of_models = [r"C:/Users/BennGarnish/Desktop/mgearBatching/file_01.mb",
                  r"C:/Users/BennGarnish/Desktop/mgearBatching/file_02.mb"]

guides_filepath = r"D:/P4/P4Root/ART/Projects/Rigging/Rigging_Characters/custom_steps/data/guide.sgt"
rgp_filepath = r"C:/Users/BennGarnish/Desktop/mgearBatching/guide_batch.rgp"

#import the guide placement from the first character and guides
(relativeGuide_dict,
 ordered_hierarchy) = relative_guide_placement.importGuidePlacement(rgp_filepath)

for scene in list_of_models:
    # open model scene (Nothing but the model in here.)
    mc.file(scene, open=True, force=True)
    # import the guides used to record the initial guides
    io.import_guide_template(filePath=guides_filepath)
    # once both the guides and the model are present call this to place guides
    relative_guide_placement.updateGuidePlacement(ordered_hierarchy,
                                                  relativeGuide_dict)
    # save scene and then move ontothe next character
    # if you do decide to build, now would be the time.
    mc.file(rename = scene.split('.mb')[0] + "_guide.ma")
    mc.file(save=True, force=True, type='mayaAscii')
Summary

This text will be hidden