Merge pull request #3331 from pypeclub/feature/OP-3377_Use-query-functions-in-Blender

Blender: Use client query functions
This commit is contained in:
Jakub Trllo 2022-06-14 17:46:49 +02:00 committed by GitHub
commit da17bf0f8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 30 deletions

View file

@ -10,6 +10,7 @@ from . import ops
import pyblish.api
from openpype.client import get_asset_by_name
from openpype.pipeline import (
schema,
legacy_io,
@ -83,11 +84,9 @@ def uninstall():
def set_start_end_frames():
project_name = legacy_io.active_project()
asset_name = legacy_io.Session["AVALON_ASSET"]
asset_doc = legacy_io.find_one({
"type": "asset",
"name": asset_name
})
asset_doc = get_asset_by_name(project_name, asset_name)
scene = bpy.context.scene

View file

@ -1,13 +1,11 @@
import os
import json
from bson.objectid import ObjectId
import bpy
import bpy_extras
import bpy_extras.anim_utils
from openpype.pipeline import legacy_io
from openpype.client import get_representation_by_name
from openpype.hosts.blender.api import plugin
from openpype.hosts.blender.api.pipeline import AVALON_PROPERTY
import openpype.api
@ -131,43 +129,32 @@ class ExtractLayout(openpype.api.Extractor):
fbx_count = 0
project_name = instance.context.data["projectEntity"]["name"]
for asset in asset_group.children:
metadata = asset.get(AVALON_PROPERTY)
parent = metadata["parent"]
version_id = metadata["parent"]
family = metadata["family"]
self.log.debug("Parent: {}".format(parent))
self.log.debug("Parent: {}".format(version_id))
# Get blend reference
blend = legacy_io.find_one(
{
"type": "representation",
"parent": ObjectId(parent),
"name": "blend"
},
projection={"_id": True})
blend = get_representation_by_name(
project_name, "blend", version_id, fields=["_id"]
)
blend_id = None
if blend:
blend_id = blend["_id"]
# Get fbx reference
fbx = legacy_io.find_one(
{
"type": "representation",
"parent": ObjectId(parent),
"name": "fbx"
},
projection={"_id": True})
fbx = get_representation_by_name(
project_name, "fbx", version_id, fields=["_id"]
)
fbx_id = None
if fbx:
fbx_id = fbx["_id"]
# Get abc reference
abc = legacy_io.find_one(
{
"type": "representation",
"parent": ObjectId(parent),
"name": "abc"
},
projection={"_id": True})
abc = get_representation_by_name(
project_name, "abc", version_id, fields=["_id"]
)
abc_id = None
if abc:
abc_id = abc["_id"]