Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Batch Render Manager, scripting camera name

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
andrewjmorin
1609 Views, 10 Replies

Batch Render Manager, scripting camera name

 

When I run the following lines:

 

     vExp=batchRenderMgr.GetView 1
     vExp.camera = $CamKcg1

 

The BRM UI updates properly, but if my camera's name has a space or a dash it gets parsed improperly.

Can anyone tell me how to enter a camera name like "CamK-CG2" in my script?

 

I usually rely on the help docs, but I'm in over my head.

 

P.S. as long as I'm asking...

 

My plan is to script a routine to export BRM info to a space-delimited text file and a second script to re-import that. I have over 500 separate shots I'd like to cut between during this animation and I want/need the ability to spreadsheet wholesale changes to render resolution and whatnot during testing. So in my export script, what is the best way to extract a camera's node.name or string or whatever... these lines:

     

      nodeCamera=vExp.camera
      vCamera=nodeCamera as string

 

...give me a troublesome string that I'll have to walk through and snip up before I save it.

(e.g.: $Target_Camera:CamKcg1 @ [0.000000,-120.000000,245.499985] )

 

Thanks for reading, and for any hints you can give me!

 

10 REPLIES 10
Message 2 of 11
Swordslayer
in reply to: andrewjmorin

Message 3 of 11
andrewjmorin
in reply to: Swordslayer

\facepalm\

Perfect! Single quotes solves the first bit, thanks and kudos!

Message 4 of 11
andrewjmorin
in reply to: andrewjmorin

Okay, I'm further down the rabbit hole now.

 

I "filterString" each line from my exported text/data file into:

 

       lineMatrix: #("true", "true", "27260f", "27385f", "1920", "1080", "1.0", "167-K-01-a-m", "U:\Prohib\RenderOutput\K-01-a-m-167.png", "CamKa1")

 

Then I begin assigning each value to the Batch Render Manager view parameters:

 

       vExp = batchRenderMgr.createView  $Camera001   --Actually sets the view's camera to "Viewport" for some reason.
       vExp.enabled   = lineMatrix[1] as booleanclass
            --snipped out my list of other view parameter assignments, those all work fine
      
   --String for camera name is not converting to the format needed for assignment to BRM data.

       --One of the various Errors I've gotten is: "Unable to convert: #CamKa1 to type: <node>"
      
      CamName    = (( trimRight ( trimLeft lineMatrix[10] "\"" ) "\"" )) as name         -- removes the quotes from the "linematrix" string entries


      -- I've also tried things like: CamName    = ( "$" + "'" + ( trimright ( trimleft lineMatrix[10] "\"" ) "\"" ) + "'")


      -- and: CamName  = $'CamKa1'    --This works as a test, but does not interact with txt file
      
      vExp.camera   =  CamName 

 

 

So the Question is:

How can I retrieve a string from my text file (originally exported from Batch Render data) and

use that data (name of the camera?) to assign a camera to a new Batch Render View's camera property?

Message 5 of 11
Swordslayer
in reply to: andrewjmorin
Message 6 of 11
andrewjmorin
in reply to: Swordslayer

Oh, hay, look at that it works.

 

I had misunderstood you before, and tried to use getnodebyname before I exported to the text file, but now I've got it working during the import phase.

 

Thanks again!

Message 7 of 11
BurrowsTD
in reply to: andrewjmorin

Hi, Just seen your post. Have you resolved the issues you were having or do you still need some pointers?

 

The script I have written does the following:

 

UI to create cameras of different lenses, distances, target heigh and camera height aimed at a centralised location

Cameras are collected and stored in a dotnet treeview with Rclick features

User output location for renders

Folder and directory creation

Option for overwrite files

Batch render manager population

Deadline submission for network rendering.

 

Also, though you probably know this, if you have the BRM open while trying to update it, it will only do so once you close it and re open it.

 

I can certainly put up some code about the BRM if you still need it. Let me know what you are looking to achieve and I will see if what I have can help. In the meantime, here is a fundamental script that will take cameras from the scene and create views and output paths. You will see I have a generic path for the location, but you can adjust this to suit your needs. The full function I have in the script I am writing takes data from the UI I created to help the artist make cameras, not just ones that are already in scene, but it works just the same here. I have left out the parts where you need to set the range and output size. They should not be an issue if you look up the settings in the help files.

 

Also, I would look at sorting the arrays so that you get a ascending list in the BRM.

 

Hope the attached can help you and others if they need it.

 

 

Message 8 of 11
andrewjmorin
in reply to: BurrowsTD

Thanks TD, your code is very enlightening for me.

 

