<s> import pymel . core as pm <EOL> def camera_film_offset_tool ( ) : <EOL> """<STR_LIT>""" <EOL> sel_list = pm . ls ( sl = <NUM_LIT:1> ) <EOL> camera_shape = "<STR_LIT>" <EOL> found_camera = <NUM_LIT:0> <EOL> for obj in sel_list : <EOL> if isinstance ( obj , pm . nt . Transform ) : <EOL> for shape in obj . listRelatives ( s = True ) : <EOL> if isinstance ( shape , pm . nt . Camera ) : <EOL> camera_shape = shape <EOL> found_camera = <NUM_LIT:1> <EOL> break <EOL> elif isinstance ( obj , pm . nt . Camera ) : <EOL> camera_shape = obj <EOL> found_camera = <NUM_LIT:1> <EOL> break <EOL> if found_camera : <EOL> pass <EOL> else : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> temp = camera_shape . listRelatives ( p = True ) <EOL> camera_transform = temp [ <NUM_LIT:0> ] <EOL> pm . getAttr ( "<STR_LIT>" ) <EOL> pm . getAttr ( "<STR_LIT>" ) <EOL> frame_curve = pm . curve ( <EOL> d = <NUM_LIT:1> , <EOL> p = [ ( - <NUM_LIT:0.5> , <NUM_LIT:0.5> , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:0.5> , <NUM_LIT:0.5> , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:0.5> , - <NUM_LIT:0.5> , <NUM_LIT:0> ) , <EOL> ( - <NUM_LIT:0.5> , - <NUM_LIT:0.5> , <NUM_LIT:0> ) , <EOL> ( - <NUM_LIT:0.5> , <NUM_LIT:0.5> , <NUM_LIT:0> ) ] , <EOL> k = [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] <EOL> ) <EOL> pm . parent ( frame_curve , camera_transform , r = True ) <EOL> frame_curve . tz . set ( - <NUM_LIT> ) <EOL> temp = pm . spaceLocator ( ) <EOL> adj_locator = temp <EOL> adj_locator_shape = temp <EOL> adj_locator . addAttr ( '<STR_LIT>' , at = '<STR_LIT:bool>' , dv = True , k = True ) <EOL> pm . parent ( adj_locator , frame_curve , r = True ) <EOL> pm . transformLimits ( adj_locator , tx = ( - <NUM_LIT:0.5> , <NUM_LIT:0.5> ) , etx = ( True , True ) ) <EOL> pm . transformLimits ( adj_locator , ty = ( - <NUM_LIT:0.5> , <NUM_LIT:0.5> ) , ety = ( True , True ) ) <EOL> pm . transformLimits ( adj_locator , sx = ( <NUM_LIT> , <NUM_LIT> ) , esx = ( True , True ) ) <EOL> adj_locator . tx >> camera_shape . pan . horizontalPan <EOL> adj_locator . ty >> camera_shape . pan . verticalPan <EOL> exp = '<STR_LIT>' '<STR_LIT>' '<STR_LIT>' % ( <EOL> camera_shape , camera_shape , frame_curve , frame_curve , frame_curve ) <EOL> pm . expression ( s = exp , o = '<STR_LIT>' , ae = <NUM_LIT:1> , uc = "<STR_LIT:all>" ) <EOL> adj_locator . sx >> adj_locator . sy <EOL> adj_locator . sx >> adj_locator . sz <EOL> adj_locator . sx >> camera_shape . zoom <EOL> adj_locator . enable >> camera_shape . panZoomEnabled <EOL> adj_locator_shape . localScaleZ . set ( <NUM_LIT:0> ) <EOL> adj_locator . tz . set ( lock = True , keyable = False ) <EOL> adj_locator . rx . set ( lock = True , keyable = False ) <EOL> adj_locator . ry . set ( lock = True , keyable = False ) <EOL> adj_locator . rz . set ( lock = True , keyable = False ) <EOL> adj_locator . sy . set ( lock = True , keyable = False ) <EOL> adj_locator . sz . set ( lock = True , keyable = False ) <EOL> def camera_focus_plane_tool ( ) : <EOL> """<STR_LIT>""" <EOL> camera = pm . ls ( sl = <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> camera_shape = camera . getShape ( ) <EOL> frame = pm . nurbsPlane ( <EOL> n = '<STR_LIT>' , <EOL> p = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) , ax = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) , w = <NUM_LIT:1> , lr = <NUM_LIT:1> , d = <NUM_LIT:1> , u = <NUM_LIT:1> , v = <NUM_LIT:1> , ch = <NUM_LIT:0> <EOL> ) [ <NUM_LIT:0> ] <EOL> frame_shape = frame . getShape ( ) <EOL> pm . parent ( frame , camera , r = True ) <EOL> frame . tz . set ( - <NUM_LIT> ) <EOL> exp = """<STR_LIT>""" % { <EOL> '<STR_LIT>' : camera_shape . name ( ) , <EOL> '<STR_LIT>' : frame . name ( ) <EOL> } <EOL> pm . expression ( s = exp , ae = <NUM_LIT:1> , uc = "<STR_LIT:all>" ) <EOL> surface_shader = pm . shadingNode ( '<STR_LIT>' , asShader = <NUM_LIT:1> ) <EOL> pm . select ( frame ) <EOL> pm . hyperShade ( a = surface_shader . name ( ) ) <EOL> surface_shader . setAttr ( '<STR_LIT>' , ( <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> surface_shader . setAttr ( '<STR_LIT>' , ( <NUM_LIT:0.5> , <NUM_LIT:0.5> , <NUM_LIT:0.5> ) ) <EOL> frame_shape . setAttr ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> frame_shape . setAttr ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> frame_shape . setAttr ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> frame_shape . setAttr ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> frame_shape . setAttr ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> frame_shape . setAttr ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> frame_shape . setAttr ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> frame_shape . setAttr ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> frame_shape . setAttr ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> frame_shape . setAttr ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> frame . setAttr ( '<STR_LIT>' , lock = True , keyable = False ) <EOL> frame . setAttr ( '<STR_LIT>' , lock = True , keyable = False ) <EOL> frame . setAttr ( '<STR_LIT>' , lock = True , keyable = False ) <EOL> frame . setAttr ( '<STR_LIT>' , lock = True , keyable = False ) <EOL> frame . setAttr ( '<STR_LIT>' , lock = True , keyable = False ) <EOL> frame . setAttr ( '<STR_LIT>' , lock = True , keyable = False ) <EOL> frame . setAttr ( '<STR_LIT>' , lock = True , keyable = False ) <EOL> frame . setAttr ( '<STR_LIT>' , lock = True , keyable = False ) <EOL> def cam_to_chan ( start_frame , end_frame ) : <EOL> """<STR_LIT>""" <EOL> selection = pm . ls ( sl = <NUM_LIT:1> ) <EOL> chan_file = pm . fileDialog2 ( cap = "<STR_LIT>" , fm = <NUM_LIT:0> , ff = "<STR_LIT>" ) [ <NUM_LIT:0> ] <EOL> camera = selection [ <NUM_LIT:0> ] <EOL> template = "<STR_LIT>" "<STR_LIT>" <EOL> lines = [ ] <EOL> for i in range ( start_frame , end_frame + <NUM_LIT:1> ) : <EOL> pm . currentTime ( i , e = True ) <EOL> pos = pm . xform ( camera , q = True , ws = True , t = True ) <EOL> rot = pm . xform ( camera , q = True , ws = True , ro = True ) <EOL> vfv = pm . camera ( camera , q = True , vfv = True ) <EOL> lines . append ( <EOL> template % { <EOL> '<STR_LIT>' : i , <EOL> '<STR_LIT>' : pos [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : pos [ <NUM_LIT:1> ] , <EOL> '<STR_LIT>' : pos [ <NUM_LIT:2> ] , <EOL> '<STR_LIT>' : rot [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : rot [ <NUM_LIT:1> ] , <EOL> '<STR_LIT>' : rot [ <NUM_LIT:2> ] , <EOL> '<STR_LIT>' : vfv <EOL> } <EOL> ) <EOL> with open ( chan_file , '<STR_LIT:w>' ) as f : <EOL> f . writelines ( '<STR_LIT:\n>' . join ( lines ) ) </s>
