from pymaxwell4 import * import os def createMxsFromCameras(oldMxsPath, mxsPath): scene = Cmaxwell(mwcallback); if scene.readMXS(oldMxsPath): cameras = scene.getCameraNames() folder = os.path.splitext(mxsPath)[0] #folder = folder.replace('%','_') os.mkdir(os.path.join(os.path.dirname(mxsPath),folder)) for camname in cameras: if not scene.getCamera(camname).isNull(): if scene.getCamera(camname).setActive(): print("Setting camera "+camname+" as active") filename = os.path.basename(mxsPath) filename = filename.replace('%cameraname%',camname) outpath = os.path.join(os.path.dirname(mxsPath),folder,filename) if scene.writeMXS(outpath): print(outpath+" saved sucessfully") else: print("Error saving "+outpath) else: print("Error setting camera "+camname+" as active") else: print("Error reading camera "+camname) else: print("Error reading scene"); print("END"); if __name__ == "__main__": # This is the path and name of the generated mxs files. # %cameraname% is a macro that is replaced with the name of the camera. Customize as you will. Please notice the "/"; this separator "\" is not valid. mxsPath = 'C:/scene/scene-%cameraname%.mxs' # Mxs path and name of the scene with several cameras. Customize as you will. Please notice the "/"; this separator "\" is not valid. oldMxsPath = 'C:/scene/MXS_file_with_several_cameras.mxs' createMxsFromCameras(oldMxsPath, mxsPath)