Announcement

Collapse
No announcement yet.

Pre-render script help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pre-render script help

    Hi,

    I might be hoping for too much here but never the less!

    I am trying to find a way to on mass redirect xrefs being loaded in a load of max files, so an example. I have 5 images, each image has a max file with cam and lights, and they all load the same list of xrefs. I then put the render scenes into Deadline/Backburner. Later I need to add a new scene to the xref list of all the files. I have to open them all and add the new scene. If a pre-render script could have the list of xrefs in to then the extra scene could be added in the script, and all render files would get the new scene at render time.

    Secondly, is there a way for the save location in the VFB to be set through a pre-render script? So somehow you set the images save name in the VFB, but the folder structure behind the save location is driven with the script? I'm thinking here if a new revision needs to be saved and not over the original renders, then you edit the pre-render script to a new folder and they all render to that folder, with same image names etc.

    This could save a ton of work, just this morning spent 3 hours opening and closing files! 18 images, 36 render files!

    Or does anyone have any other options to try? I thought if you could edit a .max file in a txt editor then that would be good.

    Cheers,
    Mark

  • #2
    It's possible....

    Something along these lines.....
    Have a text file somewhere in the job folder with the list of XRefs you want to have in your scene files for rendering.

    Have a postOpen and preRender script which adds any necessary XRef entries...

    I've tested this locally and it works... give it a try and see if it works on the network as you'd expect.

    Code:
    --lets remove the callback if we've made it already so we can replace it
    callbacks.removeScripts id:#dwXRefLoader
    
    --define the function as global and persistent so it will load on next time we open this file locally or on the farm
    persistent global checkXRefs
    
    --define our callback function
    fn checkXRefs =
    (
    	--open our data file
    	f = openfile @"c:\temp\xreflist.txt"
    	--make sure we're at the start of the file to read it
    	seek f 0
    	--keep reading until we get the end-of-file
    	while not eof f do
    	(
    		--read the line
    		thepath = readline f
    		
    		--make sure file exists first
    		if doesfileexist thepath do 
    		(
    			--is it xreffed already? Let's get a list of all the paths we have from our existing xrefs
    			thePaths = #()
    			--loop through from 1 to our xref count
    			for i = 1 to xrefs.getXRefFileCount() do
    			(
    				--add the path to our 'thepaths' array collection
    				append thePaths (xrefs.getXRefFile i).filename
    			)
    			--see if it's in the list or not...
    			if finditem thePaths thePath == 0 do
    			(
    				--if it's not in the list, lets create a new xRef
    				xrefs.addNewXRefFile thepath
    			)
    		)
    	)
    	--absolutely imperitive that we close the file or we won't be able to edit it until we restart our machine
    	close f
    )
    
    --add callbacks for preRender and postLoad
    callbacks.addScript #preRender "checkXRefs()" id:#dwXRefLoader persistent:true
    callbacks.addScript #postLoad "checkXRefs()" id:#dwXRefLoader persistent:true
    Maxscript made easy....
    davewortley.wordpress.com
    Follow me here:
    facebook.com/MaxMadeEasy

    If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

    Comment


    • #3
      You can't change your save location through a pre-render script. It would break the data for Deadline/Backburner.

      I think in both though you can manually change the output path? Gets more complicated if you are strip/tile rendering however.
      Maxscript made easy....
      davewortley.wordpress.com
      Follow me here:
      facebook.com/MaxMadeEasy

      If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

      Comment


      • #4
        Hi Dave,

        Wow, I'll try it out. So that code is the pre-render script?

        I have just made my own version to see if I could work it out, and its very simple!! But works!


        -- remove all current xRefs in scene
        -- xrefs.deleteAllXRefs - not working!!!

        SharedxRefLocation = "C:/Users/mark/Desktop/XrefLoader/"
        NoGlass1 = "xref3.max"

        xrefs.addNewXRefFile (SharedxRefLocation + NoGlass1)
        Last edited by m_hinks; 11-02-2016, 07:49 AM.

        Comment


        • #5
          Yours could easily add an xRef twice.
          Maxscript made easy....
          davewortley.wordpress.com
          Follow me here:
          facebook.com/MaxMadeEasy

          If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

          Comment


          • #6
            Run the code once in your scene and it should persist for the of the project.
            Maxscript made easy....
            davewortley.wordpress.com
            Follow me here:
            facebook.com/MaxMadeEasy

            If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

            Comment

            Working...
            X