Access comp preferences via script

User avatar
bryanfordney
Fusioneer
Posts: 99
Joined: Tue Jan 29, 2019 1:10 pm
Location: Atlanta, GA
Been thanked: 5 times

Access comp preferences via script

#1

Post by bryanfordney » Tue Jul 16, 2019 11:09 am

I can't figure out how to access comp preferences (such as the frame format, framerate, etc) via scripting. They don't appear to be attributes of the comp, but must be stored somewhere else?

Thanks!
by Movalex » Tue Jul 16, 2019 12:43 pm
Check ==comp.GetPrefs() for clues.
Here's also a small tool script that sets comp default frame size and pixel aspect ratio based on Loader's properties:

Code: Select all

def main(tool):
attrs = tool.GetAttrs()
width = attrs['TOOLIT_Clip_Width'][1]
height = attrs['TOOLIT_Clip_Height'][1]

comp.SetPrefs({'Comp.FrameFormat.Width': width,
'Comp.FrameFormat.Height': height})

print('Comp size is set to {}x{}'.format(int(width), int(height)))

try:
aspect_x = attrs['TOOLN_ImageAspectX']
aspect_y = attrs['TOOLN_ImageAspectY']
except KeyError:
print('To set defaut pixel aspect ratio, add the Loader to the viewer')
aspect_x = aspect_y = None

if aspect_x and aspect_y:
comp.SetPrefs({'Comp.FrameFormat.AspectX': aspect_x,
'Comp.FrameFormat.AspectY': aspect_y})

print('Comp pixel aspect is set to {}:{}'.format(aspect_x, aspect_y))

comp.SetPrefs({'Comp.FrameFormat.Name': 'Set by Script'})

if tool.ID == 'Loader':
main(tool)
else:
print('this tool script works with Loaders only')
Go to full post

User avatar
Movalex
Sir Requestalot
Posts: 154
Joined: Fri Nov 03, 2017 5:36 am
Answers: 2
Been thanked: 44 times
Contact:

Re: Access comp preferences via script

#2

Post by Movalex » Tue Jul 16, 2019 12:43 pm

Check ==comp.GetPrefs() for clues.
Here's also a small tool script that sets comp default frame size and pixel aspect ratio based on Loader's properties:
  1. def main(tool):
  2.     attrs = tool.GetAttrs()
  3.     width = attrs['TOOLIT_Clip_Width'][1]
  4.     height = attrs['TOOLIT_Clip_Height'][1]
  5.  
  6.     comp.SetPrefs({'Comp.FrameFormat.Width': width,
  7.                    'Comp.FrameFormat.Height': height})
  8.  
  9.     print('Comp size is set to {}x{}'.format(int(width), int(height)))
  10.  
  11.     try:
  12.         aspect_x = attrs['TOOLN_ImageAspectX']
  13.         aspect_y = attrs['TOOLN_ImageAspectY']
  14.     except KeyError:
  15.         print('To set defaut pixel aspect ratio, add the Loader to the viewer')
  16.         aspect_x = aspect_y = None
  17.  
  18.     if aspect_x and aspect_y:
  19.         comp.SetPrefs({'Comp.FrameFormat.AspectX': aspect_x,
  20.                        'Comp.FrameFormat.AspectY': aspect_y})
  21.  
  22.         print('Comp pixel aspect is set to {}:{}'.format(aspect_x, aspect_y))
  23.  
  24.     comp.SetPrefs({'Comp.FrameFormat.Name': 'Set by Script'})
  25.  
  26. if tool.ID == 'Loader':
  27.     main(tool)
  28. else:
  29.     print('this tool script works with Loaders only')
You do not have the required permissions to view the files attached to this post.