Version Control is an important feature for a team to work together, and Motionbuilder has its own version control manager that uses simplified versions of the Perforce and Microsoft Visual SourceSafe version control software products.
But, how to set it up? How to use the provided API to operate with version control? There are very few information about this, but recently, I spent some time on this, and in what follows I will talk about how to set it up and how to use these API to help you get started.
How to set it up? Let’s use Perforce as example, here are 4 steps:
- Install Perforce if you do not have, and open it, connect to a server with a specified workspace.
- Open the file \\MyDocuments\MB\2017-x64\config\*.Application.txt, and add following:
[Version Control] AskOnStartup = Yes CurrentManager = Perforce Enabled = Yes
- Open the file \\MyDocuments\MB\2017-x64\config\*.Perforce.txt, and add following, please make sure to change the User and Workspace to the one you used in P4:
[Perforce] CheckOutOnLoad = ASK UploadOnSave = ASK AddOnNewSave = ASK CheckInOnClose = ASK User = MY_USERNAME Workspace = MY_WORKSPACE
- Run Motionbuilder, you should see a “Version Control” Menu as following picture.
Until now, everything should be all set, and you can use the integrated version control menu to work on FBX file with Perforce.
But, how I can use the API to work with version control tools? Within Motionbuilder, it provides 4 classes:
FBAssetMng is used to access asset manager functionity to get files locally or from a server. You cannot instance this class because it’s a virtual class, instead, you can get it from FBSystem().AssetManager if there is already an asset manager set up. When you get the asset manager, you can use the following method to get the folder or file:
Here is a simple example to use these methods, please make sure using “/” instead of “\”:
srvPath = "//depot/mytest/ test.fbx" localPath = "C:/mytest/test.fbx" asset_mgn = FBSystem().AssetManager asset_file1 = asset_mgn.GetAssetFileFromLocalPath(localPath) asset_file2 = asset_mgn.GetAssetFile(srvPath)
Or you can use BrowseForFile() to browser a FBX file.
When you got a folder or file, you can do a couple of operations per your request, usually, the following methods are often used:
These methods are pretty straightforward, please refer the API help doc for each of these methods if you are interested.
You can follow this conversation by subscribing to the comment feed for this post.