Swordslayer nailed the immediate issue so my baseline script does what I need now, which is store BRM data so I can make changes with the confidence that I have backups. I originally imported my BRM data from an Adobe Premiere "Edit Decision List", which provides shot names and in-out points (i.e time range). I've got a 20 minute green-screen episode to immerse in a CG environment. The next step is conjnecting Max cameras to each shot thus created in the BRM. Then I can use the BRM to render tests by altering the time ranges via script, and toggle back and forth with Final render resolutions and ranges. Not having that level of render-time control was a big hurdle in this (obviously indie) production.

Message 9 of 11
BurrowsTD
in reply to: andrewjmorin

Thank you for the kudos, I do believe that that is my first!

 

I have not used EDL files before, can they be opened or exposed to see the contents? There may be a way to read in the contents and filter it for the data you need, though this may not be the direction you want to go.

I will have to have a look into this as we use premiere at the studio and it may be something we can utilise.

 

Do you use any other languages i.e Python, XML etc? Could be a solution there as well.

 

Robot Happy

Message 10 of 11
andrewjmorin
in reply to: BurrowsTD

I try to keep my coding to a minimum these days, never learned the more modern languages.

I self-teach the scripting language of whatever software I'm using, as needed.

 

EDL is just a text-output file from premiere that lists the edit points of every block of time in a sequence.

Looks like:

5     00:00:15:05   00:00:26:05   Universal Counting Leader
7     00:00:30:16   00:00:34:08   D-01-a-m Side View Transport
9     00:00:35:06   00:00:40:06   Shot 0001-Transp Flyby-002.mov

 

(Index numbers 6 and 8 are blackspace on the timeline in that sample. The file usually begins at 1, numbering continuously.)

 

Here's all I do to import the EDL data &colon; ( I just 'execute all' from the script editor, haven't yet structured this as a function or anything...)

 

intViews= batchRenderMgr.numViews
global strOutputPath = "U:\\SWprohib\\RenderOutput\\"   --Path for video render file output
StrIntViews= intViews as string

-- clear out dialog
if querybox "Clear out Batch Render dialog entries?" beep:true do
for intCount=1 to intViews do
(
batchRenderMgr.DeleteView 1
)

-- Parse EDL file (txt file created from pPro exported "Edit Decision List" data)

global diaFileOpen = getOpenFileName caption:"Open EDL File:" filename:"U:\\prohib\\testEDL-01.txt"
global fsDataFile = openfile diaFileOpen mode:"rS"

while not eof fsDataFile do
(
global strFileTextLine = readline fsDataFile
if strFileTextLine != "" do
(
                lineMatrix = filterString strFileTextLine " "
camNumber = lineMatrix[1] 

beginTime = lineMatrix[2]
cBgT =filterString beginTime ":"
begintime = cBgT[2]+ "m" + cBgT[3] + "s" + cBgT[4]+ "f"
beginTime=beginTime as time

endTime = lineMatrix[3]
cEnT =filterString endTime ":"
endTime = cEnT[2]+ "m" + cEnT[3] + "s" + cEnT[4]+ "f"
endTime =endTime as time

viewName = lineMatrix[4]

--Create views from each line in EDL data file

RenderPathName = "aa"                                      -- add feature: type in or prompt user for output image file path
renderViewName =    camnumber+"-"+viewName                                           -- parse name from file
completeFilename =   strOutputPath + viewName + "-" + camNumber  + ".png"           -- concatenate string to pass

timeStartFrame =   beginTime - 5f                                     -- parse timecodes from file
timeEndFrame =  endTime + 5f                                      -- Add 5 frame heads/tails

outputWidth = 1920
outputHeight = 1080


newRenderView = batchRenderMgr.createView  $Camera001             -- wants a camera node argument here
newRenderView.enabled = true
newRenderView.overridePreset = true
newRenderView.startFrame = timeStartFrame
newRenderView.endFrame = timeEndFrame
newRenderView.width = outputWidth
newRenderView.height = outputHeight
newRenderView.pixelAspect = 1
newRenderView.name = renderViewName
/*
Trap error here?
"Runtime error: The parameter is invalid."
happens when view name already exists in list
*/
newRenderView.outputFilename =  completeFilename
newRenderView.camera=$'Target_Camera:CamK stab1'  --random default camera
)
)

 

 

 

Message 11 of 11
BurrowsTD
in reply to: andrewjmorin

I will have a look at this later today or tomorrow as I have got some stuff to finalise today. Does this do what you want or does it produce errors? As said, not had much time to look yet, but a laymans overview of the result will be handy as I will keep it in mind.

 

EDIT: Well, I guess I should have looked a little further down as I see you have a commented out part. Doh!

 

I am much the same with languages, I learn as I go, it works for me!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report