Batch command line script

Share your scripts with other members
lukeiamyourfather
Posts: 2880
Joined: Mon Oct 15, 2007 4:09 pm
Contact:

Batch command line script

Postby lukeiamyourfather » Wed Sep 09, 2009 7:01 am

This is a work in progress but I'd appreciate input and testing. It works only with Linux currently but would be easy to port when finished. The way it works now is you select a scene from file dialog, then options for the command line like how many threads and whether or not to mesh, and then select another scene. If you don't select another scene it'll simulate what is already selected in the list of scenes. Select as few or as many as you want. One simulation runs and then the next until they are finished. Its all done in RealFlow because its a PITA to make GUI with Python by itself. Ideas for next iteration are in the comments as all capitol letters. Its a batch script by the way (F10). Cheers!

Code: Select all

import os

defaultDirectory = "/scenes/realflow"
defaultOptions = "-nogui -threads 8"
defaultCommand = "realflow"

theList = []
dialogLoop = True

# ASK TO INCLUDE CURRENT SCENE FILE?

while dialogLoop:
   fileDialog = GUIFilePickerDialog.new()
   filePath = fileDialog.show( FILE_PICKER_LOAD, defaultDirectory, "*.flw;", "Choose scene" )
   if filePath == "":
      dialogLoop = False
   else:
      optionsDialog = GUIFormDialog.new()
      optionsDialog.addStringField("Options",defaultOptions)
      if ( optionsDialog.show() == GUI_DIALOG_ACCEPTED ):
         fileOptions = optionsDialog.getFieldValue("Options")
      else:
         break
      theList.append([filePath,fileOptions])

# NORMALIZE PATHS BEFORE LAUNCHING SIMULATIONS?
# ASK TO SAVE COMMAND LIST AS TEXT FILE?
# REPORT LOG AT THE END?

if len(theList) == 0:
   scene.message("Select at least one scene file")
else:
   scene.message("Running batch command line simulations")
   for pair in theList:
      scene.message("Running scene file %s with options %s" % (pair[0],pair[1]))
      os.system('gnome-terminal --title="RealFlow - %s" -e "realflow %s %s"' % (pair[0],pair[1],pair[0]))


User avatar
phizikl
Posts: 113
Joined: Fri Aug 14, 2009 1:59 pm

Batch command line script

Postby phizikl » Wed Sep 09, 2009 7:43 am

looks great,
i am not a programmer so i cannot convert it to windows, but im sure it willbe very useful to realflow community!
Ian Clemmer // DIRECTION/DESIGN/FX // www.ianclemmer.com //
V-MOTION // 3ds Max Scripts and Realflow Plugins for the Visual Artist // www.v-motion.co

User avatar
bolek
Posts: 121
Joined: Thu Nov 27, 2008 10:24 am
Contact:

Batch command line script

Postby bolek » Sat Sep 19, 2009 8:09 pm

I have some similar script but it is still work in progress

"phizikl" try this one on windows : ]

Code: Select all

import os

def main():
#var
   range = scene.getMaxFrames()
   realflownodeWindow = GUIFormDialog.new()
   sceneMeshes = scene.getMeshes()
   meshes = [All]
   for i in sceneMeshes:
      meshes.append(i.getName())


   scenePathPython = scene.getRootPath() +"/" +scene.getFileName()
   scenePathWin = os.path.normpath(scenePathPython)


#GUI
   threadsNum = os.environ[NUMBER_OF_PROCESSORS]
   optionsSimulate = ["Realflownode" , Realflow -nogui]
   optionSimulateChoose = realflownodeWindow.addListField("1.SimulateWith", optionsSimulate , 0)
   optionCreateMesh = realflownodeWindow.addBoolField("2.CreateMesh" , False  )
   optionRange = realflownodeWindow.addVectorField("3.Range-Start/End/None" , 0 , range ,0)
   optionThreads = realflownodeWindow.addIntField("4.NumberOfThreads", int(threadsNum) )
   optionReset = realflownodeWindow.addBoolField("5.Reset", False)
   optionMesh = realflownodeWindow.addListField("6.Mesh", meshes, 0)

#lLICENSE

   form = GUIFormDialog.new()
   opcje = ["License", Simulate]
   prog = form.addListField("RFNODE", opcje,0)
   showForm = form.show()
   if(showForm == GUI_DIALOG_ACCEPTED):
      data = form.getFieldValue("RFNODE")
      if (data == 0):
         os.system("realflownode -license")
         rfshow = realflownodeWindow.show()
      elif (data == 1):
         rfshow = realflownodeWindow.show()

#get values
   if(rfshow == GUI_DIALOG_ACCEPTED):
      optionSimulateChooseExport = realflownodeWindow.getFieldValue("1.SimulateWith")
      optionCreateMeshExport = realflownodeWindow.getFieldValue("2.CreateMesh")
      optionRangeExport = realflownodeWindow.getFieldValue("3.Range-Start/End/None")
      optionThreadsExport = realflownodeWindow.getFieldValue("4.NumberOfThreads")
      optionResetExport = realflownodeWindow.getFieldValue("5.Reset")
      optionMeshExport = realflownodeWindow.getFieldValue("6.Mesh")

# print
   scene.message(optionsSimulate [(optionSimulateChooseExport)])
   scene.message(str(optionCreateMeshExport))
   scene.message(" Start " +str(optionRangeExport.x)+" End " +str(optionRangeExport.y) +" None " +str(optionRangeExport.z))
   scene.message(str(optionThreadsExport))   
   scene.message(str(optionResetExport ))
   scene.message(meshes [(optionMeshExport )])
   scene.message(scenePathPython)
   scene.message(scenePathWin)

#sim
   cmdLine = optionsSimulate[(optionSimulateChooseExport)]+" " +"-threads 4 " + " " +scenePathWin
   os.system("start /b /high " +cmdLine )
   scene.message(cmdLine)

main()

BYE BYE
____________________________________________
http://vimeo.com/bolekcg
http://bolekcg.blogspot.com/


Return to “User Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest