def SaveConfigData(key=None): """ Save Registry key(s) as file(s) in the <(u)datadir>/config/ folder. @type key: string @param key: the name of the key to be saved. If None (default) all available keys are saved. """ global _KEYS, _CFG_DIR _check_dir() if key: keys = [key] else: keys = _KEYS for mainkey in keys: cfgdict = Registry.GetKey(mainkey).copy() for k in cfgdict: # .keys() if not k or k[0] == '_': del cfgdict[k] if not cfgdict: continue try: filename = bsys.join(_CFG_DIR, "%s%s" % (mainkey, _EXT)) f = file(filename, 'w') output = _dict_to_str(mainkey, _sanitize(cfgdict)) if output != 'None': f.write(output) f.close() except Exception, e: raise Warning(e) # Resend exception as warning
def load(self): """Load settings from registry, if available. """ settingsDict = Registry.GetKey('b2rex', True) if settingsDict: for prop in ['Objects', 'Textures', 'Materials', 'Meshes']: keyName = 'regen' + prop if settingsDict.has_key(keyName): setattr(self, keyName, settingsDict[keyName]) for prop in self.properties: if settingsDict.has_key(prop): setattr(self, prop, settingsDict[prop]) if self.server_url and self.username: self.username, self.password = self.credentials.get_credentials( self.server_url, self.username) if settingsDict.has_key('locX'): try: self.locX.setValue(float(settingsDict['locX'])) except TypeError: pass if settingsDict.has_key('locY'): try: self.locY.setValue(float(settingsDict['locY'])) except TypeError: pass if settingsDict.has_key('locZ'): try: self.locZ.setValue(float(settingsDict['locZ'])) except TypeError: pass
def load(self): """Load settings from registry, if available. """ ExportSettings.load(self) settingsDict = Registry.GetKey('b2rex_char', True) if settingsDict: for prop in self._properties: setattr(self, prop, settingsDict[prop])
def load_from_registry(): d = Registry.GetKey('vrml97_export', True) if d: try: export_selection_only.val = d['selection_only'] export_rotate_z_to_y.val = d['rotate_z_to_y'] export_compressed.val = d['compressed'] except: save_to_registry() # If data is not valid, rewrite it.
def __init__(self, key, has_group=True): global DISK_UPDATE self.key = key self.has_group = has_group self.name = key self.fromdisk = HasConfigData(key) & BPY_KEY_IN_FILE if not self.fromdisk: DISK_UPDATE = False else: DISK_UPDATE = True self.origdata = Registry.GetKey(key, True) data = self.data = self.origdata.copy() if not data: Draw.PupMenu('ERROR: couldn\'t find requested data') self.data = None return keys = data.keys() nd = {} for k in keys: nd[k.lower()] = k if nd.has_key('tooltips'): ndval = nd['tooltips'] self.tips = data[ndval] data.pop(ndval) else: self.tips = 0 if nd.has_key('limits'): ndval = nd['limits'] self.limits = data[ndval] data.pop(ndval) else: self.limits = 0 if self.has_group: scriptname = key if not scriptname.endswith('.py'): scriptname = "%s.py" % scriptname elif nd.has_key('script'): ndval = nd['script'] scriptname = data[ndval] data.pop(ndval) if not scriptname.endswith('.py'): scriptname = "%s.py" % scriptname else: scriptname = None self.scriptname = scriptname self.sort()
def LoadPath(): R = Registry.GetKey('Chicken', True) error = True if R: try: binPath = R['PandaBinPath'] except KeyError: pass else: error = False if error: binPath = '' return binPath
def readDataFromRegistry(): """ Reads data from the Blender registry. """ global G dict = Registry.GetKey('TsaiCC') if dict: G.coordmap = dict['coordmap'] removeUnknownsFromCoords() # TODO: try: loadImage(dict['imagename']) except KeyError: pass
def registry_import(): global KEX_FILE global ENABLE_KEX global ENABLE_SUP global ENABLE_BETA d = Registry.GetKey('export_3ds2kex', True) if d: try: KEX_FILE = d['KEX_FILE'] ENABLE_KEX = d['ENABLE_KEX'] ENABLE_SUP = d['ENABLE_SUP'] except: registry_update() try: ENABLE_BETA = d['ENABLE_BETA'] except: registry_update() else: registry_update()
d['MIRCOL_AS_AMB'] = MIRCOL_AS_AMB d['MIRCOL_AS_EMIS'] = MIRCOL_AS_EMIS d['ADD_DEFAULT_MAT'] = ADD_DEFAULT_MAT d['SET_TEX_DIR'] = SET_TEX_DIR d['TEX_DIR'] = TEX_DIR d['AC3D_4'] = AC3D_4 d['NO_SPLIT'] = NO_SPLIT d['EXPORT_DIR'] = EXPORT_DIR d['ONLY_SELECTED'] = ONLY_SELECTED d['PER_FACE_1_OR_2_SIDED'] = PER_FACE_1_OR_2_SIDED d['tooltips'] = tooltips d['GLOBAL_COORDS'] = GLOBAL_COORDS Registry.SetKey(REG_KEY, d, True) # Looking for a saved key in Blender.Registry dict: rd = Registry.GetKey(REG_KEY, True) if rd: try: AC3D_4 = rd['AC3D_4'] SKIP_DATA = rd['SKIP_DATA'] MIRCOL_AS_AMB = rd['MIRCOL_AS_AMB'] MIRCOL_AS_EMIS = rd['MIRCOL_AS_EMIS'] ADD_DEFAULT_MAT = rd['ADD_DEFAULT_MAT'] SET_TEX_DIR = rd['SET_TEX_DIR'] TEX_DIR = rd['TEX_DIR'] EXPORT_DIR = rd['EXPORT_DIR'] ONLY_SELECTED = rd['ONLY_SELECTED'] NO_SPLIT = rd['NO_SPLIT'] PER_FACE_1_OR_2_SIDED = rd['PER_FACE_1_OR_2_SIDED'] GLOBAL_COORDS = rd['GLOBAL_COORDS']
pen_x = pen_x + button_width + padding Draw.PushButton("OK", OK_CLICKED, pen_x, pen_y, button_width, button_height, "Save Configuration") ############################################################################ # Main Program starts here # ############################################################################ n2logo = 0 logo_size = [0, 0] reg_name = "n2pathconfig" config_data = Registry.GetKey(reg_name, True) if (not config_data): config_data = getDefaults() # Get Window width and height win_size = Window.GetAreaSize() left = 0 top = win_size[1] # Space to leave between buttons padding = 10 home_dir_input = 0 proj_dir_input = 0 dir_assigns = {}
#if self.bone_stack: # bone.parent = self.bone_stack[-1] self.bone_stack.append(bone) def endElement(self, name): if name == 'bone': self.bone_stack.pop() class LindenGenepoolHandler(xml.sax.ContentHandler): def __init__(self, parent): self.parent = parent def startElement(self, name, attrs): if name == 'param': self.parent.avatar_object.getProperty('param ' + attrs['id']).setData(float(attrs['value'])) print 'param ' + attrs['id'], float(attrs['value']) ###################################################################### def start(): if not regdict.has_key('params'): regdict['params'] = {} #build_armature() AvatarBuilder() Registry.SetKey('sl_blender', regdict, True) regdict = Registry.GetKey('sl_blender', True) if not regdict: Window.FileSelector(sl_path_selected, "SL viewer dir") else: start()
def update_registry(): d = { 'EXPORT_MATERIALS': EXPORT_MATERIALS, 'OUTPUT_LANGUAGE': OUTPUT_LANGUAGE, 'USE_TWOSIDED_FLAG': USE_TWOSIDED_FLAG, 'EXPORT_CAMERA': EXPORT_CAMERA, 'STANDALONE': STANDALONE, 'SPE_LINE_COLOR': SPE_LINE_COLOR, 'ONLY_PROPERTIES': ONLY_PROPERTIES, 'EXPORT_GROUPS': EXPORT_GROUPS, } Registry.SetKey(REG_KEY, d, True) # Looking for a saved key in Blender.Registry dict: rd = Registry.GetKey(REG_KEY, True) if rd: try: OUTPUT_LANGUAGE = rd['OUTPUT_LANGUAGE'] EXPORT_MATERIALS = rd['EXPORT_MATERIALS'] USE_TWOSIDED_FLAG = rd['USE_TWOSIDED_FLAG'] EXPORT_CAMERA = rd['EXPORT_CAMERA'] STANDALONE = rd['STANDALONE'] SPE_LINE_COLOR = rd['SPE_LINE_COLOR'] ONLY_PROPERTIES = rd['ONLY_PROPERTIES'] EXPORT_GROUPS = rd['EXPORT_GROUPS'] except KeyError: print "Keyerror" update_registry() else:
exec_line = '' if SCRIPT_INFO.script.userdir: exec_line = bsys.join(Blender.Get('uscriptsdir'), SCRIPT_INFO.script.fname) else: exec_line = bsys.join(Blender.Get('scriptsdir'), SCRIPT_INFO.script.fname) Blender.Run(exec_line) keepon = True FMODE = False # called by Blender.ShowHelp(name) API function ? KEYNAME = '__help_browser' rd = Registry.GetKey(KEYNAME) if rd: rdscript = rd['script'] keepon = False Registry.RemoveKey(KEYNAME) for group in AllGroups: for script in group.get_scripts(): if rdscript == script.fname: parseit = parse_help_info(script) if parseit == True: keepon = True SCREEN = SCRIPT_SCREEN BEVT_LINK = range(20, len(SCRIPT_INFO.d['__url__']) + 20) BEVT_EMAIL = range(50, len(SCRIPT_INFO.d['__email__']) + 50) FMODE = True
from Blender import Window, Scene, Draw from Blender.Window import DrawProgressBar from Blender import Registry def update_Registry(): d = {} d['self'] = self d['epmv'] = epmv #if self.Mols : # if hasattr(self.Mols[0].geomContainer.geoms['cpk'],'obj') : # d['obj'] = self.Mols[0].geomContainer.geoms['cpk'].obj Blender.Registry.SetKey('bmv', d, False) sc=Blender.Scene.GetCurrent() rdict = Registry.GetKey('bmv', False) # True to check on disk also print rdict if rdict and 'self' in rdict.keys() : self = rdict['self'] epmv = rdict['epmv'] if VERBOSE : print "redo" #print self,self.Mols.name if self == None : if VERBOSE : print "self none" epmv = blenderAdaptor(debug=1) self = epmv.mv #self.armObj = None #self.selections=selections update_Registry() else : if VERBOSE :
'confirm_overwrite': 'scripts should always confirm before overwriting files' } CFG_LIST = ['verbose', 'confirm_overwrite', 'tooltips'] KEY_NAME = 'General' def update_registry(): rd = {} for var in CFG_LIST: exec("rd['%s']=%s" % (var, var)) Registry.SetKey(KEY_NAME, rd, True) rd = Registry.GetKey('General', True) if rd: try: for var in CFG_LIST[:-1]: # no need to update tooltips exec("%s=rd['%s']" % (var, var)) except: update_registry() else: update_registry() # --- # script globals: CFGKEY = '' LABELS = [] GD = {} # groups dict (includes "Other" for unmapped keys)
DISPLAY_TRANSP = True SUBDIV = True tooltips = { 'DISPLAY_TRANSP': 'Turn transparency on in the 3d View for objects using materials with alpha < 1.0.', 'SUBDIV': 'Apply a SUBSURF modifier to objects meant to appear subdivided.', 'TEXTURES_DIR': 'Additional folder to look for missing textures.' } def update_registry(): global TEXTURES_DIR, DISPLAY_TRANSP rd = dict([('tooltips', tooltips), ('TEXTURES_DIR', TEXTURES_DIR), ('DISPLAY_TRANSP', DISPLAY_TRANSP), ('SUBDIV', SUBDIV)]) Registry.SetKey('ac3d_import', rd, True) rd = Registry.GetKey('ac3d_import', True) if rd: if 'GROUP' in rd: update_registry() try: TEXTURES_DIR = rd['TEXTURES_DIR'] DISPLAY_TRANSP = rd['DISPLAY_TRANSP'] SUBDIV = rd['SUBDIV'] except: update_registry() else: update_registry() if TEXTURES_DIR: oldtexdir = TEXTURES_DIR if dirsep == '/': TEXTURES_DIR = TEXTURES_DIR.replace('\\', '/')
pen_x = left + padding pen_y = pen_y - button_height - 5 button_width = 80 Draw.PushButton("Close", CANCEL_CLICKED, pen_x, pen_y, button_width, button_height, "Close Exporter") pen_x = pen_x + button_width + padding Draw.PushButton("Export", OK_CLICKED, pen_x, pen_y, button_width, button_height, "Export Scene") file2 = n2.lookup("/sys/servers/file2") reg_name = "n2exportconfig" export_config = Registry.GetKey(reg_name, True) if (not export_config): export_config = GetPrefDefaults() # Get Window width and height win_size = Window.GetAreaSize() left = 0 top = win_size[1] # Space to leave between buttons padding = 10 # Buttons mnu_persist_servers = None mnu_mesh_formats = None
def edit_extern(image=None): if not image: image = Image.GetCurrent() if not image: # Image is None Draw.PupMenu('ERROR: You must select an active Image.') return if image.packed: Draw.PupMenu('ERROR: Image is packed, unpack before editing.') return imageFileName = sys.expandpath(image.filename) if not sys.exists(imageFileName): Draw.PupMenu('ERROR: Image path does not exist.') return pupblock = [imageFileName.split('/')[-1].split('\\')[-1]] new_text = False try: appstring = Registry.GetKey('ExternalImageEditor', True) appstring = appstring['path'] # for ZanQdo if he removed the path from the textbox totaly. ;) - Cam if not appstring or appstring.find('%f') == -1: new_text = True except: new_text = True if new_text: pupblock.append('first time, set path.') if platform == 'win32': appstring = 'start "" /B "%f"' elif platform == 'darwin': appstring = 'open "%f"' else: appstring = 'gimp-remote "%f"' appstring_but = Draw.Create(appstring) save_default_but = Draw.Create(0) pupblock.append( ('editor: ', appstring_but, 0, 48, 'Path to application, %f will be replaced with the image path.')) pupblock.append(('Set Default', save_default_but, 'Store this path in the blender registry.')) # Only configure if Shift is held, if Blender.Window.GetKeyQualifiers() & Blender.Window.Qual.SHIFT: if not Draw.PupBlock('External Image Editor...', pupblock): return appstring = appstring_but.val save_default = save_default_but.val if save_default: Registry.SetKey('ExternalImageEditor', {'path': appstring}, True) if appstring.find('%f') == -1: Draw.PupMenu( 'ERROR: The comment you entered did not contain the filename ("%f")' ) return # ------------------------------- appstring = appstring.replace('%f', imageFileName) print '\tediting image with command "%s"' % appstring os.system(appstring)
def edit_extern(image=None): if not image: image = Image.GetCurrent() if not image: # Image is None Draw.PupMenu('ERROR: Please select active Image.') return if image.packed: Draw.PupMenu('ERROR: Image is packed, unpack before editing.') return imageFileName = sys.expandpath( image.filename ) if not sys.exists(imageFileName): Draw.PupMenu('ERROR: Image path does not exist.') return pupblock = [imageFileName.split('/')[-1].split('\\')[-1]] new_text= False try: appstring = Registry.GetKey('ExternalImageEditor', True) appstring = appstring['path'] # for ZanQdo if he removed the path from the textbox totaly. ;) - Cam if not appstring or appstring.find('%f')==-1: new_text= True except: new_text= True if new_text: pupblock.append('first time, set path.') if platform == 'win32': # Example of path to popular image editor... ;-) # appstring = '"C:\\Program Files\\Adobe\\Photoshop CS\\photoshop.exe" "%f"' # Have to add "cmd /c" to make sure we're using Windows shell. appstring = 'cmd /c start "" /B "%f"' elif platform == 'darwin': appstring = 'open "%f"' else: appstring = 'gimp %f' appstring_but = Draw.Create(appstring) save_default_but = Draw.Create(0) pupblock.append(('editor: ', appstring_but, 0, 99, 'Path to application, %f will be replaced with the image path.')) pupblock.append(('Set Default', save_default_but, 'Store this path in the blender registry.')) # Only configure if Shift is held, if Blender.Window.GetKeyQualifiers() & Blender.Window.Qual.SHIFT: if not Draw.PupBlock('External Image Editor...', pupblock): return appstring = appstring_but.val save_default= save_default_but.val if save_default: Registry.SetKey('ExternalImageEditor', {'path':appstring}, True) if appstring.find('%f') == -1: Draw.PupMenu('ERROR: No filename specified! ("%f")') return # ------------------------------- os_run(appstring, imageFileName)