Making a script stop a render/network render until the script is okayed by a user

Hi all, I started this script

http://www.scriptspot.com/3ds-max/scripts/hide-and-unhide-all-bones-and-...

and as you can tell it's very basic. Tassel came up with a more user friendly version and i'd like to enhance my script.

What I'd like to achieve is when this script is added to the pre-render scripts area, the script halts rendering until the relevant buttons are pressed. I'll add a "Render" button to it, but forst you pick "Hide Bones" to hide them and when you click the render button, max then renders the image.

The scripts i attached to my upload dont have any use inteface and just run "behind the scenes". This was intentional so that a user can add them and forget them.

But now i'd like to add some functionality, but still keep the script able to be used in the pre-render area if possible. Presently, with Tassel's version loaded in, the script opens the dialog, but the render happens anyway before you've told it to hide/unhide bones.

So, is there a fumction i can use to halt rendering while the script is active?

 

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
le1setreter's picture

good part

found a good part by ZeBoxx2 on cgtalk:

http://forums.cgsociety.org/showpost.php?p=5177416&postcount=6

i did a rough stitching of both scripts. put the attached version in your script/startup folder:

-- var for checking if bone check has been done before:
lastRenderChecked = false 
 
-- your script: 
-- Create a rollout
rollout roll_SB_Tools "SB Tools V1.0"
(
-- UI STUFF
group "Hide / Unhide (Bones And Helpers)"
(
button btn_SBHide "..:: HIDE ::.." width:85 height:24 align:#left tooltip:"Hide bones and helpers" across:2
button btn_SBUnhide "..:: UNHIDE ::.." width:85 height:24 align:#right tooltip:"UN-Hide bones and helpers"
)
group "Render"
(
button btn_render "..::RENDER::.." width:85 height:24 align:#left tooltip:"Press to start rendering"
)
 
HyperLink hl_homepage "..:: MY SCRIPTS ::.." address:"http://www.scriptspot.com/users/script-butler/" color:(color 255 255 255) hovercolor:(color 111 111 111) visitedcolor:(color 255 255 255) height:22 align:#center
-------------------------------------------------------------------------------------------------------------------------------------------------------
-- GROUP "Hide / Unhide (bones and helpers)"
-------------------------------------------------------------------------------------------------------------------------------------------------------
on btn_SBHide pressed do
(
hideByCategory.bones = true
hideByCategory.helpers = true
)
 
on btn_SBUnhide pressed do
(
hideByCategory.bones = false
hideByCategory.helpers = false
)
-------------------------------------------------------------------------------------------------------------------------------------------------------
-- GROUP "Render"
-------------------------------------------------------------------------------------------------------------------------------------------------------
on btn_render pressed do -- I'M UNSURE ON SCRIPTING COMMANDS TO MAKE THE RENDER HAPPEN
(
	lastRenderChecked = true -- disabling the check request window
	destroyDialog roll_SB_Tools -- closing current dialog
	max quick render -- starting the rendering
	lastRenderChecked = false -- enabling the check request window 
)
-------------------------------------------------------------------------------------------------------------------------------------------------------
 
) -- End of script
 
--Create the dialog and stuff -- disbaled dialog here:
-- createDialog roll_SB_Tools width:200 height:150
 
 
 
 
 
 
 
 
dialogMonitorOps.unRegisterNotification id:#renderConfirm
 
 fn renderConfirmationDialog = (
 
 	local hwnd = dialogMonitorOps.getWindowHandle()
	-- check if rendering is on progress and if bones has been checked before:
 	if (uiAccessor.getWindowText hwnd == "Rendering") and (lastRenderChecked == false) do (
 		if (querybox "Check Bones before Rendering?") do ( 
			-- cancel current rendering:
			uiAccessor.pressButtonByName hwnd "Cancel"
			-- creating dialog with bones
			createDialog roll_SB_Tools width:200 height:150
		)
	) 
 	true
 )
 
 dialogMonitorOps.enabled = true
 dialogMonitorOps.interactive = false
 dialogMonitorOps.registerNotification renderConfirmationDialog id:#renderConfirm
AttachmentSize
ms_renderconfirm.ms 2.93 KB
Script_Butler's picture

Slight tweak....

