Quantcast
Channel: MotionBuilder Python topics
Viewing all 41 articles
Browse latest View live

How to get selected vertex?

$
0
0

I'd like to get selected vertex in MB2015.

So I do these sequence.

1. Show Skins window

2. Select model and Alt+D&D to Skin window

3. Switch vertex mode and select vertex in Viewer window

4. Execute my script.

But my script can't get selected vertex.

Here is my script.

 

 

from pyfbsdk import *

## get model & geometry
lMdls = FBModelList()
FBGetSelectedModels(lMdls)
lMdl = lMdls[0]
lGeo = lMdl.Geometry

## get selected vertex
for i in range(lGeo.VertexCount()):
  print i, lGeo.VertexGetSelected(i)  

Please tell me what is mistaken in my script and resolution.

 


connect timecode to joint

$
0
0

 

I have added a TimeCode attribute to a joint, using:

 

trackerAttr = comp.PropertyCreate(attrName, FBPropertyType.kFBPT_charptr, "TimeCode", False, True, None)

 

What is the best way to now link this to the timecode coming in from an LTC device?

 

Thanks!

Story track record path in python

$
0
0

Hi, I am creating story character tracks in python, and need to record to disk. Problem is, I can't get the record path to stick. If I use:

 

 

for char in characterList:
                lTrackChar = FBStoryTrack(FBStoryTrackType.kFBStoryTrackCharacter, FBStory().RootEditFolder)
                lTrackChar.Character = char
                lTrackChar.Label = char.LongName
                lTrackChar.RecordClipPath == 'C:\Users\Documents\mobuTemp'
                lTrackChar.RecordTrack == True
                print lTrackChar.RecordClipPath

 

the print will print the path as I have entered it, but if i open the recording options, the path is empty. How can I add the path and switch recording on for a story track?

 

Thanks!

Creating a property reference from FBReferenceTime?

$
0
0

I have figured out how to query the currently displayed timecode in the transport panel:

 

refTime = FBReferenceTime()
t = refTime.GetTime(refTime.ItemIndex, FBSystem().SystemTime)
t.ShowAsTimecode = True
timecode_ref = t.GetTimeString()

 

Using this value, how can I attach the timecode to a property reference?

 

prop = destNode.PropertyCreate( sourceNode.Name, FBPropertyType.kFBPT_Reference, '', True, True, refProp )

 will not work, as I don't know what to give as the sourceNode.Name...

 

Thanks!

 

 

Problems with online documentation for MoBu 2014

Help!!! pyfbsdk

$
0
0

ok i am a noob to motion builder but trying to automate couple of stuff but tried a lot dint get it so i am here 

 

1 under character control window i want to change character and the source option using pyfbsdk 

 

for example 

 

1 FBApplication().CurrentCharacter == 0

FBApplication().CurrentCharacter =="object_3"

 

ps: not creating new just trying to choose diffrent one 

 

and for source 

src=FBApplication().CurrentCharacter

1 src.ActiveInput == 0

2 src.ActiveInput == 3

 

and not able to figure out what is the problem any help would be very helpfull warm regards 

sumanth

Constraint property 'Zero' in python

$
0
0

Hi, I am creating a series of constraints in python, with:

 

 

            lConstraint = consManager.TypeCreateConstraint(3)
            lConstraint.Name = 'tmp_constraint'
            lConstraint.ReferenceAdd(0,markerTmp)
            lConstraint.ReferenceAdd(1,cam)
            lConstraint.Active = False
            lConstraint.Snap()

 

How can I switch on the'Zero' Property?? ie, the button next to 'Snap', with code?

 

I can't find it mentioned at all in the docs..

 

Thanks!

Python - Story Video Track applied to Video plane

$
0
0

 Hey,

 

I am trying to apply a Story Video Track to be a material on a video plane. This is to allow easy offsetting/trimming of the video using the clip in story mode.

I have managed to create the Video Track, import a video and create the plane but I can't seem to work out how I apply this track to the plane. At the bottom of the following script I've been trying to create textures and materials to use this Video Track somehow. The problem is I can't seem to aplly the video track to anything.

 

Any help would be much appreciated.

 

# Create a video story track
FRVideoTrack = FBStoryTrack(FBStoryTrackType.kFBStoryTrackVideo)
FRVideoTrack.Label = 'MyVideoTrack'

# Create a video clip
FRPath = os.path.join("C:\Video\Test.mov")
FRPath = os.path.normpath(FRPath)
FRVideo = FBVideoClip(FRPath)

# Use this video clip to create a video story clip on the video track
FRClip = FBStoryClip (FRTexture, FRVideoTrack, FBTime(0,0,0,0))

# Create the Plane.
VideoPlane = FBModelPlane('My_Plane')
VideoPlane.Visible = True
VideoPlane.Show = True

# VideoPlane.SetVector( FBVector3d( 50, 50, 50 ) )
VideoPlane.SetVector( FBVector3d( 0.2, 1, 0.3 ), FBModelTransformationType.kModelScaling )
VideoPlane.SetVector( FBVector3d( 90, 0, 0 ), FBModelTransformationType.kModelRotation )

# Create a texture
FRTexture = FBTexture('My_Texture')
FRTexture.Video = FRVideo

# Create a material
FRMaterial = FBMaterial("My_Material")

# Set texture to material's diffuse channel.
FRMaterial.SetTexture(FRTexture, FBMaterialTextureType.kFBMaterialTextureDiffuse)

# Attach material to plane
MyPlane.Materials.append(FRTexture)

 


Trigger script via relation output.

$
0
0

Hi, I know you can trigger scripts in relations using the Action custom property.

