BasicOperations/LockProperty.py

BasicOperations/LockProperty.py
1 # Copyright 2012 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 how locked properties can be used.
8 #
9 
10 from pyfbsdk import *
11 
12 # Create a simple cube on which properties will be manipulated.
13 cube = FBModelCube( "Cube" )
14 cube.Show = True
15 
16 # Get the scaling property which we will manipulate.
17 scaling = cube.PropertyList.Find( 'Lcl Scaling' )
18 scaling.Data = FBVector3d( 2 , 2 , 2 )
19 print "After setting to (2,2,2) : " + str(scaling.Data)
20 
21 # Lock the property and change it.
22 scaling.SetLocked( True )
23 scaling.Data = FBVector3d( 3 , 3 , 3 )
24 print "After locking and setting to (3,3,3) : " + str(scaling.Data)
25 
26 # Query to check if the property is locked.
27 print "Is the property locked : " + str(scaling.IsLocked())
28 
29 # Unlock the property and change it.
30 scaling.SetLocked( False )
31 scaling.Data = FBVector3d( 4 , 4 , 4 )
32 print "After unlocking and setting to (4,4,4) : " + str(scaling.Data)
33 
34 # Query to check if the property is locked.
35 print "Is the property locked : " + str(scaling.IsLocked())
36 
37 # Lock Y and change the whole property.
38 scaling.SetMemberLocked( 1 , True )
39 scaling.Data = FBVector3d( 5 , 5 , 5 )
40 print "After locking Y and setting to (5,5,5) : " + str(scaling.Data)
41 
42 # Query to check if members are locked.
43 print "Is X locked : " + str(scaling.IsMemberLocked( 0 ))
44 print "Is Y locked : " + str(scaling.IsMemberLocked( 1 ))
45 print "Is Z locked : " + str(scaling.IsMemberLocked( 2 ))
46 
47 # Unlock Y and change the whole property.
48 scaling.SetMemberLocked( 1 , False )
49 scaling.Data = FBVector3d( 6 , 6 , 6 )
50 print "After unlocking Y and setting to (6,6,6) : " + str(scaling.Data)
51 
52 # Clean-up
53 del( cube )