# Copyright 2009 Autodesk, Inc.  All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement 
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.
#
# Topic: FBPopupInputType, FBComponent.ClassName
#

from pyfbsdk import FBSystem, FBMessageBoxGetUserValue, FBPopupInputType

# Get the substring that we want to use as a prefix.
(lRes, lPrefix ) = FBMessageBoxGetUserValue( "Enter new Prefix", "Enter new prefix for markers: ", "", FBPopupInputType.kFBPopupString, "OK", "Cancel" )

# Insure that the user entered a string and selected "Ok".
if lRes == 1 and lPrefix and len( lPrefix ) > 0:

    # Look at all the elements in the scene.
    for lComponent in FBSystem().Scene.Components:

        # We want to apply this prefix only to regular markers...
        # not optical markers.
        if lComponent and lComponent.ClassName() == "FBModelMarker":

            # We will change the name only on objects that do not already
            # have the desired prefix.
            if not lComponent.Name.startswith( lPrefix ):
                lComponent.Name = "%s:%s"%(lPrefix, lComponent.Name)

    # Cleanup loop variables.
    del( lComponent )


# Cleanup local variables.
del( lRes, lPrefix )

# Cleanup things from pyfbsdk
del( FBSystem, FBMessageBoxGetUserValue, FBPopupInputType )