def button_event(evt): global config_data if (evt == BROWSE_HOME_CLICKED): default_path = "C:\\" if (Blender.sys.exists(config_data["home"])): default_path = config_data["home"] Window.FileSelector(SetHomeDir, "Nebula Home", default_path) if (evt == BROWSE_PROJ_CLICKED): default_path = "C:\\" if (Blender.sys.exists(config_data["home"])): default_path = config_data["proj"] Window.FileSelector(SetProjDir, "Project Dir", default_path) if (evt == ASSIGN_DIR_CHANGED): for data in config_data: if (data != "home" and data != "texture_dir" and data != "proj"): config_data[data] = dir_assigns[data].val if (evt == OK_CLICKED): SaveConfig() result = Draw.PupMenu("Saved%t|Do you want to exit?") if (result != -1): Draw.Exit() return if (evt == CANCEL_CLICKED): result = Draw.PupMenu("Exit%t|Exit and Discard Changes?") if (result != -1): Draw.Exit() return
def bevent(evt): global EVENT_NOEVENT, EVENT_DRAW, EVENT_EXIT if (evt == EVENT_EXIT): Draw.Exit() elif (evt == EVENT_DRAW): Draw.Redraw() elif (evt == EVENT_EXPORT): sce = bpy.data.scenes.active if (export_all == 1): print "oh ja" # get a list of mesh objects obs = [ob for ob in sce.objects if ob.type == 'Mesh'] # export all object names for ob in obs: me = Mesh.New() me.getFromObject(ob, 0) print(me.name) export_to_as(ob) Draw.PupMenu("Export Successful") else: export_to_as(sce.objects.active) Draw.PupMenu("Export Successful") elif (evt == EVENT_BROWSEFILE): Window.FileSelector(FileSelected, "Export .as", expFileName) Draw.Redraw(1)
def fPathSelector(id): def updatePath(fn): n = fn.rfind(os.sep) fn = fn[0:n] if os.path.isdir(fn): self.pathMap[id].val = fn Window.FileSelector(updatePath, "Select Path", self.pathMap[id].val)
def buttonEvents(event): """ This function handles events when the morph target is being processed. Parameters ---------- event: *int*. An indicator of the event to be processed """ global symmPath, selAxis, morphFactor global loadedTraslTarget, loadedRotTarget, loadedPoseTarget global currentTarget fileToSaveName = "" if loadedTraslTarget != "": fileToSaveName = loadedTraslTarget if loadedRotTarget != "": fileToSaveName = loadedRotTarget if loadedPoseTarget != "": fileToSaveName = loadedPoseTarget if event == 0: pass elif event == 1: Window.FileSelector(loadTarget, "Load Target") elif event == 2: applyTarget(morphFactor.val) elif event == 3: symm(0) elif event == 4: reset() elif event == 5: symm(1) elif event == 6: Window.FileSelector(saveTarget, "Save Target", fileToSaveName) elif event == 30: Window.FileSelector(scanReg, "Load scan") elif event == 31: Window.FileSelector(buildSVDdb, "Build scan->mh db", "head_vertices.dat") elif event == 32: Window.FileSelector(scan2mh, "Do scan->mh", "head_vertices.dat") elif event == 33: Window.FileSelector(saveSelVerts, "Save verts", "head_vertices.dat") elif event == 40: Window.FileSelector(regularise.loadTargetBase, "Load regularise db", "head_base.dat") elif event == 41: regulariseMesh() elif event == 42: Window.FileSelector(buildRegulariseDb, "Build regularise db", "head_vertices.dat") Draw.Draw()
def edl_bevent(evt): if evt == B_EVENT_NOP: pass elif evt == B_EVENT_IMPORT: ''' Load the file into blender with UI settings ''' filename = PREF['filename'].val reel_files = {} reel_offsets = {} for reel_key, reel_item in REEL_UI.iteritems(): reel_files[reel_key] = reel_item.filename_but.val reel_offsets[reel_key] = reel_item.offset_but.val error = load_edl(filename, reel_files, reel_offsets) if error != '': Draw.PupMenu('Error%t|' + error) else: Window.RedrawAll() elif evt == B_EVENT_RELOAD: edl_reload() Draw.Redraw() elif evt == B_EVENT_FILESEL_EDL: filename = PREF['filename'].val if not filename: filename = Blender.sys.join(Blender.sys.expandpath('//'), '*.edl') Window.FileSelector(edl_set_path, 'Select EDL', filename) elif evt >= B_EVENT_FILESEL: reel_keys = edl_reel_keys() reel_key = reel_keys[evt - B_EVENT_FILESEL] filename = REEL_UI[reel_key].filename_but.val if not filename: filename = Blender.sys.expandpath('//') PREF['reel_act'] = reel_key # so file set path knows which one to set Window.FileSelector(edl_set_path_reel, 'Reel Media', filename)
def bevent(evt): global GUIPARAMS, PARAMS if evt == NO_EVT: Draw.Redraw() elif evt == SINGLE_IMG: Window.FileSelector(setSinglePath, 'Image', Blender.sys.expandpath('//')) Draw.Redraw() PARAMS['ImportType'] = SINGLE elif evt == DIRECTORY_IMG: Window.FileSelector(setDirPath, 'Directory', Blender.sys.expandpath('//')) Draw.Redraw() PARAMS['ImportType'] = DIR elif evt == CLR_PATH: GUIPARAMS['Path'].val = '' PARAMS['ImagePaths'] = [] GUIPARAMS['ImageExt'].val = '' Draw.Redraw() elif evt == CHG_EXT: changeExtension() Draw.Redraw() elif evt == EXIT: Draw.Exit() elif evt == DO_SCRIPT: doScript() else: print "ERROR: UNEXPECTED BUTTON EVENT" return
def EventGUI(event): #================================ global gFilename global ExportOptions global ExportType global type global exporttype global operation global gAlert if (event == EVENT_IMPORT): ImportFunction(gFilename.val, type) operation = "Import" if (event == EVENT_IMPORT_SELECT): Window.FileSelector(ImportFunctionselet, 'IMPORT FILE') if (event == EVENT_IMPORT_CONT): gAlert = 0 operation = "Import" Draw() if (event == EVENT_EXPORT): ExportFunction(gFilename.val, type) operation = "Export" if (event == EVENT_EXPORT_CHK): ExportFunctionOK(gFilename.val, type) Draw() if (event == EVENT_EXPORT_CANCEL): gAlert = 0 Draw() if (event == EVENT_OPTIONS): type = ExportOptions.val Draw() if (event == EVENT_TYPE): exporttype = ExportType.val Draw() if (event == EVENT_EXPORT_ERR): gAlert = 0 Draw() if (event == EVENT_DONE): gAlert = 0 Draw() if (event == EVENT_QUIT): ExitGUI()
def import_gui_buttonevent(evt): global filename, fileinput if evt == 1: # Import print "Importing %s..." % filename file=open(filename) filedict={'newmodel': loadmodel} linereader(file, filedict) Draw.Redraw(1) return elif evt == 2: # Exit Draw.Exit() return elif evt == 3: # Edited text. # Err, clicked on the file selector button. Window.FileSelector(import_gui_filenamechosen, "Choose model to import") Draw.Redraw(1) #filename = eval(str(fileinput)) #Draw.Redraw(1) return else: # I have no clue *when* to call this thing (aside of launch). # I know it needs to be restarted, sorta like signal() in sysvile/posix. # Let's just be anal, even if it shall, yes shall, blow up. - W4 start_import_gui()
# FILE WRITE #RG - dump psk file psk.PrintOut() file = open(psk_filename, "wb") file.write(psk.dump()) file.close() print 'Successfully Exported File: ' + psk_filename #RG - dump psa file if not psa.IsEmpty(): psa.PrintOut() file = open(psa_filename, "wb") file.write(psa.dump()) file.close() print 'Successfully Exported File: ' + psa_filename else: print 'No Animations to Export' print 'My Export PSK/PSA Script finished in %.2f seconds' % (sys.time()-t) t = datetime.datetime.now() EpochSeconds = time.mktime(t.timetuple()) print datetime.datetime.fromtimestamp(EpochSeconds) textstring = 'Export Complete!' #Blender.Draw.PupStrInput("Name:", "untitled", 25) Draw.PupMenu(textstring) if __name__ == '__main__': Window.FileSelector(fs_callback, 'Export PSK/PSA File', sys.makename(ext='.psk')) #fs_callback('c:\\ChainBenderSideTurret.psk')
IMAGE_SEARCH.val,\ POLYGROUPS.val ) Window.WaitCursor(0) def load_obj_ui_batch(file): load_obj_ui(file, True) DEBUG = False if __name__ == '__main__' and not DEBUG: if os and Window.GetKeyQualifiers() & Window.Qual.SHIFT: Window.FileSelector(load_obj_ui_batch, 'Import OBJ Dir', '') else: Window.FileSelector(load_obj_ui, 'Import a Wavefront OBJ', '*.obj') # For testing compatibility ''' else: # DEBUG ONLY TIME= sys.time() DIR = '/fe/obj' import os print 'Searching for files' def fileList(path): for dirpath, dirnames, filenames in os.walk(path): for filename in filenames: yield os.path.join(dirpath, filename)
if (not model.IsEmpty()): if (model.HasRootPiece()): model.SetPieceLinks(log) model.CalculateGlobalOffsets(log) model.SetRadiusAndHeight(log) try: f = open(filename, "w") s = WriteMetaDataString(model) f.write(s) f = f.close() r = True except IOError: log.Write("ERROR: cannot open file \"%s\" for writing\n" % (filename)) else: log.Write("ERROR: model does not have a root-piece\n") else: log.Write("ERROR: model does not have any pieces\n") log.Flush() Window.WaitCursor(0) del log return r Window.FileSelector(SaveSpringOBJMetaDataScript, "Export to Spring OBJ meta-data script", "*.lua")
readLIBs(join(xppath,d,d2), libterrain) break break Window.DrawProgressBar(0, "Importing") readDSF(filename) elif 0:#except IOError, e: Window.WaitCursor(0) Window.DrawProgressBar(1, "ERROR") print("ERROR:\t%s.\n" % e.strerror) Draw.PupMenu("ERROR: %s" % e.strerror) return elif 0:#except: Window.WaitCursor(0) Window.DrawProgressBar(1, "ERROR") print("ERROR:\tCan't read DSF.\n") Draw.PupMenu("ERROR: Can't read DSF") return else: Window.WaitCursor(0) Window.DrawProgressBar(1, "Finished") Window.RedrawAll() print "Finished\n" #------------------------------------------------------------------------ # main routine #------------------------------------------------------------------------ Window.FileSelector(file_callback,"Import DSF")
psaFile.close() Window.RedrawAll() print "PSA2Blender completed" ##End of def ImportPSK######################### def fs_callback(filename): t = sys.time() import time import datetime print "====== IMPORTING UNREAL SKELETAL ANIMATION FORMAT========\r\n" ImportPSA(filename) print 'Import PSA Script finished in %.2f seconds' % (sys.time() - t) t = datetime.datetime.now() EpochSeconds = time.mktime(t.timetuple()) print datetime.datetime.fromtimestamp(EpochSeconds) #textstring = 'Import Complete!' #Blender.Draw.PupStrInput("Name:", "untitled", 25) #Draw.PupMenu(textstring) if __name__ == '__main__': Window.FileSelector(fs_callback, 'Import PSA File', sys.makename(ext='.psa'))
write_mtl(file, materialDict, globalMaterials) file.close() def write_ui(filePath): Window.EditMode(0) slashPos = filePath.rfind('\\') directory = filePath[:slashPos + 1] filename = filePath[slashPos + 1:] if not filename.lower().endswith('.drk'): filename += '.drk' if not BPyMessages.Warning_SaveOver(filePath): return context = Scene.GetCurrent().getRenderingContext() orig_frame = Blender.Get('curframe') Blender.Set('curframe', context.startFrame()) write(directory, filename, Scene.GetCurrent().objects) Blender.Set('curframe', orig_frame) # Restore old active scene. Window.WaitCursor(0) if __name__ == '__main__': Window.FileSelector(write_ui, 'Export Darkness Drk', sys.makename(ext='.drk'))
def buttonEvt(evt): global evtExport, evtPathChanged, evtBrows, evtExportSelection, exportSelection, exportNormals, exportTriangulated global exportPath global guiPopup if evt == evtExport: i3d = I3d() sce = bpy.data.scenes.active if exportSelection: for obj in sce.objects.selected: i3d.addObject(obj) else: for obj in sce.objects: i3d.addObject(obj) i3d.printToFile(exportPath.val) print("exported to %s" % exportPath.val) if evt == evtPathChanged: pass if evt == evtBrows: Window.FileSelector(selectExportFile, "Ok", exportPath.val) if evt == evtExportSelection: exportSelection = 1 - exportSelection Draw.Redraw(1) if evt == evtExportNormals: exportNormals = 1 - exportNormals Draw.Redraw(1) if evt == evtExportTriangulated: exportTriangulated = 1 - exportTriangulated Draw.Redraw(1) if evt == evtAddObjExtension: activeObj = bpy.data.scenes.active.objects.active slName = "%s.i3d" % activeObj.name sl = None try: sl = Text.Get(slName) except: sl = None if not sl is None: guiPopup = Draw.PupMenu( "%s already exists. Find it in the Text Editor" % slName) else: sl = Text.New(slName) sl.write("""<!-- this describes some i3d properties of the object it is linked to via Script Links. the name of this text file must end with ".i3d". all attributes of the SceneType node are copied to the Object in the final i3d. "i3dNodeId" is replaced by the id the object gets in the i3d scene. For the UserAttributes to work the attribute nodeId must be "i3dNodeId". --> <i3D> <Scene> <SceneType static="true" dynamic="false" kinematic="false"/> </Scene> <UserAttributes> <UserAttribute nodeId="i3dNodeId"> <Attribute name="onCreate" type="scriptCallback" value="print"/> </UserAttribute> </UserAttributes> </i3D>""") activeObj.addScriptLink(sl.getName(), "FrameChanged") guiPopup = Draw.PupMenu( "Check ScriptLink panel and Text Editor for %s" % sl.getName()) if evt == evtAddMatExtension: activeObj = bpy.data.scenes.active.objects.active activeMat = activeObj.getData().materials[activeObj.activeMaterial - 1] slName = "%s.i3d" % activeMat.name sl = None try: sl = Text.Get(slName) except: sl = None if not sl is None: guiPopup = Draw.PupMenu( "%s already exists. Find it in the Text Editor" % slName) else: sl = Text.New(slName) sl.write("""<!-- this describes some i3d properties of the material it is linked to via Script Links. the name of this text file must end with ".i3d". all attribute values starting with "assets/" are added to the Files Node and replaced with the id. in order for file references to work the path must start with "assets/". --> <i3D> <Materials> <Material customShaderId="assets/exampleCustomShader.xml"> <Custommap name="colorRampTexture" fileId="assets/exampleCustomMap.png"/> <CustomParameter name="exampleParameter" value="2 0 0 0"/> </Material> </Materials> </i3D>""") activeMat.addScriptLink(sl.getName(), "FrameChanged") guiPopup = Draw.PupMenu( "Check ScriptLink panel and Text Editor for %s" % sl.getName())
"""Read a point set and duplicate obj for each location. Insert every created object in sc """ Window.WaitCursor(True) sc = Scene.GetCurrent() ref_obj = sc.getActiveObject() #unselect everything except ref for obj in Object.GetSelected(): obj.sel = 0 ref_obj.sel = 1 #read points pts = load(open(filename, 'rb')) for pid, vec in pts.iteritems(): Object.Duplicate() obj = sc.getActiveObject() obj.setLocation(*vec) #return Window.RedrawAll() if __name__ == '__main__': Window.FileSelector(load_point_set, 'Import point set', '*.pkl')
cam.setMatrix(pose) def main(param_file): Window.WaitCursor(1) camera_parameters = load_camera(param_file) emode = int(Window.EditMode()) if emode: Window.EditMode(0) scene = Scene.GetCurrent() camera_data = create_camera(camera_parameters) scene.objects.new(camera_data) camera = Object.Get(camera_data.name) pose_camera(camera, camera_parameters) scene.objects.camera = camera context = scene.getRenderingContext() context.imageSizeX(int(camera_parameters.getroot().get('Width'))) context.imageSizeY(int(camera_parameters.getroot().get('Height'))) scene.update() Window.RedrawAll() if emode: Window.EditMode(1) Window.WaitCursor(0) Window.FileSelector(main, 'Load Calibration')
def event(event, value): """ This function handles keyboard events when the escape key or the 's' key is pressed to exit or save the morph target file. Parameters ---------- event: *int*. An indicator of the event to be processed value: *int*. A value **EDITORIAL NOTE: Need to find out what this is used for** """ global GUIswitch GUIswitchMax = 3 if event == Draw.ESCKEY and not value: Draw.Exit() elif event == Draw.AKEY: Window.FileSelector(saveSymVertsIndices, "Save Symm data") elif event == Draw.BKEY: selectSymmetricVerts() elif event == Draw.CKEY: Window.FileSelector(processingTargetsSymm, "Save Target") elif event == Draw.DKEY: Window.FileSelector(colorVerticesFromFile, "Load color file") elif event == Draw.EKEY: align() elif event == Draw.FKEY: Window.FileSelector(generateTargetsDB, "Generate DB from") elif event == Draw.GKEY: regulariseMesh() elif event == Draw.HKEY: Window.FileSelector(saveSelVerts, "Save index of selected vertices") elif event == Draw.IKEY: Window.FileSelector(findClosereset, "Reconstruct") elif event == Draw.LKEY: Window.FileSelector(adapt, "*.verts") elif event == Draw.MKEY: seekGroup() elif event == Draw.NKEY: Window.FileSelector(loadSelVerts, "Load index of verts to select") elif event == Draw.OKEY: analyseTarget() elif event == Draw.PKEY: Window.FileSelector(scaleRotTarget, "Scale Rot target") elif event == Draw.QKEY: Window.FileSelector(applyPoseFromFolder, "Load pose from folder") elif event == Draw.RKEY: Window.FileSelector(processingTargetsSaveSel, "save only selected") elif event == Draw.SKEY: Window.FileSelector(processingTargets, "Process targets") elif event == Draw.TKEY: Window.FileSelector(saveGroups, "Save vertgroups") elif event == Draw.UKEY: Window.FileSelector(scanReg, "Load scan") elif event == Draw.WKEY: Window.FileSelector(buildScan2Mesh, "build db") elif event == Draw.XKEY: Window.FileSelector(fitScan2Mesh, "svd fitting") elif event == Draw.YKEY: Window.FileSelector(applyPosesFromLibrary, "Create poses to correct") elif event == Draw.KKEY: Window.FileSelector(loadVerticesFromFolder, "Load indices from") elif event == Draw.PAGEDOWNKEY and not value and GUIswitch < GUIswitchMax: GUIswitch += 1 elif event == Draw.PAGEUPKEY and not value and GUIswitch > 1: GUIswitch -= 1 Draw.Draw()
def button_event(evt): # gui button events global SCREEN, START_SCREEN, CONFIG_SCREEN, CFGKEY, DISK_UPDATE global BEVT_KEYMENU, BUT_KEYMENU, BUT_TYPES, SCROLL_DOWN, GD, INDEX global BEVT_EXIT, BEVT_BACK, BEVT_APPLY, BEVT_CANCEL, BEVT_HELP, FREEKEY_IDX if SCREEN == START_SCREEN: for e in BEVT_KEYMENU: if evt == e: index = e - 1 k = BUT_KEYMENU[index].val - 1 CFGKEY = Config(GD[LABELS[index]][k][0], index != FREEKEY_IDX) if CFGKEY.data: SCREEN = CONFIG_SCREEN Draw.Redraw() return if evt == BEVT_EXIT: Draw.Exit() elif evt == BEVT_HELP: show_help() return elif SCREEN == CONFIG_SCREEN: datatypes = CFGKEY.sorteddata if evt >= BEVT_BROWSEFILE: INDEX = evt - BEVT_BROWSEFILE Window.FileSelector(fs_file_callback, 'Choose file') elif evt >= BEVT_BROWSEDIR: INDEX = evt - BEVT_BROWSEDIR Window.FileSelector(fs_dir_callback, 'Choose any file') elif evt >= BEVT_STR: var = BUT_TYPES[str][evt - BEVT_STR].val datatypes[str][evt - BEVT_STR][1] = var elif evt >= BEVT_FLOAT: var = BUT_TYPES[float][evt - BEVT_FLOAT].val datatypes[float][evt - BEVT_FLOAT][1] = var elif evt >= BEVT_INT: var = BUT_TYPES[int][evt - BEVT_INT].val datatypes[int][evt - BEVT_INT][1] = var elif evt >= BEVT_BOOL: var = datatypes[bool][evt - BEVT_BOOL][1] if var == True: var = False else: var = True datatypes[bool][evt - BEVT_BOOL][1] = var elif evt == BEVT_BACK: if SCREEN == CONFIG_SCREEN: SCREEN = START_SCREEN SCROLL_DOWN = 0 Draw.Redraw() elif evt == BEVT_EXIT: if CFGKEY.needs_update(): if Draw.PupMenu('UPDATE?%t|Data was changed') == 1: CFGKEY.update() Draw.Exit() return elif evt == BEVT_APPLY: if CFGKEY.needs_update(): CFGKEY.update() elif evt == BEVT_CANCEL: if CFGKEY.needs_update(): CFGKEY.revert() elif evt == BEVT_DEL: if CFGKEY.delete(): reset() init_data() SCREEN = START_SCREEN SCROLL_DOWN = 0 elif evt == BEVT_DISK: if DISK_UPDATE: DISK_UPDATE = False else: DISK_UPDATE = True elif evt == BEVT_HELP: show_help(CFGKEY.scriptname) return else: return Draw.Redraw()
if SUBDIV and obj.subdiv > 0: subdiv = obj.subdiv subdiv_render = subdiv # just to be safe: if subdiv_render > 6: subdiv_render = 6 if subdiv > 3: subdiv = 3 modif = object.modifiers.append(Modifier.Types.SUBSURF) modif[Modifier.Settings.LEVELS] = subdiv modif[Modifier.Settings.RENDLEVELS] = subdiv_render obj_idx += 1 self.build_hierarchy() scene.update() # End of class AC3DImport def filesel_callback(filename): inform("\nTrying to import AC3D model(s) from:\n%s ..." % filename) Window.WaitCursor(1) starttime = bsys.time() test = AC3DImport(filename) Window.WaitCursor(0) endtime = bsys.time() - starttime inform('Done! Data imported in %.3f seconds.\n' % endtime) Window.EditMode(0) Window.FileSelector(filesel_callback, "Import AC3D", "*.ac")
for frame in scene_frames: if EXPORT_ANIMATION: # Add frame to the filename. context_name[2] = '_%.6d' % frame Blender.Set('curframe', frame) if EXPORT_SEL_ONLY: export_objects = scn.objects.context else: export_objects = scn.objects full_path= ''.join(context_name) # erm... bit of a problem here, this can overwrite files when exporting frames. not too bad. # EXPORT THE FILE. write(full_path, export_objects,\ EXPORT_TRI, EXPORT_EDGES, EXPORT_NORMALS,\ EXPORT_NORMALS_HQ, EXPORT_UV, EXPORT_MTL,\ EXPORT_COPY_IMAGES, EXPORT_APPLY_MODIFIERS,\ EXPORT_ROTX90, EXPORT_BLEN_OBS,\ EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_MORPH_TARGET, EXPORT_ARMATURE) Blender.Set('curframe', orig_frame) # Restore old active scene. orig_scene.makeCurrent() Window.WaitCursor(0) if __name__ == '__main__': Window.FileSelector(write_ui, 'Export Wavefront OBJ', sys.makename(ext='.obj'))
# # OpenAlea WebSite : http://openalea.gforge.inria.fr # ############################################################################### ''' This module import a PlantGL scene into blender ''' __docformat__ = "restructuredtext" __license__ = "Cecill-C" __revision__ = " $Id: $ " import Blender from Blender import Window from openalea.plantgl.scenegraph import Scene as PGLScene from openalea.plantgl.codec.blender import sc_to_blender def load_scene (filename) : sc = PGLScene() sc.read(filename) print("loaded",len(sc)) return sc_to_blender(sc) if __name__ == '__main__' : Window.FileSelector(load_scene, 'Import scene', '*.geom,*.bgeom')
#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()
for frame in scene_frames: if EXPORT_ANIMATION: # Add frame to the filename. context_name[2] = '_%.6d' % frame Blender.Set('curframe', frame) if EXPORT_SEL_ONLY: export_objects = scn.objects.context else: export_objects = scn.objects full_path = ''.join(context_name) # erm... bit of a problem here, this can overwrite files when exporting frames. not too bad. # EXPORT THE FILE. write(full_path, export_objects,\ EXPORT_NORMALS_HQ, EXPORT_MTL,\ EXPORT_COPY_IMAGES, EXPORT_APPLY_MODIFIERS,\ EXPORT_BLEN_OBS,\ EXPORT_GROUP_BY_OB) Blender.Set('curframe', orig_frame) # Restore old active scene. orig_scene.makeCurrent() Window.WaitCursor(0) if __name__ == '__main__': Window.FileSelector(write_ui, 'Export OpenRacing WTF', sys.makename(ext='.wtf'))
def file_callback(filename): obj = NETimport(filename) try: obj.doimport() Blender.Scene.GetCurrent().update() except ParseError, e: Window.WaitCursor(0) Window.DrawProgressBar(0, 'ERROR') if e.type == ParseError.HEADER: msg = 'This is not a valid X-Plane v6, v7 or v8 OBJ file' elif e.type == ParseError.NAME: msg = 'Missing dataref or light name at line %s\n' % obj.m.lineno elif e.type == ParseError.MISC: msg = '%s at line %s' % (e.value, obj.m.lineno) else: thing = ParseError.TEXT[e.type] if e.value: msg = 'Expecting a %s, found "%s" at line %s' % ( thing, e.value, obj.m.lineno) else: msg = 'Missing %s at line %s' % (thing, obj.m.lineno) print "ERROR:\t%s\n" % msg Draw.PupMenu("ERROR%%t|%s" % msg) Window.RedrawAll() Window.DrawProgressBar(1, 'ERROR') Window.FileSelector(file_callback, "Import road.net")
if (not model.IsEmpty()): if (model.HasRootPiece()): model.SetPieceLinks(log) model.CalculateGlobalOffsets(log) model.SetRadiusAndHeight(log) try: f = open(filename, "w") s = WriteMetaDataString(model) f.write(s) f = f.close() ret = True except IOError: log.Write("ERROR: cannot open file \"%s\" for writing\n" % (filename)) else: log.Write("ERROR: model does not have a root-piece\n") else: log.Write("ERROR: model does not have any pieces\n") log.Flush() Window.WaitCursor(0) del log return ret Window.FileSelector(ExportSpringMetaDataScript, "export (.obj model) to Spring meta-data script", "*.lua")
self.oFile.write(pack(self.uvFmt, uv[0], -uv[1])) def export(self, object): #self.oFile.write(self.asciiz(object.getName())) mesh=object.getData() self.copyVertices(mesh) self.copyNormals(mesh) self.copyFaces(mesh) self.saveVertices(mesh) self.saveNormals(mesh) self.saveFaces(mesh) self.saveUV(mesh) print "UV=", len(self.uv) print "Vertices=", len(self.vertices) print "Normals=", len(self.normals) print "Faces=", len(self.faces) print "Duped vertices: ", len(self.vertices)-len(mesh.verts) self.oFile.close() #--------GUI--------------------------------------------------- objects = Blender.Object.GetSelected() def fileSelected(filename): meshExporter = MeshExporter(filename) meshExporter.export(objects[0]) #--------Main--------------------------------------------------- #Export only if one mesh object is selected if len(objects)==1 and objects[0].getType()=="Mesh": Window.FileSelector(fileSelected, 'SAVE FILE', 'unnamed.scn')
return ONLYSELECTED = PREF_ONLYSELECTED.val POLYLINES = PREF_POLYLINES.val ONLYFACES = PREF_ONLYFACES.val POLYFACES = PREF_POLYFACES.val FLATTEN = PREF_FLATTEN.val HIDDEN_MODE = PREF_HIDDEN_MODE.val SCALE_FACTOR = PREF_SCALE_FACTOR.val sce = Scene.GetCurrent() if ONLYSELECTED: sel_group = sce.objects.selected else: sel_group = sce.objects if sel_group: do_export(sel_group, filepath) else: print "Abort: selection was empty, no object to export!" Draw.PupMenu('DXF Exporter: nothing exported!|empty selection!') # Timing the script is a good way to be aware on any speed hits when scripting #----------------------------------------------------- if __name__=='__main__': #main() if not copy: Draw.PupMenu('Error%t|This script requires a full python install') Window.FileSelector(dxf_export_ui, 'EXPORT DXF', sys.makename(ext='.dxf'))
xoff /= float(newsize[0]) yoff /= float(newsize[1]) Draw.Exit() for ob in Scene.GetCurrent().objects: if ob.getType() == "Mesh": mesh = ob.getData() if mesh.hasFaceUV(): for face in mesh.faces: if face.mode & NMesh.FaceModes.TEX and face.image == oldimage: for i in range(len(face.uv)): (s, t) = face.uv[i] face.uv[i] = (xoff + s * xscale, yoff + t * yscale) face.image = newimage mesh.update() newimage.makeCurrent() Window.RedrawAll() #--------------------------------------------------------------------------- oldimage = Image.GetCurrent() if oldimage: try: oldsize = oldimage.getSize() except: Draw.PupMenu("Can't read image %s" % oldimage.name) else: #Window.ImageSelector(dodialog, 'Replace image', oldimage.filename) Window.FileSelector(dodialog, 'Replace image', oldimage.filename)
guiTable = {'VC': 1, 'UV': 1} for s in Window.GetScreenInfo(): Window.QHandle(s['id']) IMPORT_VC = Draw.Create(guiTable['VC']) IMPORT_UV = Draw.Create(guiTable['UV']) # Get USER Options pup_block = [ ('Import Options'), ('Vertex Color', IMPORT_VC, 'Import Vertex Colors if exist'), ('UV', IMPORT_UV, 'Import UV if exist'), ] if not Draw.PupBlock('Import...', pup_block): return Window.WaitCursor(1) guiTable['VC'] = IMPORT_VC.val guiTable['UV'] = IMPORT_UV.val read_main(filename) Window.WaitCursor(0) if __name__ == '__main__': Window.FileSelector(read_ui, 'Import ASCII Scene', ('.ase'))