from pymaxwell import * import os import sys def createSunSeq(scene,begin,duration,nFrames,outDir,outName): if not os.path.exists(outDir): os.makedirs(outDir) interval = float(duration)/float(nFrames-1) skytype = scene.getEnvironment().getActiveSky() if not skytype == 'PHYSICAL': print('No physical sky!') return False lon,lat,sm,day,time,ok = scene.getEnvironment().getSunLongitudeAndLatitude() new_time = begin for i in range(nFrames): print new_time scene.getEnvironment().setSunLongitudeAndLatitude(lon,lat,sm,day,new_time) framename = os.path.join(outDir,outName+'_{0:0>6d}'.format(i)+'.mxs') if not scene.writeMXS(framename): print('Error saving '+framename) return False new_time = new_time+interval if new_time > 24.0: new_time = new_time - 24.0 return True #if name == "__main__": ################################### edit this as you want begin = 10.5 # 10:30 duration = 8 # hours nFrames = 30 input_mxs = 'D:/SAMPLES/maxwell/3.1.0.2/cube/cube.mxs' output_dir = 'D:/SAMPLES/maxwell/3.1.0.2/cube/sun_animation' output_name = 'SunAnimation' ################################## mxs = Cmaxwell(mwcallback) if not mxs.readMXS(input_mxs): print('Error reading '+input_mxs) else: if createSunSeq(mxs,begin,duration,nFrames,output_dir,output_name): print('OK')