PDA

View Full Version : Confused by Net Render Syntax


Coll
01-07-2009, 06:28 PM
I've only been using Maxscript for a day, so I'm sorry if this is an obvious question, but I'm totally bewildered by the help file's description of how to do stuff with Net Render.

I'm writing a script that will automate a tedious process I have to do a lot; rotating, renaming and rendering the same scene over and over. I have most of the other stuff working, but getting it to connect to Manager (kind of important) is still greek to me.

I need to:

1. Open the Net Render settings
2. Connect to the servers
3. Rename the job
4. Verify that "Use Maps" is on
5. Submit the job

My main problem with the Help file is that they seem to be pulling variables out of midair, which makes it hard to follow. If someone could point me to a tutorial or something, I'd be very grateful.

PiXeL_MoNKeY
01-07-2009, 06:46 PM
A little more info is needed to help you. Do you want to use the net render interface to submit the jobs or 3dsmaxcmd.exe or some other method? I have used the netrender interface in the past, but now I use the 3dsmaxcmd.exe to submit jobs using the HiddenDOSCommand. Are you using a mixed renderfarm 32bit/64bit machines (this is very important and is undocumented in the help)?

-Eric

Coll
01-07-2009, 06:55 PM
Good gravy, Monkey. Is there any part of Max you aren't an expert in? Every time I post one of these idiot beginner questions you're all over it :D


I'm afraid I don't know what 3dsmaxcmd.exe is. My experience with Net Render thus far has all been the direct approach, using the Render Scene dialogue to open the Network Job Assignment window. I can say, however, that we're only using 32-bit servers.

PiXeL_MoNKeY
01-07-2009, 07:16 PM
Ok, well since you want to use "include maps" you will need to use the NetRender Interface (for more info on this check the Maxscript Help for netrender interface should be the second returned option). So now we will start, there are a few things you need to do to submit jobs: 1) You must connect to the manager before you can submit or modify jobs.
2) You need to create the parameters for your jobs, prior to submitting.
3) Submit the job.
So here we go:/*Get and then connect to the manager*/
mngr = NetRender.GetManager() -- get an instance of the manager
if mngr.connected == false do ( -- check if you are already connected
mngr.connect #automatic "255.255.255.0" platform:#32-- connect to the manager if not already connected and force 32bit mode
--platform is an undocumented parameter used to connect to the manager for access to 32bit or 64bit jobs. You can only connect to one at a time.
)
/*Now that we have access to the manager we need to prepare the job for submission*/
job = mngr.newJob() -- create a new job
job.name = "New Job" -- assign a name to the job. this should be a unique name, replace this string with what you want.
/*From here you can set just about anything else you need.*/
job.includemaps = true -- set includemaps to true for the job
job.frameoutputname = @"\\path\path\Someoutputname.ext" -- here you supply the output information for this job. Replace the string with what you want.
/*Once done setting your render parameters you need to simply submit the job*/
job.Submit()So there you go let me know if you have any more questions.

-Eric

Coll
01-07-2009, 07:58 PM
Thanks a lot! Hopefully that will work nicely

One last thing. Do you know of a way to add a Browse button to the rollout? I want the user to be able to choose the directory the render will be going to.

ZeBoxx2
01-07-2009, 08:06 PM
use a regular button and in its 'on <button> pressed' event, use getSaveFileName() or getSavePath() (see help file) to get the filename/folder to save to, store that in a variable that gets used when the actual render is executed

Coll
01-08-2009, 12:49 PM
Okay, I ran a test sequence last night for good measure. All you guys' advice worked great, but I'm still hitting roadblocks. I think setting the output name in the nework code is causing problems. I'm having trouble dynamically adding the file extension to the code, which means that the manager doesn't know what kind of file to make, which means they aren't rendering. Also, the script I was using to rotate the model (selObj.object.rotation.z_rotation + 45) Doesn't seem to work. I've also tried

rot_obj = eulerangles 0 0 45
rotate selObj.object rot_obj

with the same lack of success.

I hate to keep pestering you guys for advice, but I'm pretty lost here.

PiXeL_MoNKeY
01-08-2009, 02:28 PM
I'm having trouble dynamically adding the file extension to the code, which means that the manager doesn't know what kind of file to make, which means they aren't rendering.Could you post the portion of the code that shows what you are doing? It should be as simple as just adding it as part of the string in the frameoutputname parameter. Now if you need to set specific settings for the output then that needs to be handled through that plugins interface. So what format(s) are you wanting to use and what settings need to be set?

-Eric

PiXeL_MoNKeY
01-08-2009, 02:35 PM
Also, the script I was using to rotate the model (selObj.object.rotation.z_rotation + 45) Doesn't seem to work. I've also tried

