Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Python / Instantiate Character face
  RSS 2.0 ATOM  

Instantiate Character face
Rate this thread
 
58239
 
Permlink of this thread  
avatar
  • Laudor
  • Posted: 20 July 2011 01:24 PM
  • Total Posts: 4
  • Joined: 23 March 2010 08:40 AM

Hi guys, I have a rookie question. How do I instantiate Character face with python? It is easy assigning character to variable via:

myChar = FBApplication().CurrentCharacter

but characterFace isn’t supported in FBApplication class, I guess there is other approach
Thanks in advance



Replies: 0
avatar
  • melvin3d
  • Posted: 31 July 2011 06:09 PM

Hey man..
Yeah its the same thing as anything else ... you just need to create an instance of the char face.
make it active ,,,if need to ..and so on..

So… example…

from pyfbsdk import *

# create a face
lFace = FBCharacterFace(’Myface’)
lFace.ActiveInput = True

# to delete the face
lFace.FBDelete()

That should get you get going with the creation of the face .. hooking stuff up into it is another story .. :) ..
Good luck.

Melvin3d



Replies: 2
/img/forum/dark/default_avatar.png

Thanks so much on reply Melvin3d,

Yes, I came across using code: lFace = FBCharacterFace(’Myface’)

but let’s say I used that line, created character face ‘Myface’, saved scene and left motionbuilder. If I open motionbuilder again and try to use any attribute within lFace, such as lFace.ActiveInput=True, motionbuilder doesn’t hold ‘Myface’ in variable ‘lface’ anymore, because lFace was cleared out from memory. If I was to recreate lFace again to alter Myface (which is still in the scene), using the code: lFace = FBCharacterFace(’Myface’),
motionbuilder will create ‘Myface 2’ node instead making instance of ‘Myface’ node.

Author: Laudor

Replied: 01 August 2011 03:29 AM  
/img/forum/dark/default_avatar.png

I assume that characterFace shouldn’t be created from scratch every time we want to use it in motionbuilder. I find it difficult to understand why there isn’t ‘.CurrentCharacterFace’ attribute, like there is ‘.CurrentCharacter’ or ‘.CurrentActor’ attribute within FBApplication class, it would have made instancing of the current characterFace so easy :)

Author: Laudor

Replied: 01 August 2011 03:29 AM  
avatar
  • melvin3d
  • Posted: 02 August 2011 01:45 PM

Hey,
i understand what you’re saying ..but that’s where the basic programming kicks in.
In order to run the same code on a scene after you close Mobu, you have to do few steps that “checks” the existence of your character face in the scene..
So the pseudo would be :
assuming you just opened your old scene or scene from last night.

1: Check my scene if there are any character faces in the scene
2: If so , get the names
3: If any of the character faces matches my face.Name, then do something to it

So knowing that you should be able to get your face every time you open your scene.
New or old , its all based on searching your scene and finding the correct model.
Simple function example.

I hope that helps…
Good luck.

melvin3d



Attachment Attachment
Replies: 1
/img/forum/dark/default_avatar.png

Thank you Melvin3d,

Simple and beautiful function :D
Operates perfectly!

You are God,

Laudor

Author: Laudor

Replied: 03 August 2011 03:03 PM