Home Technical Talk

Maxscript: Can write to parameter but read lies!

polycounter lvl 12
Offline / Send Message
jeremiah_bigley polycounter lvl 12
renderers.current.globalSamplerEnabled = true -- Sets the GSS checkbox to on.
then if I go and manually turn it off in the UI and ask max...
renderers.current.globalSamplerEnabled == false
I get false... in other words... It is only reading back to me the last value I set to the checkbox through maxscript.

Why? idunderstand! D: Anyone know something I don't about this? Any help would be greatly appreciated.

Jeremiah

Replies

  • JamesWild
    Options
    Offline / Send Message
    JamesWild polycounter lvl 8
    You will get false:

    a = true

    a == false

    true == false

    false
  • monster
    Options
    Offline / Send Message
    monster polycounter
    The value updates when you close the dialog. The MaxScript help says to always make sure the dialog is closed when changing render settings. See the not on the top of this page.

    http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/files/GUID-30AF1E53-5A69-402D-84D6-4D6ECCDD6D20.htm
  • Mark Dygert
    Options
    Offline / Send Message
    The Render Scene dialog is barely functional, you are definitely staring into the abyss and its staring back at you.

    I hate the thing with a passion and it knows it. It uses every chance it can to ruin my day. Like rendering a muti-frame job from batch render to a single frame if single is checked on in the render dialog window. It's a completely unrelated setting in an completely separate window that should have no bearing on the batch render. It pulls the right range from batch, but just renders it all to a single frame... WTF!?

    I had to write a script that forces it to range and closes the render dialog window, anytime I pull up the batch render dialog.
    Don't get me started on the way it sets the file type for render output...
  • jeremiah_bigley
    Options
    Offline / Send Message
    jeremiah_bigley polycounter lvl 12
    *sigh* That is it monster. I didn't see that note because it is not on the Default Scanline Render Class page... I searched for at least a couple of hours on that subject and found nothing. So frustrating. Thanks for the info.

    Mark - lol I have been feeling that way about the RTT dialog. The most complex thing I have touched in maxscript so far... I had no idea what I was getting into when I started this script.

    RTT works the same way with having to close, change the settings, and then reopen it.


    Thank you so much guys!
  • jeremiah_bigley
    Options
    Offline / Send Message
    jeremiah_bigley polycounter lvl 12
    While we are here... is there a way to do this?
    renderers.current == Default_Scanline_Renderer
    
    when I check the renderers.current it returns:
    Default_Scanline_Renderer:Default_Scanline_Renderer
    
    I can't seem to find the name of the Default Scanline to compare it to the renderers.current.
  • jeremiah_bigley
    Options
    Offline / Send Message
    jeremiah_bigley polycounter lvl 12
    nvm... disregard that.
    renderers.current.classID[1] == 1
    
  • Bryan Cavett
    Options
    Offline / Send Message
    Bryan Cavett polycounter lvl 19
    Hey Jermiah why not just use render presets and then load the renderer and settings you want that way? You can load them through script and it might be less of a headache.

    I think I was doing this in one of my baking scripts that I seemed to have lost... but it worked pretty good.
  • monster
    Options
    Offline / Send Message
    monster polycounter
    For my render to texture scripts I do something like this:
    --SAVE THE CURRENT RENDERER
    savedRenderer = rederers.current
    
    --CREATE A NEW RENDERER AND SET IT UP
    scanline = Default_Scanline_Renderer()
    scanline.globalSamplerEnabled = true
    --other settings...
    
    --RENDER/BAKE
    rederers.current = scanline
    render output:myFile
    
    --RESET THE RENDERER
    renderers.current = savedRenderer
    
  • jeremiah_bigley
    Options
    Offline / Send Message
    jeremiah_bigley polycounter lvl 12
    Bryan - Yeah I had read in a couple of places that you could do that but I am very OCD about my scripts being self sufficient (at least for now). I like only having to worry about saving my macro folder when I backup my 3ds max. I feel like it is more files I don't want to deal with.

    monster - I will have to give that a try. I hadn't thought of saving the current render like that. Pretty cool!
  • jeremiah_bigley
    Options
    Offline / Send Message
    jeremiah_bigley polycounter lvl 12
    Was wondering if anyone might have some insight to a problem I am having over in my script thread.

    http://www.polycount.com/forum/showthread.php?t=104541&page=2
  • jeremiah_bigley
    Options
    Offline / Send Message
    jeremiah_bigley polycounter lvl 12
    Well I made some progress figure out what the issue is... Hopefully someone here would be able to help me.


    be.bitmap is the bitmap last rendered in the render to texture.
    I have to render to texture twice before the be.bitmap will update. Is there anything wrong with this?
    bp = $.INodeBakeProperties
    be = bp.getBakeElement 1
    
    -- render here
    
    newbitmap =  bitmap xsize ysize
    copy be.bitmap newbitmap 
    newbitmap.filename = some location
    save newbitmap 
    
    close newbitmap
    close be.bitmap
    
  • leslievdb
    Options
    Offline / Send Message
    leslievdb polycounter lvl 15
    not sure but shouldnt the copy be like this
    newbitmap = copy be.bitmap
    also you wouldnt have to define the new bitmap before that
  • jeremiah_bigley
    Options
    Offline / Send Message
    jeremiah_bigley polycounter lvl 12
    gave it a try and it is still doing it :/
    but you helped me condense my code :D
  • monster
    Options
    Offline / Send Message
    monster polycounter
    So why are you using the copy command? You should be able to specify an output file for each render element.
  • monster
    Options
    Offline / Send Message
    monster polycounter
    So I think the main issue that it would cause it to update every other render is because of scope. You have the script in global scope. The variable be is used in the function, but defined after it. There were a few other issues. I chopped it up and came up with this, it outputs an updated bitmap to disk every time:
    (
    	bp = $.INodeBakeProperties
    	bp.removeAllBakeElements()
    	bp.bakeEnabled = true
    	bp.bakeChannel = 1
    	bp.nDilations = 4
    
    	prjp = $.INodeBakeProjProperties
    	prjp.hitMatchMtlID = true
    	prjp.enabled = true
    	prjp.warnRayMiss = true
    
    	sz = 512
    
    	nmtest = Normalsmap()
    	nmtest.enabled = true
    	nmtest.outputSzX = nmtest.outputSzY = sz
    	nmtest.filenameUnique = true
    	nmtest.elementname = "Normal Map Test"
    	nmtest.filetype = (maxfilepath + $.name + "_nmtest.tga")
    	bp.addBakeElement nmtest
    
    	render renderType:#bakeSelected frame:#current vfb:false outputwidth:sz outputheight:sz
    )
    

    Here is the original code with my notes added.
    --LETS NOT RUN THE SCRIPT IN GLOBAL SCOPE
    --SIMPLY ADD PARENTHESES TO THE BEGINING AND END
    (
    --LETS NOT USE GLOBALS
    -- 	global bp = $.INodeBakeProperties
    -- 	global prjp = $.INodeBakeProjProperties
    	bp = $.INodeBakeProperties
    	prjp = $.INodeBakeProjProperties
    
    --FUNCTION ISN'T REALLY NEEDED BECAUSE THE BAKE ELEMENT HAS ALL THE PARAMETERS
    -- 	fn RTTBigleyCastTools Xsize Ysize channel padding fullfilename =
    -- 	(
    -- 		bp.bakeEnabled = true
    -- 		bp.bakeChannel = channel
    -- 		bp.ndilations = padding
    
    -- 		fPath = getFilenamePath fullfilename
    -- 		fName = getFilenameFile fullfilename
    -- 		fType = getFilenameType fullfilename
    
    -- 		--JUST FYI "be" IS NOT A LOCAL VARIABLE IN THIS FUNCTION
    -- 		--IT WAS WORKING BEFORE BECAUSE THE SCRIPT WAS RUN IN GLOBAL SCOPE
    	
    -- 		be.outputSzX = Xsize
    -- 		be.outputSzY = Ysize
    -- 		be.filenameUnique = true
    -- 		be.filename = fName
    -- 		be.fileType = fType
    
    -- 		render rendertype:#bakeSelected outputwidth: Xsize outputheight: Ysize outputfile:(fPath+fName+fType)  vfb: false
    -- 	)
    
    
    	-- Sets up a Test Normal Map RTT Element
    	bp.removeAllBakeElements()
    	bp.bakeEnabled = true
    	bp.bakeChannel = 1
    	bp.nDilations = 4
    
    --THIS WAS ALREADY DEFINED
    --	prjp = $.INodeBakeProjProperties
    	prjp.hitMatchMtlID = true
    	prjp.enabled = true
    	prjp.warnRayMiss = true
    
    --ADDING A SIZE VARIABLE
    	sz = 512
    
    	nmtest = Normalsmap()
    	nmtest.enabled = true
    	nmtest.outputSzX = nmtest.outputSzY = sz
    	nmtest.filenameUnique = true
    	nmtest.elementname = "Normal Map Test"
    --FILENAME PROPERTY DOESN'T WORK FOR ME, FILETYPE DOES THOUGH 
    --*SHRUGS*
    --	nmtest.filename = (maxfilepath + $.name + "_nmtest.tga")
    	nmtest.filetype = (maxfilepath + $.name + "_nmtest.tga")
    	bp.addBakeElement nmtest
    
    
    	-- Renders and Saves bitmap 
    	be = bp.getBakeElement 1 -- Assigns the obj bake element to the variable be
    
    --LETS JUST USE THE RENDER COMMAND
    --NO NEED TO SPECIFY OUTPUT FILE BECAUSE IT'S PART OF THE BAKE ELEMENT.
    
    	--RTTBigleyCastTools be.outputSzX be.outputSzY bp.bakeChannel bp.ndilations be.filename
    	render renderType:#bakeSelected frame:#current vfb:false outputwidth:sz outputheight:sz
    
    --I HAVEN'T FOUND A NEED TO COPY THE BITMAP
    
    -- if be.bitmap != undefined do
    -- 	(
    -- 		newbitmap =  bitmap be.outputSzX be.outputSzY
    
    -- 		copy be.bitmap newbitmap 
    -- 		--edtFilePath DOESN'T EXIST, I ASSUME THIS IS FROM A LARGER SCRIPT
    -- 		newbitmap.filename = edtFilePath.text
    -- 		display be.bitmap
    -- 		save newbitmap 
    
    -- 		close newbitmap
    -- 		close be.bitmap
    -- 	)
     )
    
  • jeremiah_bigley
    Options
    Offline / Send Message
    jeremiah_bigley polycounter lvl 12
    T.T My god! Thank you monster. I can't tell you how much I appreciate you taking the time to do that. I was stuck for a couple of days at least. That did the trick and think I am just about done with my script :D

    I clearly still have a lot to learn.
Sign In or Register to comment.