import Blender from Blender import Window, Draw, Registry from os import mkdir scriptname = "newproject" docache = True blendfile = "Base.blend" # Add the current project to the list of previously created projects def UpdateRegistry(projectpath): scriptdata = Registry.GetKey(scriptname, docache) scriptdata['past'].append(projectpath) Registry.SetKey(scriptname, scriptdata, docache) # Save a default blender file in the new projects directory def SaveBlenderFile(projectpath): filepath = projectpath + blendfile print "\t1. Saving Blender file %s" % (filepath) Blender.Save(filepath, 1) return filepath # Create sub-directories inside the projects directory for organizing data def CreateProjectDirectoryTree(projectpath): dirs2make = ["images", "temp", "ref", "doc", "final"] print "\t2. Creating sub-directories:" for dir in dirs2make: path = projectpath + dir print "\t\t %s" % (path) mkdir(path) # On setting a new project, the FileSelector calls this function def NewProject(projectpath): print "Creating new project %s" % (projectpath) filepath = SaveBlenderFile(projectpath) CreateProjectDirectoryTree(projectpath) UpdateRegistry(projectpath) Blender.Load(filepath) # This script stores inforamtion in a config file for later introspection if not Registry.GetKey(scriptname, docache): scriptdata = {} scriptdata['past'] = [] Registry.SetKey(scriptname, scriptdata, docache) # Open the file selector so that the user can create a new project # The project directory is created by the FileSelector itself. # The script creates the project sub-directories Window.FileSelector (NewProject, "Create New Project")