Python Reference Guide
 
Loading...
Searching...
No Matches
BasicOperations\RigiBody.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# Change the PhysicalProperties (RigiBody) of all selected models.
8#
9# Topic: FBPhysicalProperties
10#
11
12from pyfbsdk import *
13
14def ListObjectProperties(o):
15 print("ObjectName: " + o.Name)
16 for each in o.PropertyList:
17 print(each.Name + " ")
18
19def ChangeRigidBody (obj, propertyName, newValue):
20 for i in range (obj.GetSrcCount()):
21 o = obj.GetSrc(i)
22 if isinstance(o, FBPhysicalProperties):
23 p = o.PropertyList.Find(propertyName)
24 if p:
25 p.Data = newValue
26
27def SetRigidBodyState():
28
29 lModelList = FBModelList()
30
31 # Get the selected models.
32 FBGetSelectedModels( lModelList )
33
34 if len( lModelList ) == 0:
35 FBMessageBox( "Message", "Nothing selected", "OK", None, None )
36 else:
37 for each in lModelList:
38 ChangeRigidBody ( each, "Bounce", 0.1 )
39 ChangeRigidBody ( each, "Density", 0.5 )
40
41 lMessage = "Models modified:"
42 lMessage += ''.join( map( lambda pModel: "\n" + pModel.Name, lModelList ))
43 FBMessageBox( "Message", lMessage, "OK", None, None )
44
45SetRigidBodyState()
FBGetSelectedModels(FBModelList pList, FBModel pParent=None, bool pSelected=True, bool pSortBySelectOrder=False)
Find all models that are selected (if pSelected is true) Searches recursively from a root model for m...
int FBMessageBox(str pBoxTitle, str pMessage, str pButton1Str, str pButton2Str=None, str pButton3Str=None, int pDefaultButton=0, int pScrolledMessage=0)
Dialog popup box.