Python Reference Guide
 
Loading...
Searching...
No Matches
Tasks\TraversingRelationConstraint.py
1# Copyright 2010 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# This sample shows you how to traverse animation node connections in a relation constraint.
8#
9# Sample scene file this script works with: traversingRelationConstraint.fbx
10#
11# Topic: FBConstraintRelation, FBAnimationNode
12
13from pyfbsdk import *
14
15lCons = FBSystem().Scene.Constraints
16#Going through the constraints in the scene
17print("********************************************")
18print("***These are the constraints in the scene***")
19print("********************************************")
20for lCon in lCons:
21 print("Constraint Name ->", lCon.Name)
22 print(" Constraint Type ->", lCon.FbxGetObjectType() )
23 print(" Constraint Sub Type ->", lCon.FbxGetObjectSubType() )
24
25print
26for lCon in lCons:
27 if lCon.Is( FBConstraintRelation_TypeInfo() ):
28 print("*************************************************")
29 print("***These are the %d boxes in the %s Constraint***" % (len(lCon.Boxes), lCon.Name))
30 print("*************************************************")
31 for lBox in lCon.Boxes:
32 lOut = 0
33 lIn = 0
34 lAnimationNodesOUT = lBox.AnimationNodeOutGet().Nodes
35 for lAnimationNode in lAnimationNodesOUT:
36 for i in range(lAnimationNode.GetDstCount()):
37 if lAnimationNode.GetDst(0) != None:
38 #Workaround for why it's printing in nodes that aren't connected
39 if not lAnimationNode.GetDst(i).GetOwner().Name.startswith("Relation"):
40 lOut = 1
41 #IN Animation Nodes
42 lAnimationNodesIN = lBox.AnimationNodeInGet().Nodes
43 for lAnimationNode in lAnimationNodesIN:
44 for i in range(lAnimationNode.GetSrcCount()):
45 if lAnimationNode.GetSrc(0) != None:
46 lIn = 1
47 if lOut == 0 and lIn == 1:
48 print("%s is a Receiver Box of type: %s, of sub type: %s" %( lBox.Name, lBox.FbxGetObjectType(), lBox.FbxGetObjectSubType() ) )
49 elif lOut == 1 and lIn == 0:
50 print("%s is a Sender Box of type: %s, of sub type: %s" %( lBox.Name, lBox.FbxGetObjectType(), lBox.FbxGetObjectSubType() ) )
51 else:
52 print("%s is a Function (operator) Box of type: %s, of sub type: %s" %( lBox.Name, lBox.FbxGetObjectType(), lBox.FbxGetObjectSubType() ) )
53 print()
54 print("**********************************************************************")
55 print("***These are the connections between the boxes in the %s Constraint***" % lCon.Name)
56 print("**********************************************************************")
57 for lBox in lCon.Boxes:
58 print("-------%s Box connected Animation Nodes-------" % lBox.Name)
59 #OUT Animation Nodes
60 #looks like we have an issue with Out Animation Nodes, I think it prints in nodes too :(
61 lAnimationNodesOUT = lBox.AnimationNodeOutGet().Nodes
62
63 for lAnimationNode in lAnimationNodesOUT:
64 for i in range(lAnimationNode.GetDstCount()):
65 if lAnimationNode.GetDst(0) != None:
66 #Workaround for why it's printing in nodes that aren't connected
67 if not lAnimationNode.GetDst(i).GetOwner().Name.startswith("Relation"):
68 print("OUT: %s (%s) > %s (%s) " % (lBox.Name, lAnimationNode.UserName, lAnimationNode.GetDst(i).GetOwner().Name, lAnimationNode.GetDst(i).UserName))
69
70 #IN Animation Nodes
71 lAnimationNodesIN = lBox.AnimationNodeInGet().Nodes
72 for lAnimationNode in lAnimationNodesIN:
73 for i in range(lAnimationNode.GetSrcCount()):
74 if lAnimationNode.GetSrc(0) != None:
75 print("IN: %s (%s) > %s (%s) " % (lBox.Name, lAnimationNode.UserName, lAnimationNode.GetSrc(0).GetOwner().Name, lAnimationNode.GetSrc(0).UserName))
76 print()
77
78
79
80
Provides access to the underlying system, and the MotionBuilder scene.
Definition: pyfbsdk_generated.h:18837