From 86588b7add4ebab6956deb98805db2e5d0ef07ff Mon Sep 17 00:00:00 2001 From: Daniele Zaccaria Date: Fri, 10 Dec 2021 14:24:09 +0100 Subject: [PATCH] parent place holder to selection --- openpype/hosts/maya/api/lib_template_builder.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/maya/api/lib_template_builder.py b/openpype/hosts/maya/api/lib_template_builder.py index 1d425c7b254..84baa6199ce 100644 --- a/openpype/hosts/maya/api/lib_template_builder.py +++ b/openpype/hosts/maya/api/lib_template_builder.py @@ -1,7 +1,7 @@ import maya.cmds as cmds from avalon.maya.lib import imprint from avalon.vendor import qargparse -from avalon.tools.widgets import OptionDialog +from openpype.tools.utils.widgets import OptionDialog from avalon.maya.pipeline import get_main_window @@ -100,9 +100,14 @@ def create_placeholder(): # custom arg parse to force empty data query # and still imprint them on placeholder # and getting items when arg is of type Enumerator + # get maya selection + selection = cmds.ls(selection=True) options = {str(arg): arg._data.get("items") or arg.read() for arg in args if not type(arg) == qargparse.Separator} placeholder = cmds.spaceLocator(name="_TEMPLATE_PLACEHOLDER_")[0] + # if something is selected parent the placeholder to the first selection + if selection: + cmds.parent(placeholder, selection[0]) imprint(placeholder, options) # Some tweaks because imprint force enums to to default value so we get