-
Notifications
You must be signed in to change notification settings - Fork 129
Houdini: support for id attribute for Houdini -> Maya lookdev #3312
Comments
For what it's worth - this is what we had sometimes used in a Python node in SOPs level in Houdini to create path consistent NEW import random
import uuid
from openpype.pipeline.context_tools import get_current_project_asset
def generate_id(path, asset_id):
"""Returns new unique ids for the given nodes.
Note: This does not assign the new ids, it only generates the values.
Args:
asset_id (str or bson.ObjectId): The database id for the *asset* to
generate for.
Returns:
str: single cbId
"""
uuid_ = str(uuid.uuid3(uuid.NAMESPACE_DNS, path))
_, uid = str(uuid_).rsplit("-", 1)
unique_id = "{}:{}".format(asset_id, uid)
return unique_id
# The seed should be random everywhere you create it but consistent in your Python node
# so that next time you open the scene it generates the same output.
seed_num = 0
random.seed(seed_num)
# Get the asset ID from the database for the asset of current context
asset_doc = get_current_project_asset(fields=["_id"])
assert asset_doc, "No current asset found in Session"
asset_id = asset_doc['_id']
cbId_attrib = geo.addAttrib(hou.attribType.Prim, "cbId", '')
prims = geo.prims()
for prim in prims:
path = prim.attribValue('path');
cbId = generate_id(path, asset_id)
prim.setAttribValue(cbId_attrib, cbId) OLD import random
import uuid
import avalon.io as io
import avalon.api as api
def generate_id(path, asset_id):
"""Returns new unique ids for the given nodes.
Note: This does not assign the new ids, it only generates the values.
Args:
asset_id (str or bson.ObjectId): The database id for the *asset* to
generate for.
Returns:
str: single cbId
"""
uuid_ = str(uuid.uuid3(uuid.NAMESPACE_DNS, path))
_, uid = str(uuid_).rsplit("-", 1)
unique_id = "{}:{}".format(asset_id, uid)
return unique_id
# The seed should be random everywhere you create it but consistent in your Python node
# so that next time you open the scene it generates the same output.
seed_num = 0
random.seed(seed_num)
# Get the asset ID from the database for the asset of current context
asset_data = io.find_one({"type": "asset",
"name": api.Session["AVALON_ASSET"]},
projection={"_id": True})
assert asset_data, "No current asset found in Session"
asset_id = asset_data['_id']
cbId_attrib = geo.addAttrib(hou.attribType.Prim, "cbId", '')
prims = geo.prims()
for prim in prims:
path = prim.attribValue('path');
cbId = generate_id(path, asset_id)
prim.setAttribValue(cbId_attrib, cbId) Notes:
It's important however to understand that I have never found a way to export from Houdini to Alembic |
The I'm closing this until there's a request to focus more on this in AYON. Feel free to re-open on |
Feature
Houdini currently doesn't generate and add
cbId
equivalent attribute so when you publish alembics from Houdini and you want to use them for lookdev in Maya, it will not work.There are few options to handle it:
[cuID:OP-3390]
The text was updated successfully, but these errors were encountered: