搜档网
当前位置:搜档网 › Advanced Multithreaded Mesh

Advanced Multithreaded Mesh

###########################################################
# Advanced Multithreaded Mesh Build for RF5
# Make sure you cache the particles, add mesh node and save
# the scene before you start the script.
# Author: bazuka
# Version: v1.5
# Date: 2010-07-25
#how to use
#1. Run Rf5 and load the scene where you already have cached/calculated particles
#2. Add Mesh node, and tweak it as you like
#3. Save scene
#4. Load the script from Batch Script window
#5. Run the script

#Note:
#Before you run the script make sure you have nextlimit license manager running.

#Warning:
#Due the rf 5.0.1.0154 bug for command line meshing this script wont work,
#so only solution for now is to roll back to rf 5.0 or wait for new update...
###########################################################

import subprocess
import platform

form = GUIFormDialog.new()

options = [ "2", "4", "8", "16" ]
form.addListField( "1. Threads", options, 1 )
form.addBoolField( "2. Range", False )

rf5Path = 'c:\\Program Files\\Next Limit\\RealFlow 5'

if (scene.getFileName() == None):
warning = GUIMessageDialog.new()
warning.show( ALERT_TYPE_CRITICAL, "Please load the Scene!" )
else:
sceneFile = scene.getRootPath() + "/" + scene.getFileName()

endRange = scene.getMaxFrames()
startRange = 0

if (form.show() == GUI_DIALOG_ACCEPTED ):
dialogRange = ( form.getFieldValue( "2. Range" ) )
if ( dialogRange == 1 ):
rangeDlg = GUIFormDialog.new()
rangeDlg.addIntField( "1. Start", 0 )
rangeDlg.addIntField( "2. End", endRange )
if ( rangeDlg.show() == GUI_DIALOG_ACCEPTED ):
startRange = ( rangeDlg.getFieldValue( "1. Start" ) )
endRange = ( rangeDlg.getFieldValue( "2. End" ) )
numThread = int(str(options[(form.getFieldValue( "1. Threads" ) )]))
divRange = int((endRange - startRange +1) / numThread)
scene.message(str(startRange))
scene.message(str(endRange))
for i in range(0, (numThread)):
startFrame=startRange + divRange*i
endFrame=startFrame + divRange -1
if (i == (numThread-1)):
endFrame=endRange
cmdRange = '-range '+ str(startFrame) + ' ' + str(endFrame)
subprocess.Popen('start realflownode.exe -mesh %s "%s"' % (cmdRange,sceneFile), shell=True, cwd=rf5Path)
else :
scene.message ( "Operation did not complete." )

相关主题