But is there a way to do it without user having to click on a button?

 

For example, I want to turn on/off constraints based on the value of custom property's F-Curve, so a value of 1 would trigger a script to activate a left hand constraint with snap on, a value of 2 turns on the right hand constraint, etc.

 

Thanks!

FBConstraint 'offset' property with python?

$
0
0

Is there a way to access the translation/rotation offset of a constraint via python?

Only the Snap() function is mentioned in the docs, which is only good to set an initial offset.

 

What I want is to key that offset across different takes in a multitake file, so that each take will 'remember' that constraint's offset.

 

'myCons.PropertyList.Find('Offset T').Data' yields no results.

 

Anyone has tried something like this?

 

List (enum) Custom Property: GetAnimationNode??

$
0
0

I have a marker with some List (enum) custom properties.

When animated, the f curve has values that reflect the order of enumeration of the list items.

If the property is animatable, how come I cannot get to the animation node?

 

Other custom properites (i.e type Number) give acces to the animation node no problem, but when I try with the List I get:

 

AttributeError: 'int' object has no attribute 'GetAnimationNode'

 

I would like to access the times and values of that prop's Fcurve, how can I do that for a list property?

piping values into a script device?

$
0
0

Hey all, is it possible to send values into a script device inside a relation constraint? Eg:If I load the below script into a script device and add it as a reciever in a relation constraint, how can I send in the value that will be the 'sentValue' variable?

 

Thanks!

 

mTwo = FBFindModelByLabelName('Translation')
marker2Trans = mTwo.PropertyList.Find('Lcl Translation')

marker2Trans[0] = sentValue

2014, FBProgress is broken, won't exit

$
0
0

I'm noticing some issues when utilizing FBProgress. You can't end out of ProgressBegin.

 

This doesn't do anything in 2014, but works in 2012:

lFbp.ProgressDone()

yourProgressBar.ProgressDone()

 

Can anyone else confirm this?

 

justHangs.JPG

 

 

lFbp.ProgressDone()lFbp.ProgressDone()

FBFindModelByName() Make Mobu Crashes.

$
0
0

Hello, 

 

       I'am trying to use function FBFindModelByName() after opening a scene with 

FBApplication().FileOpen(filename)

  but it makes my application crashes with no error. If I use :

 

cl = FBComponentList()
FBFindObjectsByName(objName, cl, True, True )

instead it works fine.

 

Anyone has an idea of what is happening here?

 

thx for your help. 

Retrieving clip information from the Shot Track

$
0
0

Hello,

I am currently trying to pull out information from Shot Track clips (Story equivalent of the Camera Switcher) and can't find a way to do this. I can pull out the clip number, and start and end frames, but not the content/camera that is used for a given clip inside the Shot Track.



New Facial Animation Python Script

FBInterpolateRotation for quaternions

$
0
0

Does anybody know if the method

void 	FBInterpolateRotation (FBQuaternion &pQOut, const FBQuaternion &pQ0, const FBQuaternion &pQ1, double pU)

is the implementation of Slerp?

The MoBu documentation is so vague sometimes.

Selecting a texture?

$
0
0

Hello, I am pretty new to Python in Motionbuilder.  I can't seem to figure this out, so any help is appreciated...  trying to select the texture node attached to the material node so that I can then key the Translation attributes....  

 

 

# Select some models
lModelList = FBModelList()
FBGetSelectedModels(lModelList)

for lModel in lModelList:
    print "Geo is", lModel.Name
    lTextures = []
    lMaterials = []

    for i in range(lModel.GetSrcCount()):
        lConnection = lModel.GetSrc(i)
        
        if lConnection.ClassName() == 'FBMaterial':
            lMaterials .append(lConnection)
            print "Material is", lConnection.Name

    for m in lMaterials:
        for j in range(m.GetSrcCount()):
            lConnection = m.GetDstCount(j)
   
            if lConnection.ClassName() == 'FBTexture':
                       ......
            if lConnection.ClassName() == 'FBVideoClip':
                      .........

 

Creating / error handling a Shot Track

$
0
0

Looking at the code sample "ShotTrackSetupTool.py", it uses the following code:

 #In Story you need to create the clips
lTrackContainer = FBStory().RootEditFolder.Tracks
lastTrack=0
lTrack=None
lTakeIdx=[]
for Track in lTrackContainer:
    if Track.Label =="Shot Track":
        lTrack=Track
clipStart = FBTime(0,0,0,0)


As read, this executes fine IF you already have a Story Track / Shot Track called "Shot Track".

I wanted to add error handling for when it *doesn't* exist or removing all Shot Tracks *not* named "Shot Track"; forcing the tracks to be just on one track.

Tried:

        Track = FBStoryTrack(FBStoryTrackType.kFBStoryTrackShot)
        Track.Label = "Shot Track"
        lTrack=Track

But no effect.

I guess I could put :

lTrackContainer = FBStory().RootEditFolder.Tracks
Track = FBStoryTrack(FBStoryTrackType.kFBStoryTrackShot)
Track.Label = "Shot Track"


Before the for... loop but this feels inelegant somehow.

 

'FBTake' object has no attribute 'PlotAllTakesOnProperties'

$
0
0

Hi everyone, I'm trying to do a "Plot All (All Properties)" in my scene, using python.

I found in the documentation the function that should fit my needs : PlotAllTakesOnProperties()

But this function appeared in the 2015 version of MotionBuilder and i'm using the 2013 version.

Does anyone know some work around to get the same result using the 2013 version?

I can use the PlotAllTakesOnSelectedProperties() method but i don't really know how to select my properties.

Viewing all 41 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>