Skip to content

Commit

Permalink
Merge pull request #3805 from Autodesk/bailp/EMSUSD-1343/disable-mat-…
Browse files Browse the repository at this point in the history
…for-dup

EMSUSD-1343 disable material in sync with meshes when duplicating
  • Loading branch information
seando-adsk authored Jun 10, 2024
2 parents 56fb9fc + fe16c86 commit b7e78d1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def _fillDuplicateAsUsdDataOptionsDialog(subLayout, optionsText, action):
cmds.setParent(subLayout)
mel.eval(
'''
mayaUsdTranslatorExport("{subLayout}", "{action}=all;!output", "{optionsText}", "")
mayaUsdTranslatorExport("{subLayout}", "{action}=all;!output;duplicate", "{optionsText}", "")
'''.format(optionsText=optionsText, subLayout=subLayout, action=action))

def _helpDuplicateAsUsdDataOptions(data=None):
Expand Down
27 changes: 26 additions & 1 deletion plugin/adsk/scripts/mayaUsdTranslatorExport.mel
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
global string $gMayaUsdTranslatorExport_SectionNames[];
global int $exportAll;
global int $gMayaUsdTranslatorExport_useShadingRegistry = 1;
global int $gMayaUsdTranslatorExport_MaterialsOnlyIfMeshes = 0;

proc string stringRemoveSuffix(string $object, string $suffix)
{
Expand Down Expand Up @@ -326,16 +327,32 @@ global proc mayaUsdTranslatorExport_MeshCB() {
if (`checkBoxGrp -exists exportMeshesCheckBox` == 0)
return;

mayaUsdTranslatorExport_updateDefaultPrimList();
int $enable = `checkBoxGrp -q -v1 exportMeshesCheckBox`;
columnLayout -e -enable $enable meshExportOptsCol;

mayaUsdTranslatorExport_MaterialsCB();
mayaUsdTranslatorExport_updateDefaultPrimList();
}

global proc mayaUsdTranslatorExport_MaterialsCB() {
if (`checkBoxGrp -exists exportMaterialsCheckBox` == 0)
return;

int $enable = `checkBoxGrp -q -v1 exportMaterialsCheckBox`;

// If materials export is linked to meshes export, then we disable
// all materials-related check-boxes when meshes are off. This is
// used in duplicate-to-USD to not duplicate materials without meshes.
global int $gMayaUsdTranslatorExport_MaterialsOnlyIfMeshes;
if ($gMayaUsdTranslatorExport_MaterialsOnlyIfMeshes) {
int $meshesEnable = `checkBoxGrp -q -v1 exportMeshesCheckBox`;
columnLayout -e -enable $meshesEnable materialOptsCol2;
columnLayout -e -enable $meshesEnable materialOptsCol;
if ($meshesEnable == 0) {
$enable = 0;
}
}

mayaUsdTranslatorExport_updateDefaultPrimList();
columnLayout -e -enable $enable materialOptsCol;
}
Expand Down Expand Up @@ -1066,6 +1083,8 @@ global proc int mayaUsdTranslatorExport (string $parent,
// check for export option box window first, if it doesn't exist means user opened the main export window
global string $gOptionBox;
global int $exportAll;
global int $gMayaUsdTranslatorExport_MaterialsOnlyIfMeshes;

if (`window -exists $gOptionBox`) {
string $title = `window -query -title $gOptionBox`;
if ($title == `uiRes("m_fileOptions.kExportAllOptions")`) {
Expand Down Expand Up @@ -1284,6 +1303,12 @@ global proc int mayaUsdTranslatorExport (string $parent,
setParent ..;
}

if (stringArrayContains("duplicate", $sectionNames)) {
$gMayaUsdTranslatorExport_MaterialsOnlyIfMeshes = 1;
} else {
$gMayaUsdTranslatorExport_MaterialsOnlyIfMeshes = 0;
}

$bResult = 1;

} else if ($action == "query") {
Expand Down

0 comments on commit b7e78d1

Please sign in to comment.