Thanks for this find le1setreter, i added it in to my startup scripts and did a test, it works well. But, when i add it to the Pre-render list, it's not so usable because it gets stuck in a loop. Because of the Render button on my script, when that is pressed, the script gets loaded again and you keep going through the same process.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Attached is a version where I've got rid of the render button and made the other two buttons render directly after they have been pressed. It's still got the loop problem, which can be negotiated but it's very annoying!

 

You have to say yes to "check bones before rendering", click the "hide" bones button, then click no to the "check bones before rendering when it comes up again.

I also deleted your part of the script and it seems to work still so i'm not entirely sure if your find was needed, but to be honest i don't quite know how i've made that happen without your part in.

 

I've attached it because i don't know how to add my script in to a window like you did.........by doing that, does all the colour formatting stay?

PS> I've managed to google how to create a scroll box, but when i add my script in (by copying and pasting directly from MAXScript) when i preview my post the scroll box dissapears......

AttachmentSize
hideunhide_1.02_test.ms 1.75 KB

Cheers.

Script_Butler

le1setreter's picture

hi Script_Butler, hmm... what

hi Script_Butler,

hmm... what do you exactly mean with "Pre-render list"? do you mean a callbacks.addScript #preRender? if yes is it really neccessary?
why not just put my script into script/startup?

i know the loop problem and it was annoying for me too. that has been the reason why i worked with the variable "lastRenderChecked" to not get the render confirmation request after being in the hide/unhide bones dialog.

the reason why i (or better said others) used the "dialogMonitorOps" is some kind of workaround to cancel/stop/kill the already startet render! i could not find another way to cancel a render via script.

using the messagebox, querybox or yesNoCancelBox also do some pausing while you can do changes before rendering but you are limited to the properties of these boxes/windows.

the code box can be done like this but without the space after "<":
< code>
your code in here (copyNpaste)
< /code>

Script_Butler's picture

Pre-render list

Hello.

If you open up the Render dialog, there is a scripts rollout.

The first part is the Pre render list. Bassically i want my script to be added in there so the user can load it in just for certain maxfiles and whenever they hit render it loads the scripts listed.

If you look at my script page http://www.scriptspot.com/3ds-max/scripts/hide-and-unhide-all-bones-and-... you will see i included two scripts one for pre-render and one for pos-render.

The reason i want this script to be added in there is so that my script automatically gets run every time a render is needed and that way you don't forget to run the script or hide the bones.

If you put your version in to the startup folder it will run in every single maxfile. If you add it in the pre-render list it's on a per maxfile basis which is better in my opinion. Your version can be used either way though!

I guess theres no way around the loop? Could it be scripted so that the query box button "Yes" hides the bones and renders and the "no" button unhides the bones and renders? Looking at that piece of script i don't think it can.

Cheers.

Script_Butler

tassel's picture

Hi, You can use "render()" Or

Hi,

You can use "render()"

Or an example of rendering in you own Renderbuffer (VFB or what they call it these days)

on btn_render pressed do
(
RenderWindow = bitmap renderwidth renderheight --(W/H is collected from Render Settings. if you want a specified size just write "bitmap 200 200" or whatever)
displayRenderWindow
Render to:RenderWindow

escapeEnable = true
rendersavefile = false
)

/ Raymond

Script_Butler's picture

Pre-render loading script issue....

Cheers for that Tassel,

But it still doesn't solve the problem if the script is loaded in to the Pre-render list.

Is it possible to have a script that when run stops rendering until a button is pressed?

Cheers.

Script_Butler

tassel's picture

Do you you talking about

Do you you talking about "Pause" the render?

/ Raymond

Script_Butler's picture

I think that will work. I

I think that will work.

I appreciate if the script is run during normal max usage, the user can click on the render button and render the image.

But because I'd like my version to be usable when added in to the pre-render list, it would need an option to pause the render silently and then the user can turn off bones and click render!

Does that make sense?

Cheers.

Script_Butler

br0t's picture

just to note, there is a

just to note, there is a (code) ... (/code) context in this forum, (will work if you replace the round brackets with square brackets: [ ]) which will make your code much more readably through color coding :)

Never get low & slow & out of ideas

Script_Butler's picture

Code Context

Thanks Br0t.

 

I will utilise this. Cool

Cheers.

Script_Butler

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.