• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VZim - One-click Fumefx to VrayVolumegrid Script
#1
VZim is a script that will run your Fumefx default sim and post-cache sim as well as creating and loading a VrayVolumegrid for the resulting sim, all in one click. This allows you to utilize the Fumefx preview window for sims without experiencing file incompatibility, while optimizing your cache files, and skipping the many mundane steps to get your sim loaded into and ready for rendering with a VrayVolumegrid.

Download: http://www.whitewizardentertainment.com/tools/

Compatibility: Tested with 3dsmax 2016, Vray 3.4, and Fumefx 4

UPDATE: I cleaned up the script and made a nice little macro for it.

Source Code:
Code:
macroScript VZim
category:"White Wizard Tools"
InternalCategory:"White Wizard Tools"
buttonText:"VZim"
toolTip:"VZim: Fumefx to VrayVolumegrid. Click to run Fumefx sim, convert to .vdb, and prepare a VrayVolumeGrid. Click again to update your VrayVolumeGrid. Shift-Click bypasses the default cache sim."


(
/*    Fumefx VZim v1.2 -- 9/20/2016
/    Created by Ronnee Swenton
/    Property of White Wizard Entertainment, LLC
/    
/        VZim is a script that will run your Fumefx default sim and post sim as well as creating
/        and loading a vrayvolumegrid for the resulting sim, all in one click. This allows you to utilize the Fumefx
/        preview window for sims without experiencing file incompatibility, while optimizing your cache files, and
/        skipping the many mundane steps to get your sim loaded into and ready for rendering with a VrayVolumegrid.
/    
/    Instructions:
/        - Create your Fumefx simulation setup as you would normally
/        - Click the VZim button (instead of the Fumefx sim button) and let it do the rest!
/        - Running VZim again will sim your default cache, convert to vdb, and then update your VrayVolumeGrid.
/        - Shift-click to run VZim without running a default sim (only works if you already have a default cache)
/    
/    Special notes:
/        VZim respects all of your Fumefx settings with the exception of your post-cache location. The script
/        creates all post-cache files next to your set default cache. VZim checks for an existing VrayVolumeGrid
/        corresponding to the name of your Fumefx grid. Because of this, it is not reccomended to alter the name
/        of your Fumefx grid after VZim runs, as it will create a new volumegrid rather than updating the previous one.
/        
/        VZim also sets your Fumefx grid to not render, so that only the volumegrid does so.
/        
/        This script was originally developed for the creation of Fumefx/VrayVolumegrid clouds. A simple trick to load
/        a static cache is to set the post-cache start and end frames to the desired frame. This will load a single frame
/        into the volumegrid (which is automatically set to "Load Nearest").
/        
/    Legal:
/        Feel free to share this script and alter as needed.
*/

        
    function vzim token =
        (
            
            global waitcount = 1    --Create a waitcounter to avoid errors from trying to run VZim again mid-process
            currentFFX = $
            volgridname = "VolGrid_" + currentFFX.name
            
            --If macro was Shift-Clicked, ignore this section (default cache sim)
            if ( token == 0 )    then
                (
                    
                    currentFFX.selectedcache = 0 --Select default cache
                    currentFFX.runsimulation 0 --Sim default cache
                    
                )
            
            --Return an error message if no default cache exists
            if ( ( getFiles ( currentFFX.GetPath "default" + "*.fdc" ) ) .count !=0 == false )
            then ( messageBox ( "No default cache was found! \n \n Run a default Fumefx sim before Shift-Clicking VZim." ) )
            
            --Otherwise convert the default to vdb
            else
            (
                
                cachepathdefault = currentFFX.GetPath "default"    --Get cache path
                currentFFX.SetPath ( cachepathdefault + "pp_.vdb" ) "retimer"    --Set post-cache to save as .vdb next to default cache
                
                --currentFFX.DeleteCaches "retimer"    --Delete post-cache files in case the range was altered
                
                currentFFX.selectedcache = 0 --Select default cache
                currentFFX.runsimulation 3 --Sim post-cache
                
                ppcache = ( currentFFX.GetPath "retimer" ) + "####.vdb"    --Finds the post-cache filepath and prepares it for the volumegrid input
                
                (
                    
                    if ( getNodeByName volgridname == undefined )
                    
                    then
                        (
                            print "VrayVolumeGrid not detected. Creating one for the current Fumefx Sim."
                            VRayVolumeGrid pos:currentFFX.pos rendinput:ppcache name:volgridname loadnearest:true --Creates a volumegrid at the same position as the fumefx grid
                            
                        )
                        
                    else
                        (
                            print "VrayVolumeGrid detected. Updating the cache file."
                            volgrid = getNodeByName volgridname
                            volgrid.pos = currentFFX.pos    --Update the position to align with our Fumefx cache
                            volgrid.rendinput = ppcache    --Update the post-cache input
                            volgrid.loadnearest = true
                        )
                    
                )
                
                currentFFX.renderable = false    --Make sure the Fumefx grid does not render while we are using a vrayvolumegrid
                
                currentFFX.selectedcache = 0    --Select default cache
                currentFFX.SimMode = 0    --Set Sim Mode to default
                
                select ( getNodeByName volgridname )    --select our vrayvolumegrid
                waitcount = 0    --Reset waitcount; allow VZim to run again
                
            )    
                
        )
                
        
    --Make sure the Fumefx grid is selected and if so, execute vzim function (based on if their was a shift click on the macro button)
    on execute do
        (
            
            
            if ( classof $ == FumeFx )
            
            then
            (
                
                if ( waitcount == 1 ) then ( print "VZim in progress! Don't be so impatient!" )    --A wait counter is checked to avoid errors
                
                else
                (
                    
                if (keyboard.shiftPressed) then ( vzim( token = 1 ) )
                
                else ( vzim( token = 0 ) )
                    
                )
                
            )
            
            else ( messageBox ("No Fumefx Grid Selected!") )
            
        )
        
)

I would like to be able to clear the post cache before I run a sim. You might see I have the command in there but commented out. The function brings up a dialogue box to confirm, which I don't have the knowledge to bypass. If anybody knows how please share so I can update my script. Tips and feedback are welcome.
  Reply
#2
Hello,

Thank s for sharing the script. We will repost it on our fb page.
Unfortunately, there is no option not to show that dialog.

Regards,
Kresimir Tkalcec
  Reply
#3
Very cool. Thank you!
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)