Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Maya - Publishing camera from renderlayer creates untitled collections #6091

Open
2 tasks done
BigRoy opened this issue Dec 27, 2023 · 0 comments
Open
2 tasks done
Labels
Good first issue Simpler issues that are easy to understand and implement host: Maya type: bug Something isn't working

Comments

@BigRoy
Copy link
Collaborator

BigRoy commented Dec 27, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior:

When publishing a camera instance whilst currently in a render setup layer and having the default setting enabled for Enable untitled collections when new objects are created the baked camera (only used for the export) gets added into an untitled collection.

image

image

The maya setting is documented here.

Expected Behavior:

  1. Leave the scene unaltered. As such, make sure to leave no trailing collection.
  2. Another question of course would be whether we'd even want to export from an active renderlayer to begin with - but I suppose that's a separate issue.

Context manager

We could use a context manager to ensure the setting is disabled.
Either setting the option var, or the environment variable.

Not preferred:

from maya import cmds
import contextlib


@contextlib.contextmanager
def rendersetup_use_untitled_collections_context(value):
    key = "renderSetup_useUntitledCollections"
    if cmds.optionVar(exists=key):
        original_value = cmds.optionVar(query=key)
    else:
        original_value = None
        
    try:
        cmds.optionVar(intValue=(key, int(value)))
        yield
    finally:
        # Revert original value
        if original_value is None:
            cmds.optionVar(remove=True)
        else:
            cmds.optionVar(intValue=(key, original_value))

Since The environment variable takes precedence over the preference I'd say we should use the environment variable instead.

Preferred:

import os
import contextlib


@contextlib.contextmanager
def rendersetup_use_untitled_collections_context(value):
    key = "MAYA_RENDER_SETUP_USE_UNTITLED_COLLECTIONS"
    original_value = os.getenv(key)
        
    try:
        # Allow only 1 or 0 as string value
        os.environ[key] = str(int(bool(value)))
        yield
    finally:
        # Revert original value
        if original_value is None:
            del os.environ[key]
        else:
            os.environ[key] = value


# Example
with rendersetup_use_untitled_collections_context(False):
    cmds.polyCube()

Version

3.18.2-nightly.4

What platform you are running OpenPype on?

Windows

Steps To Reproduce:

  1. Create camera
  2. Create camera instance
  3. Create and activate a render setup layer
  4. Have Enable untitled collections when new objects are created setting enabled
  5. Publish camera

There will now be a trailing (invalid) collection generated from the publish.

Are there any labels you wish to add?

  • I have added the relevant labels to the bug report.

Relevant log output:

No response

Additional context:

No response

[cuID:OP-7982]

@BigRoy BigRoy added type: bug Something isn't working host: Maya Good first issue Simpler issues that are easy to understand and implement labels Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Simpler issues that are easy to understand and implement host: Maya type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant