Samples/Properties/PropertyViewManager.py

Samples/Properties/PropertyViewManager.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 to create new Property View
8 #
9 # Topic: FBPropertyViewManager
10 #
11 from pyfbsdk import *
12 
13 # This function finds property in pOwner property list and add it under given pHierarchy in pViewList
14 # pSetOpen will open whole hierarchy
15 def AddPropertyToViewList(pOwner, pPropertyName, pViewList, pHierarchy, pSetOpen=False):
16  lProperty = pOwner.PropertyList.Find(pPropertyName)
17  lView = pViewList.AddPropertyView(lProperty, pHierarchy)
18 
19  if pSetOpen:
20  lView.SetOpen(pSetOpen,True)
21 
22  return lView
23 
24 #################################
25 
26 # Create new object for which we will create local(by object) property view
27 lModel = FBModelNull('ObjectWithLocalPropertyView')
28 
29 # Make model visible in the viewer
30 lModel.Show = True
31 
32 # Get property view manager
33 lMgr = FBPropertyViewManager()
34 
35 # Create local(by object) property view called 'PythonCreatedView'
36 lViewList = lMgr.CreatePropertyList(lModel, FBPropertyViewType.kFBViewByObject, 'PythonCreatedView')
37 # Add 'Show' property under 'Visibility Options' node
38 AddPropertyToViewList(lModel, 'Show', lViewList, 'Visibility Options')
39 # Add 'Visibility' property under 'Visibility Options' node
40 AddPropertyToViewList(lModel, 'Visibility', lViewList, 'Visibility Options')
41 # Here we add 'Visibility Inheritance' under 'Visibility' which is under 'Visibility Options' node
42 AddPropertyToViewList(lModel, 'Visibility Inheritance', lViewList, 'Visibility Options.Visibility', True)
43 
44 # Same this as above, adding properties under 'Transformation Options'
45 AddPropertyToViewList(lModel, 'Translation (Lcl)', lViewList, 'Transformation Options')
46 AddPropertyToViewList(lModel, 'Rotation (Lcl)', lViewList, 'Transformation Options')
47 AddPropertyToViewList(lModel, 'Scaling (Lcl)', lViewList, 'Transformation Options')
48 AddPropertyToViewList(lModel, 'Quaternion Rotation', lViewList, 'Transformation Options')
49 
50 # Select model to see our new property view in Properties tool
51 lModel.Selected = True
52 
53 # In this case we don't have to refresh, but if you update already existing View, you should do it.
54 lMgr.RefreshPropertyViews()