From 8ad54a4e5b298da31d2c2f0dcd31234f133802c9 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 29 Jul 2019 09:19:02 +0200 Subject: [PATCH] fix(nuke): setting resolution problem, _tool to _node name change --- pype/nuke/lib.py | 49 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/pype/nuke/lib.py b/pype/nuke/lib.py index a9aac47228..f6f6767163 100644 --- a/pype/nuke/lib.py +++ b/pype/nuke/lib.py @@ -43,7 +43,7 @@ def checkInventoryVersions(): container = avalon.nuke.parse_container(each) if container: - node = container["_tool"] + node = container["_node"] avalon_knob_data = get_avalon_knob_data(node) # get representation from io @@ -403,8 +403,8 @@ def reset_frame_range_handles(): # adding handle_start/end to root avalon knob if not avalon.nuke.set_avalon_knob_data(root, { - "handle_start": handle_start, - "handle_end": handle_end + "handle_start": int(handle_start), + "handle_end": int(handle_end) }): log.warning("Cannot set Avalon knob to Root node!") @@ -425,34 +425,25 @@ def reset_resolution(): asset = api.Session["AVALON_ASSET"] asset = io.find_one({"name": asset, "type": "asset"}) - try: - width = asset.get('data', {}).get('resolution_width', 1920) - height = asset.get('data', {}).get('resolution_height', 1080) - pixel_aspect = asset.get('data', {}).get('pixel_aspect', 1) - bbox = asset.get('data', {}).get('crop', "0.0.1920.1080") + width = asset.get('data', {}).get('resolution_width') + height = asset.get('data', {}).get('resolution_height') + pixel_aspect = asset.get('data', {}).get('pixel_aspect') - if bbox not in "0.0.1920.1080": - try: - x, y, r, t = bbox.split(".") - except Exception as e: - x = 0 - y = 0 - r = width - t = height - bbox = None - log.error("{}: {} \nFormat:Crop need to be set with dots, example: " - "0.0.1920.1080, /nSetting to default".format(__name__, e)) - else: - bbox = None - - except KeyError: - log.warning( - "No resolution information found for \"{0}\".".format( - project["name"] - ) - ) + log.info("pixel_aspect: {}".format(pixel_aspect)) + if any(not x for x in [width, height, pixel_aspect]): + log.error("Missing set shot attributes in DB. \nContact your supervisor!. \n\nWidth: `{0}` \nHeight: `{1}` \nPixel Asspect: `{2}`".format(width, height, pixel_aspect)) return + bbox = asset.get('data', {}).get('crop') + + if bbox: + try: + x, y, r, t = bbox.split(".") + except Exception as e: + bbox = None + log.error("{}: {} \nFormat:Crop need to be set with dots, example: " + "0.0.1920.1080, /nSetting to default".format(__name__, e)) + used_formats = list() for f in nuke.formats(): if project["name"] in str(f.name()): @@ -609,7 +600,7 @@ def get_hierarchical_attr(entity, attr, default=None): # dict # """ # -# node = container["_tool"] +# node = container["_node"] # tile_color = node['tile_color'].value() # if tile_color is None: # return {}