Accessing Film Gate / Film Back attribute

199 views
Skip to first unread message

likage

unread,
Jun 20, 2016, 6:00:41 PM6/20/16
to Python Programming for Autodesk Maya
I am trying to write a check in which it will checks for the camera's film gate/ film back.
Currently within my list of options in the film gate/film backs contains 2 similar format names and their values (hor., ver. aperture is the same).

For example, 35mm delivery, 35mm default.

Should the camera be set to a 'default' naming format, it will prompt up a list of 'delivery' formats (created using pyqt combobox)
However I do not know how I should access this Film Gate / Film Back attribute..

Andres Weber

unread,
Jun 21, 2016, 3:17:07 PM6/21/16
to Python Programming for Autodesk Maya
 I'm not sure I understand you right in regards to the delivery/default thing...but accessing film back is easy:
cmds:
import maya.cmds as cmds

cmds.getAttr("myCameraShape.horizontalFilmAperture")
cmds.getAttr("myCameraShape.verticalFilmAperture")

pymel:
pm.PyNode('myCamera').getShape().horizontalFilmAperture.get()
pm.PyNode('myCamera').getShape().verticalFilmAperture.get()

default value for setting/getting is in inches so be sure to do your conversion from mm if you need to.

likage

unread,
Jun 21, 2016, 5:16:39 PM6/21/16
to Python Programming for Autodesk Maya
Hi there,
So if you create a camera >> Attribute Editor, under the Film Back section, there is this field called Film Gate.
Suppose this camera of mine, its Film Gate is called '35mm Default' and I had wanted to access/modify this attribute to '35mm Delivery'

However in these 2 Film Gates, their Aperature values are the same except for its naming.
How can I change the Film Gate?

As for your code, it is only accessing the horizontal and vertical aperture values in which it is something related but not I want..

Cesar Saez

unread,
Jun 22, 2016, 5:40:16 AM6/22/16
to python_in...@googlegroups.com
Those are hardcoded presets, you can see what's going on by inspecting.

/usr/autodesk/maya/scripts/AETemplates/AEcameraFilmbackNew.mel
(/usr/autodesk/maya/ is the directory where maya is installed on linux, replace it for whatever makes sense in your system)

Said that, I would not recommend you to modify/hack that file, maintain custom AETemplates is not fun at all.
If anything I would create my own generic templates, it's not more than a dictionary mapping attrName/value exported in a markup language (json, yaml or whatever makes sense to you) and a for loop setting those values or populating the dictionary.

Good luck!

likage

unread,
Jun 23, 2016, 2:43:01 PM6/23/16
to Python Programming for Autodesk Maya
While I am able to append the lists of formats by using the following code:
import maya.cmds as cmds


formatLs
= Format.showDefaults()
wrkLs
= []
for i in formatLs:
   
if 'Working Extractions' in str(i):
          wrkLs
.append(i)


def printNewFormat(item):
   
print item


window
= cmds.window()
cmds
.columnLayout()    
cmds
.optionMenu (label = 'Select a format', changeCommand = printNewFormat)
for x in wrkLs:
    cmds
.menuItem(label=x)


cmds
.showWindow( window )


I am still unable to append / change the film format of the selected camera to the option chosen in the ui, which is something I am having trouble with at the moment..

Need some insights on that

Andres Weber

unread,
Jun 23, 2016, 3:21:57 PM6/23/16
to Python Programming for Autodesk Maya
I'm assuming Format is a custom class that you've created?

In either case what Cesar mentioned is still applicable in this instance.  You need to hardcore a look up dictionary based on the format names for each preset film back:

format_lookup_table = {'16mm Theatrical': [0.404, 0.295],
                                   'Super 16mm': [0.493, 0.292'],
                                   <ETC>}

Then you can use that to convert between the strings that you're listing as the options and the preset film backs.  I didn't check out the AETemplate that Cesar mentioned but I assume you could source the values from that file (also depending on if they set more than just the film backs...but I'm pretty sure that's all they do?).  Then you'd just use the code I provided to actually set the film backs for the specified cameras based on the values from the key you're giving the look up table.

likage

unread,
Jun 23, 2016, 3:40:11 PM6/23/16
to Python Programming for Autodesk Maya
Hi there,

yes, Format is a custom class that looks up on the list of formats

In my case, in the list - wrkLs that I have created, it will simply append the name of formats as it print something like [<Format 'Working Extractions/35 mm' object at 0x765413696>, ... , <Format 'Working Extractions/HD 1080-2' object at 0x765778418>] etc

As for the mel files mentioned - AEcamerFilmbackNew.mel, it has 4 functions namely : 
  • AEresetFilmbackMenu
  • AEwhichCameraFilmback
  • AEcameraFilmbackReplace
  • AEcameraFilmbackNew
and all 4 needs to have 3 arguements called eg. AEcameraFilmbackReplace (string $hor, string $ver, string $squ)
Reply all
Reply to author
Forward
0 new messages