rot_obj = eulerangles 0 0 45
rotate selObj.object rot_obj

with the same lack of success.What is .object? .object is not a parameter of most objects so that is probably where your issue is coming from. Again post the code you are trying to use so we can see how you are setting selObj and what you are trying to access. Also, are you trying to rotate around World or Local Z? This code works here for rotating around world Z: rot_obj = eulerangles 0 0 45
rotate selObj rot_obj-Eric

diffx
01-08-2009, 02:50 PM
Basic netrender setup.

Thanks Eric. Saves me some setup time for my new test project.

Coll
01-08-2009, 05:13 PM
SelObj is a pickbutton. Object refers to the object chosen. Or at least, I think it does.

As for the whole file extension thing, it has apparantly fixed itself. However, I was wondering if there was any way to specify that wou want to safe an 8-bit png?

ZeBoxx2
01-08-2009, 05:53 PM
saving to PNG is easy enough - set the filename extension to ".png"
8-bit is the more difficult bit - have a play with the PNGio interface:

showinterfaces PNGio
Interface: ipngio
Properties:
Methods:
<enum>getType()
getType enums: {#paletted|#true24|#true48|#gray8|#gray16
<void>setType <enum>type
type enums: {#paletted|#true24|#true48|#gray8|#gray16}
<boolean>getAlpha()
<void>setAlpha <boolean>useAlpha
<boolean>getInterlaced()
<void>setInterlaced <boolean>Interlaced
Actions:


However, I'm not entirely clear on how / if this actually gets stored with the scene file for file output straight out of the render (i.e. not handled yourself by saving the bitmap via scripting). Max is severely lacking the bitmap i/o access as far as that goes.

PiXeL_MoNKeY
01-08-2009, 05:58 PM
SelObj is a pickbutton. Object refers to the object chosen. Or at least, I think it does.Again code will help. Most of the time when using a pickbutton the code is executed after the pick using the on <pickbutton> picked <arg> do <expr> syntax. In which you would do the rotation on the <arg> and not the button object.As for the whole file extension thing, it has apparantly fixed itself. However, I was wondering if there was any way to specify that wou want to safe an 8-bit png?This is available through the PNG (Portable Network Graphics) Interface. This should do what you want:ipngio.setType #true24-Eric

PiXeL_MoNKeY
01-08-2009, 06:02 PM
However, I'm not entirely clear on how / if this actually gets stored with the scene file for file output straight out of the render (i.e. not handled yourself by saving the bitmap via scripting). Max is severely lacking the bitmap i/o access as far as that goes.Which is part of the reason I have moved to the 3dsmaxcmd route, as you can define the output parameters that are sent with the file for some types of files. However, there are limitations to the 3dsmaxcmd route as well, like no include maps option.

-Eric

Coll
01-08-2009, 07:31 PM
Again code will help. Most of the time when using a pickbutton the code is executed after the pick using the on <pickbutton> picked do syntax. In which you would do the rotation on the and not the button object.

This isn't quite what I need. The purpose of the script is to render the scene, rotate an object, render again, in a For Loop. The pickbutton is so the user can select the object they want to rotate. I need to be able to rotate the picked object later on, not right when it's picked.

PiXeL_MoNKeY
01-08-2009, 08:55 PM
Ok it looks like you need to assign the picked object to a variable:on selObj picked obj do (
pickObj = selObj.object
)From there you should be able to call your rotation code on pickObj.rot_obj = eulerangles 0 0 45
rotate pickObj rot_objHope that helps,
-Eric

Coll
01-09-2009, 02:29 PM
I'm having a bit of trouble implementing the rotation, though I don't think it's being caused by the Pickbutton. It keeps returning the error "No ""rotate"" function for undefined." This happens even if I nake a new Maxscript containing only the rotation command and name the object I want to rotate directly.

Also, it says it doesn't recognise

ipngio.setType #true24

Is there some specific place it needs to go, or something I need to open?

PiXeL_MoNKeY
01-09-2009, 02:59 PM
Hard to diagnose without seeing a file and code. If its returning undefined then you are calling rotate on something that has no object assigned to it.

-Eric

PiXeL_MoNKeY
01-09-2009, 03:01 PM
ipngio.setType #true24Sorry trying to do too much at once. It should be:portable_network_graphics.setType #true24-Eric

Coll
01-09-2009, 06:21 PM
This is frustrating. Rotating the object is the last hurdle, and after getting it to net render it should be easy. I assign the clicked object to the variable PickedONJ, like you suggested. I print it immediately and it comes back

$Plane:Plane01 @ [67.962395,-1.970469,-29.78515

But then in the For loop the script thinks it's undefined, Is it getting dumped? Is it not getting carried into the loop?

On the bright side, that PNG thing isn;t returning an error anymore, so it seems to be working

PiXeL_MoNKeY
01-09-2009, 06:24 PM
Can't answer it without seeing the code where you are assigning the object and the for loop code. It could also be a scope issue you may need to define PickedONJ as a global variable.

-Eric

Coll
01-09-2009, 06:29 PM
Okay, here's the whole thing (My apologies to any actual programmers I offend) :P

dirArray = #(" back ", " back left ", " left ", " front left ", " front ", " front right "," right "," back right ") --these are automatically appended to the end of the Sequence Name to create the filename, for the different views (Assumes you start with the character's back to you)
totalAngles = 0 --keeps track of how many individual jobs have been sent to Backburner. This number is automatically appended to the Job Name, to keep track of them

createDialog myWin

rollout myWin "Sprite Renderer" width:432 height:287
(
checkbox symClick "Render One Side Only (For Symmetrical Models)" pos:[93,16] width:245 height:15 --you can flip the existing frames to get the other side. Hooray for efficiency!
pickbutton selObj "Choose Control Object" pos:[156,136] width:120 height:24 toolTip:"Choose the character's parent object. The script will rotate it on the Z axis to create the different views"

button btnGo "Go to it!" pos:[168,163] width:98 height:24

edittext fileName text:rendOutputFilename pos:[32,56] width:284 height:24
label lbl2 "Filepath:" pos:[192,40] width:48 height:16
label lbl3 "Sequence Name" pos:[168,88] width:96 height:16
edittext seqName "" pos:[32,104] width:368 height:24
edittext errorBox "" pos:[81,192] width:275 height:21 enabled:false
button btnReset "Reset Control Object" pos:[156,232] width:120 height:32
button btnPath "Browse" pos:[325,56] width:74 height:26

on selObj picked obj do
(
--if the user did not cancel the picking...
if obj != undefined do
(
--display the name of the object on the button:
pickedObj = obj
print pickedObj
selObj.text = obj.name
)
)
on btnGo pressed do
(
if selObj.object != undefined and seqName.text != "" do --if acontrol object and sequence name are chosen
(
case symClick.checked of
(
true: renderNum = 5
false: renderNum = 8
)

for i = 1 to renderNum do
(

print (seqName.text + dirArray [i])

/*Get and then connect to the manager*/
mngr = NetRender.GetManager() -- get an instance of the manager
if mngr.connected == false do -- check if you are already connected
(
mngr.connect #automatic "255.255.255.0" platform:#32-- connect to the manager if not already connected and force 32bit mode
--platform is an undocumented parameter used to connect to the manager for access to 32bit or 64bit jobs. You can only connect to one at a time.
)
/*Now that we have access to the manager we need to prepare the job for submission*/
job = mngr.newJob() -- create a new job
suffix = totalAngles as string
job.name = (seqName.text + suffix) -- assign a name to the job. this should be a unique name, replace this string with what you want.
/*From here you can set just about anything else you need.*/
job.includemaps = true -- set includemaps to true for the job
job.frameoutputname = (fileName.text + dirArray [i] + ".png") -- here you supply the output information for this job. Replace the string with what you want.

print job.frameoutputname
/*Once done setting your render parameters you need to simply submit the job*/
job.Submit()
portable_network_graphics.setType #true24
totalAngles = totalAngles + 1

-- selObj.object.wirecolour
rot_obj = eulerangles 0 0 45
rotate pickedObj rot_obj
--selObj.object.rotation.z_rotation = selObj.object.rotation.z_rotation + 45

)
print totalAngles

)
if seqName.text == "" do
(
errorBox.text = "You need a sequence name"
)
if selObj.object == undefined do
(
errorBox.text = "You need to choose a control object"
)
if pathIsNetworkPath fileName.text == false do
(
errorBox.text = "Net Render requires a network path"
)
)
on btnReset pressed do
(

)
on btnPath pressed do
fileName.text = getSaveFileName caption:"Save As:" initialDir:getOpenFileName
)

PiXeL_MoNKeY
01-10-2009, 07:09 AM
1) You should create your dialog after you define your rollout, not before.
2) You need to define pickedObj as a local or global variable in the macroscript or the rollout, that way it is available outside of the scope of the on picked event.
3) You need to replace all selObj.object with pickedObj, calling selObj.object outside the on picked event could cause scope issues.

