BasicOperations/FBGroup.py

BasicOperations/FBGroup.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 # Create and edit Groups of cube
8 #
9 # Topic: FBModelCube, FBGroup, FBNamespaceAction
10 #
11 
12 from pyfbsdk import FBModelCube, FBSystem, FBGroup, FBNamespaceAction
13 
14 # Setting up a test scene
15 cube1 = FBModelCube ("Cube 1")
16 cube1.Show = True
17 cube2 = FBModelCube ("Cube 2")
18 cube2.Show = True
19 cube3 = FBModelCube ("Cube 3")
20 cube3.Show = True
21 cube4 = FBModelCube ("Cube 4")
22 cube4.Show = True
23 cube5 = FBModelCube ("Cube 5")
24 cube5.Show = True
25 cube6 = FBModelCube ("Cube 6")
26 cube6.Show = True
27 
28 # Creating the groups
29 
30 # Creating Group One, which contains one cube
31 lGroup1 = FBGroup ("OneCubeGroup")
32 # Adding the object to the group
33 lGroup1.ConnectSrc( cube1 )
34 
35 # Setting the attributes
36 lGroup1.Show = True
37 lGroup1.Pickable = False
38 lGroup1.Transformable = False
39 
40 # Creating Group Two, which contains two cubes
41 lGroup2 = FBGroup ("TwoCubeGroup")
42 
43 # Adding the objects to the group
44 lGroup2.ConnectSrc( cube2 )
45 lGroup2.ConnectSrc( cube3 )
46 
47 # Setting the attributes
48 lGroup2.Show = True
49 lGroup2.Pickable = True
50 lGroup2.Transformable = False
51 
52 # Creating Group Three, which contains three cubes
53 lGroup3 = FBGroup ("ThreeCubeGroup")
54 
55 # Adding the objects to the group
56 lGroup3.ConnectSrc( cube4 )
57 lGroup3.ConnectSrc( cube5 )
58 lGroup3.ConnectSrc( cube6 )
59 
60 # Setting the attributes
61 lGroup3.Show = True
62 lGroup3.Pickable = True
63 lGroup3.Transformable = True
64 
65 # One thing to note is normally you would use the items property to add objects
66 # to the group however within Python this attribute is a Tuple so you cannot add
67 # items to it, this is why we are using FBPlug methods to add items.
68 
69 # This is how you remove objects from the group, commented out so user can see the groups in the Viewer
70 #lGroup1.DisconnectSrc( cube1 )
71 #lGroup2.DisconnectSrc( cube2 )
72 #lGroup2.DisconnectSrc( cube3 )
73 #lGroup3.DisconnectSrc( cube4 )
74 #lGroup3.DisconnectSrc( cube5 )
75 #lGroup3.DisconnectSrc( cube6 )
76 
77 # Clean-up
78 del(FBModelCube, FBSystem, FBGroup, FBNamespaceAction, cube1, cube2, cube3, cube4, cube5, cube6, lGroup1, lGroup2, lGroup3)