Tasks/RePrefixAllMarkers.py

Tasks/RePrefixAllMarkers.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 # Topic: FBPopupInputType, FBComponent.ClassName
7 #
8 
9 from pyfbsdk import *
10 
11 gScene = FBSystem().Scene
12 
13 # Get the substring that we want to use as a prefix.
14 (lRes, lPrefix ) = FBMessageBoxGetUserValue( "Enter new Prefix", "Enter new prefix for markers: ", "", FBPopupInputType.kFBPopupString, "OK", "Cancel" )
15 
16 # Insure that the user entered a string and selected "Ok".
17 if lRes == 1 and lPrefix and len( lPrefix ) > 0:
18 
19  # Look at all the elements in the scene.
20  for lComponent in FBSystem().Scene.Components:
21 
22  # We want to apply this prefix only to regular markers...
23  # not optical markers.
24  if lComponent and lComponent.ClassName() == "FBModelMarker":
25 
26  # We will change the name only on objects that do not already
27  # have the desired prefix.
28  if lComponent.OwnerNamespace == None or lComponent.OwnerNamespace.Name != lPrefix :
29  lComponent.LongName = "%s:%s"%(lPrefix, lComponent.Name)
30 
31  # Cleanup loop variables.
32  del( lComponent )
33 
34 # Cleanup Namespace.
35 gScene.NamespaceCleanup()
36 
37 # Cleanup local variables.
38 del( lRes, lPrefix )
39 
40 # Cleanup things from pyfbsdk
41 del( FBSystem, FBMessageBoxGetUserValue, FBPopupInputType )