Try those and see if it helps,
-Eric

Coll
01-12-2009, 12:47 PM
That's fantastic, Monkey! That fixed everything. The script works almost perfectly now. The only thing now is that I can't get it to render anything but frames 1-100. I tried setting rendtimetype to 2 in the net render code you gave me, to no avail. Am I putting it in the wrong place? Or better yet, is there a way to just pull the current selection from the Render Scene Dialogue?

PiXeL_MoNKeY
01-12-2009, 02:49 PM
First you need to add to your netrender code job.fromFrame and job.toFrame. These control the start and end frame of the job being submitted/altered. If you want to pull from the render dialog you would use:job.fromFrame = rendStart
job.toFrame = rendEndHowever, you will probably need to close the render scene dialog if it is open, because changes from the dialog aren't updated to maxscript calls until its closed or you call renderSceneDialog.commit() (NOTE: not everything in the dialog can be updated using the commit command). So some code to help there add this before your render loop:dialogOpen = renderSceneDialog.isOpen()
if dialogOpen == true do
(
dialogOpen = true
renderSceneDialog.close()
)Then add this after your render loop:if dialogOpen == true do
(
renderSceneDialog.open()
)The first set of code creates a dialogOpen variable and sets its value to true if the render scene dialog is open and false if it is closed. If dialogOpen is true then we set the variable to true and close the dialog. Now you would run your render loop. Then after the jobs are submitted we open the dialog back up if it was open before.

