BasicOperations/FBClusterTransactions.py

BasicOperations/FBClusterTransactions.py
1 # Copyright 2009 Autodesk, Inc. All rights reserved.
2 # Use of this software is subject to the terms of the Autodesk license agreement
3 # provided at the time of installation or download, or which otherwise accompanies
4 # this software in either electronic or hard copy form.
5 #
6 # Script description:
7 # Shows you how to access the cluster and cluster index, while using the cluster
8 # transactions.
9 #
10 # Sample scene file this script works with: FBClusterTransactions.fbx
11 #
12 # Topic: FBCluster
13 #
14 
15 from pyfbsdk import *
16 import os
17 import os.path
18 
19 
20 gApp = FBApplication()
21 gSys = FBSystem()
22 
23 gApp.FileNew()
24 
25 lFilePath = os.path.abspath( os.path.join( gSys.ApplicationPath, r"..\config\FBClusterTransactions.fbx"))
26 print "Source File Path", lFilePath
27 
28 gApp.FileOpen(lFilePath)
29 
30 lSphere = FBFindModelByLabelName("pSphere1")
31 
32 if lSphere:
33  skinCluster = FBCluster(lSphere)
34  print skinCluster.Name
35 
36  if skinCluster and skinCluster.LinkGetCount():
37  for n in range (skinCluster.LinkGetCount()):
38  skinCluster.ClusterBegin(n) # Set the current cluster index
39  linkName = skinCluster.LinkGetName(n)
40  linkModel = skinCluster.LinkGetModel(n)
41  numVerts = skinCluster.VertexGetCount() # Using the current cluster index
42  print numVerts
43  for v in range (numVerts):
44  vertIndex = skinCluster.VertexGetNumber(v) # Using the current cluster index
45  vertWeight = skinCluster.VertexGetWeight(v) # Using the current cluster index
46  print "For Vertex Index %d, the weight is %d" % (vertIndex, vertWeight)
47  skinCluster.ClusterEnd()
48 
49 
50 
51 
52