fix container id uniqueness for each class instance

This commit is contained in:
Jakub Jezek 2021-11-23 14:39:27 +01:00
parent af0dd3856f
commit 1263d969e0
No known key found for this signature in database
GPG key ID: D8548FBF690B100A
2 changed files with 13 additions and 4 deletions

View file

@ -49,8 +49,11 @@ def get_review_presets_config():
class NukeLoader(api.Loader):
container_id_knob = "containerId"
container_id = ''.join(random.choice(
string.ascii_uppercase + string.digits) for _ in range(10))
container_id = None
def reset_container_id(self):
self.container_id = ''.join(random.choice(
string.ascii_uppercase + string.digits) for _ in range(10))
def get_container_id(self, node):
id_knob = node.knobs().get(self.container_id_knob)
@ -67,13 +70,16 @@ class NukeLoader(api.Loader):
source_id = self.get_container_id(node)
if source_id:
node[self.container_id_knob].setValue(self.container_id)
node[self.container_id_knob].setValue(source_id)
else:
HIDEN_FLAG = 0x00040000
_knob = anlib.Knobby(
"String_Knob",
self.container_id,
flags=[nuke.READ_ONLY, HIDEN_FLAG])
flags=[
nuke.READ_ONLY,
HIDEN_FLAG
])
knob = _knob.create(self.container_id_knob)
node.addKnob(knob)

View file

@ -67,6 +67,9 @@ class LoadClip(plugin.NukeLoader):
def load(self, context, name, namespace, options):
# reste container id so it is always unique for each instance
self.reset_container_id()
is_sequence = len(context["representation"]["files"]) > 1
file = self.fname.replace("\\", "/")