MHC Python API Question

Hi,

So I’m trying to pipe in all the info MetaHuman Creator needs from Maya and I have a few questions.

I’m looking at the conform body py example and it looks like the joint translations are not used. Is setting joint translations not currently possible through the api?

result, joint_world_translations, joint_rotations = metahuman_character_subsystem.get_joints_for_body_conforming(body_skeletal_mesh)
if result != unreal.ImportErrorCode.SUCCESS:
    unreal.log_error("Failed to get joints for body conforming")
    return

success = metahuman_character_subsystem.conform_body(metahuman, vertices, joint_rotations, repose=True, estimate_joints_from_mesh=False)

And how are the joint rotational values calculated? I can’t figure out how you got the values

LogPython: [<Struct 'Vector' (0x0000020BE00C9050) {x: -0.000000, y: 0.000000, z: 0.000000}>,
 
LogPython: <Struct 'Vector' (0x0000020AC2234330) {x: 1.570796, y: 1.534966, z: 1.570796}>,
 
LogPython: <Struct 'Vector' (0x0000020AC2234380) {x: -0.000000, y: -0.000004, z: 0.191115}>,
 
LogPython: <Struct 'Vector' (0x0000020AC22343D0) {x: 0.000000, y: -0.000000, z: -0.127772}>,
 
LogPython: <Struct 'Vector' (0x0000020AC2234420) {x: 0.000000, y: -0.000006, z: -0.165914}>,
 
LogPython: <Struct 'Vector' (0x0000020AC2234470) {x: 0.000000, y: 0.000000, z: -0.148927}>,
 
LogPython: <Struct 'Vector' (0x0000020AC22344C0) {x: -0.000000, y: 0.000000, z: 0.026750}>,
 
LogPython: <Struct 'Vector' (0x0000020AC2234510) {x: -0.000000, y: -0.000000, z: 0.404122}>,
 
LogPython: <Struct 'Vector' (0x0000020AC2234560) {x: -0.000000, y: -0.000000, z: -0.015788}>,
 
LogPython: <Struct 'Vector' (0x0000020AC22345B0) {x: -0.000000, y: 0.000000, z: -0.199416}>,
 
LogPython: <Struct 'Vector' (0x0000020AC2234600) {x: 2.969533, y: -1.438563, z: -2.782088}>,
 
LogPython: <Struct 'Vector' (0x0000020AC2234650) {x: -0.080422, y: -0.788340, z: 0.057689}>,



Any update on this?

Hi Robert,

Apologies for the delay in responding here. I have been discussing with the team and hope to have an update soon.

Thanks,

Mark.

Hi Mark,

Thanks for getting back to me. Are there any details on the discussion you can give?

Hi Robert,

Sorry for the delay getting back to you on this one. Mark passed it over to me to take a look.

You’re right that, unfortunately, in 5.7, it’s not possible to set the joint translations via the blueprint/python API by default. There is a function to do this in the MetaHumanCharacterEditorSubsystem (SetBodyJoints) but it’s not exposed to python in 5.7. So one option is just to modify UMetaHumanCharacterEditorSubsystem directly within the MetaHumanCharacter plugin by doing the following:

	/* Set custom body joints */
	UFUNCTION(BlueprintCallable, Category = "MetaHuman|Conforming")
	bool SetBodyJoints(UMetaHumanCharacter* InMetaHumanCharacter, const TArray<FVector3f>& InComponentJointTranslations, const TArray<FVector3f>& InJointRotations, bool bImportHelperJoints);

Or, if you don’t want to modify the plugin code, you might be able to call this via a custom blueprint library class within your project code.

Either way, once you have that exposed, you would call it after your existing script that calls conform_body.

We’ve exposed this function along with a few others to python & blueprint in the 5.8 release so you won’t need to maintain any custom C++ code if/when you upgrade to do this.

Let me know if you have any questions.

Thanks,

Euan

Hi Euan

I had figured out workarounds in the meantime and so I probably just going to wait until we update to 5.8.

Good to know the 5.7 does have some options if someone is locked to that version

Thanks,

Robert

Good to hear that you aren’t blocked by this. Thanks for raising this issue, it was the initial discussion between Mark and the dev team that prompted the change to expose this for 5.8 so it’s been useful feedback. I’ll close out the thread.