def update_RegistryInfo():
    d = {}
    d['EXPORT_DIR'] = EXPORT_DIR
    d['ONLY_SELECTED'] = ONLY_SELECTED
    d['tooltips'] = tooltips
    d['GLOBAL_COORDS'] = GLOBAL_COORDS
    Registry.SetKey(REG_KEY, d, True)
示例#2
0
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
示例#3
0
 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
示例#4
0
 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])
示例#5
0
 def save(self):
     """Save settings to registry.
     """
     ExportSettings.save(self)
     settingsDict = {}
     for prop in self._properties:
         settingsDict[prop] = getattr(self, prop)
     Registry.SetKey('b2rex_char', settingsDict, True) 
     return
示例#6
0
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.
示例#7
0
def SavePrefs():
    export_config["persist_server"] = persist_server
    export_config["mesh_format"] = mesh_format
    export_config["window_width"] = window_width
    export_config["window_height"] = window_height
    export_config["fullscreen"] = fullscreen
    export_config["renderpath"] = renderpath
    export_config["group"] = group
    export_config["aa"] = aa
    Registry.SetKey("n2exportconfig", export_config, True)
示例#8
0
    def delete(self):
        global DISK_UPDATE

        delmsg = 'OK?%t|Delete key from memory'
        if DISK_UPDATE:
            delmsg = "%s and from disk" % delmsg
        if Draw.PupMenu(delmsg) == 1:
            Registry.RemoveKey(self.key, DISK_UPDATE)
            return True

        return False
示例#9
0
    def update(self):  # update original key
        global DISK_UPDATE

        data = self.data
        odata = self.origdata
        new = self.sorteddata
        for vartype in new.keys():
            for i in new[vartype]:
                if data[i[0]] != i[1]: data[i[0]] = i[1]
                if odata[i[0]] != i[1]: odata[i[0]] = i[1]

        if DISK_UPDATE: Registry.SetKey(self.key, odata, True)
示例#10
0
    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()
示例#11
0
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)
示例#12
0
def writeDataToRegistry():
    """
	Writes data to the Blender registry.
	"""

    global G

    dict = {}
    dict['coordmap'] = G.coordmap
    if G.imagename is not None:
        dict['imagename'] = G.imagename

    Registry.SetKey('TsaiCC', dict)
示例#13
0
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
示例#14
0
def SaveConfig():
    global config_data
    file2 = n2.lookup("/sys/servers/file2")
    #file2.setassign("home", str(config_data["home"]))
    #file2.setassign("proj", str(config_data["proj"]))
    for data in config_data:
        #if(data != "home"):
        data = str(data)
        assign = config_data[data]
        file2.setassign(data, assign)
    texture_dir = file2.manglepath("textures:")
    texture_dir = os.path.abspath(texture_dir)
    texture_dir = string.replace(texture_dir, "\\", "/")
    config_data["texture_dir"] = texture_dir
    Registry.SetKey(reg_name, config_data, True)
示例#15
0
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
示例#16
0
def update_RegistryInfo():
	d = {}
	d['SKIP_DATA'] = SKIP_DATA
	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)
示例#17
0
 def save(self):
     """Save settings to registry.
     """
     settingsDict = {}
     for prop in self.properties:
         settingsDict[prop] = getattr(self, prop)
     if self.username and self.password:
         self.credentials.set_credentials(self.server_url, self.username,
                                          self.password)
     settingsDict['locX'] = self.locX.getValue()
     settingsDict['locY'] = self.locY.getValue()
     settingsDict['locZ'] = self.locZ.getValue()
     for prop in ['Objects', 'Textures', 'Materials', 'Meshes']:
         keyName = 'regen' + prop
         settingsDict[keyName] = getattr(self, keyName)
     Registry.SetKey('b2rex', settingsDict, True)
     return
示例#18
0
 def fCheck(dummy):
     self.msg = []
     if self.bBinPathAuto.val:
         bin = ''
     else:
         bin = self.bBinPath.val
     self.error = CheckPath(bin, self.msg)
     if self.error is False:
         d = {}
         if self.bBinPathManual.val:
             d['PandaBinPath'] = bin
         else:
             d['PandaBinPath'] = ''
         Registry.SetKey('Chicken', d, True)
     else:
         Draw.PupMenu('Configuration Errors%t|' + '|'.join(self.msg))
         print self.msg
示例#19
0
def registry_update():
	global KEX_FILE
	global ENABLE_KEX
	global ENABLE_SUP
	global ENABLE_BETA

	d = {
		'KEX_FILE': KEX_FILE,
		'ENABLE_KEX': ENABLE_KEX,
		'ENABLE_SUP': ENABLE_SUP,
		'ENABLE_BETA': ENABLE_BETA,
		'script': 'export_3ds2kex.py',
		'tooltips': {
			'KEX_FILE': 'Location of 3DS2KEX.exe utility.',
			'ENABLE_KEX': 'Enable creation of KEX by calling 3DS2KEX utility.',
			'ENABLE_SUP': 'Enable creation of custom SUP file for pivot and NUP parameters.',
			'ENABLE_BETA': 'Enable beta 3ds2kex utility features (Dec 2007 Beta release from Knife Edge)',
		},
	}

	Registry.SetKey('export_3ds2kex', d, True)
示例#20
0
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()
示例#21
0
def HasConfigData(key):
    """
	Check if the given key exists, either already loaded in the Registry dict or
	as a file in the script data config dir.
	@type key: string
	@param key: a given key name.
	@returns:
		- 0: key does not exist;
		- 1: key exists in the Registry dict only;
		- 2: key exists as a file only;
		- 3: key exists in the Registry dict and also as a file.
	@note: for readability it's better to check against the constant bitmasks
		BPY_KEY_MISSING = 0, BPY_KEY_IN_REGISTRY = 1 and BPY_KEY_IN_FILE = 2.
	"""

    fname = bsys.join(_CFG_DIR, "%s%s" % (key, _EXT))

    result = BPY_KEY_MISSING
    if key in Registry.Keys(): result |= BPY_KEY_IN_REGISTRY
    if bsys.exists(fname): result |= BPY_KEY_IN_FILE

    return result
示例#22
0
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)
示例#23
0
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 : 
示例#24
0
	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']
示例#25
0
def save_to_registry():
    d = {}
    d['selection_only'] = export_selection_only.val
    d['rotate_z_to_y'] = export_rotate_z_to_y.val
    d['compressed'] = export_compressed.val
    Registry.SetKey('vrml97_export', d, True)
示例#26
0
def start():
    if not regdict.has_key('params'):
        regdict['params'] = {}
    #build_armature()
    AvatarBuilder()
    Registry.SetKey('sl_blender', regdict, True)
示例#27
0
                #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()
示例#28
0
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:
示例#29
0
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)
示例#30
0
        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