Hope that does it,
-Eric

Coll
01-12-2009, 04:05 PM
Monkey, I can't thank you enough for all your help with this. The app is still a little rickety, but I'm the only on who has to use it anyway. You have no idea how much time this is going to save me.

I really hate to ask for anything at this point, but the PNGs still aren't rendering as 8-bit, even with the code you gave me to set the type to 24. Is there a specific place the code needs to go?

also, I can't seem to alter the Nth frame settings, or import them from the Render Scene Dialogue.




edit: Oh, right. Job.nthFrame. Because it's not like we've used job. for every other thing we've worked on :P

mustan9
03-20-2009, 02:28 PM
Thanks Pixel_monkey!

Copy/pasted and it works. Just saved me some time. :)

Ok, well since you want to use "include maps" you will need to use the NetRender Interface (for more info on this check the Maxscript Help for netrender interface should be the second returned option). So now we will start, there are a few things you need to do to submit jobs: 1) You must connect to the manager before you can submit or modify jobs.
2) You need to create the parameters for your jobs, prior to submitting.
3) Submit the job.
So here we go:/*Get and then connect to the manager*/
mngr = NetRender.GetManager() -- get an instance of the manager
if mngr.connected == false do ( -- check if you are already connected
mngr.connect #automatic "255.255.255.0" platform:#32-- connect to the manager if not already connected and force 32bit mode
--platform is an undocumented parameter used to connect to the manager for access to 32bit or 64bit jobs. You can only connect to one at a time.
)
/*Now that we have access to the manager we need to prepare the job for submission*/
job = mngr.newJob() -- create a new job
job.name = "New Job" -- assign a name to the job. this should be a unique name, replace this string with what you want.
/*From here you can set just about anything else you need.*/
job.includemaps = true -- set includemaps to true for the job
job.frameoutputname = @"\\path\path\Someoutputname.ext" -- here you supply the output information for this job. Replace the string with what you want.
/*Once done setting your render parameters you need to simply submit the job*/
job.Submit()So there you go let me know if you have any more questions.

-Eric

PiXeL_MoNKeY
03-20-2009, 03:06 PM
Glad I could help Mathew, its good to know that I can save some other people some time. I have spent quite a bit of time investigating net render solutions.

For the most part now I have been using 3dsmaxcmd.exe to submit my jobs, because it offers some options that aren't available from the net render interface. Stuff like Output format parameters (only limited formats supported), single frame rendering, split scanlines, plus most of the other things I need. For proper submission management I use a combination of the net render interface (to check existing jobs, etc) and then 3dsmaxcmd.exe to submit new jobs. So far it has been working really well.

-Eric

mustan9
03-20-2009, 03:38 PM
Thanks for the advise. I might have to go in the direction later.

I've used Deadline and RPManager before for a couple of years. They work great, but I've always wanted a one click render button. Something smart that can process all the Max files for a project, figure out if it has changed, update character rigs with new animation, and submit everything to the farm.

All from one click :)

Maybe I'm dreaming, but I got files rendering now. Thanks for the help :)

PiXeL_MoNKeY
03-20-2009, 05:06 PM
Dreaming if you want it to magically happen without doing any work. You may look at Paul Neale's BatchItMax (http://www.paulneale.com/scripts/batchItMax/batchItMax.htm) script. You should be able to use the net render or 3dsmaxcmd.exe method with it. You will have to figure out the animation loading, and the "if it has changed" from someone else, since I don't do that in day to day work. My guess is you won't get a totally automated system, ie you may need to move files to a folder rather than having it know that something has changed, but it all should be possible.

Coll, did you ever get the png settings working? If not was everything else working as you need?

-Eric

CGTalk Moderation
03-20-2009, 05:06 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.