Skip to content

Commit bf1f539

Browse files
EMSUSD-3841 Add copy and repaths export flag
Only enabled for component creator exports. - Added a `copyAndRepathMaterials` (`-crm`) flag to the `mayaUSDExport` command. - Added documentation about the new flag. - Added `copyAndRepathMaterials` option in the `UsdMayaJobExportArgs` class. - Added `copyAndRepathMaterials` to the job export tokens. - Added `copyAndRepathMaterials` to the default merge options. - Added `Copy and Repath` check-box in the export UI, enabled for `createComponent` exports.
1 parent 398a58c commit bf1f539

8 files changed

Lines changed: 25 additions & 0 deletions

File tree

lib/mayaUsd/commands/Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ their own purposes, similar to the Alembic export chaser example.
212212
| `-selection` | `-sl` | noarg | false | When set, only selected nodes (and their descendants) will be exported |
213213
| `-stripNamespaces` | `-sn` | bool | false | Remove namespaces during export. By default, namespaces are exported to the USD file in the following format: nameSpaceExample_pPlatonic1 |
214214
| `-hideSourceData` | `-hsd` | bool | false | Hide the Maya nodes that were used as the source. |
215+
| `-copyAndRepathMaterials` | `-crm` | bool | false | Copy and repath materials. |
215216
| `-worldspace` | `-wsp` | bool | false | Export all root prim using their full worldspace transform instead of their local transform |
216217
| `-staticSingleSample` | `-sss` | bool | false | Converts animated values with a single time sample to be static instead |
217218
| `-geomSidedness` | `-gs` | string | derived | Determines how geometry sidedness is defined. Valid values are: `derived` - Value is taken from the shapes doubleSided attribute, `single` - Export single sided, `double` - Export double sided |

lib/mayaUsd/commands/baseExportCommand.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ MSyntax MayaUSDExportCommand::createSyntax()
135135
kHideSourceDataFlag,
136136
UsdMayaJobExportArgsTokens->hideSourceData.GetText(),
137137
MSyntax::kBoolean);
138+
syntax.addFlag(
139+
kCopyAndRepathMaterialsFlag,
140+
UsdMayaJobExportArgsTokens->copyAndRepathMaterials.GetText(),
141+
MSyntax::kBoolean);
138142
syntax.addFlag(
139143
kEulerFilterFlag, UsdMayaJobExportArgsTokens->eulerFilter.GetText(), MSyntax::kBoolean);
140144
syntax.addFlag(

lib/mayaUsd/commands/baseExportCommand.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class MAYAUSD_CORE_PUBLIC MayaUSDExportCommand : public MPxCommand
6060
static constexpr auto kMergeTransformAndShapeFlag = "mt";
6161
static constexpr auto kStripNamespacesFlag = "sn";
6262
static constexpr auto kHideSourceDataFlag = "hsd";
63+
static constexpr auto kCopyAndRepathMaterialsFlag = "crm";
6364
static constexpr auto kExportRefsAsInstanceableFlag = "eri";
6465
static constexpr auto kExportDisplayColorFlag = "dsp";
6566
static constexpr auto kExportDistanceUnitFlag = "edu";

lib/mayaUsd/fileio/jobs/jobArgs.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,8 @@ UsdMayaJobExportArgs::UsdMayaJobExportArgs(
765765
, preserveUVSetNames(extractBoolean(userArgs, UsdMayaJobExportArgsTokens->preserveUVSetNames))
766766
, stripNamespaces(extractBoolean(userArgs, UsdMayaJobExportArgsTokens->stripNamespaces))
767767
, hideSourceData(extractBoolean(userArgs, UsdMayaJobExportArgsTokens->hideSourceData))
768+
, copyAndRepathMaterials(
769+
extractBoolean(userArgs, UsdMayaJobExportArgsTokens->copyAndRepathMaterials))
768770
, worldspace(extractBoolean(userArgs, UsdMayaJobExportArgsTokens->worldspace))
769771
, writeDefaults(extractBoolean(userArgs, UsdMayaJobExportArgsTokens->writeDefaults))
770772
, parentScope(extractAbsolutePath(userArgs, UsdMayaJobExportArgsTokens->parentScope))
@@ -936,6 +938,7 @@ std::ostream& operator<<(std::ostream& out, const UsdMayaJobExportArgs& exportAr
936938
out << "stripNamespaces: " << TfStringify(exportArgs.stripNamespaces) << std::endl
937939
<< "worldspace: " << TfStringify(exportArgs.worldspace) << std::endl
938940
<< "hideSourceData: " << TfStringify(exportArgs.hideSourceData) << std::endl
941+
<< "copyAndRepathMaterials: " << TfStringify(exportArgs.copyAndRepathMaterials) << std::endl
939942
<< "timeSamples: " << exportArgs.timeSamples.size() << " sample(s)" << std::endl
940943
<< "staticSingleSample: " << TfStringify(exportArgs.staticSingleSample) << std::endl
941944
<< "geomSidedness: " << TfStringify(exportArgs.geomSidedness) << std::endl
@@ -1228,6 +1231,7 @@ const VtDictionary& UsdMayaJobExportArgs::GetDefaultDictionary()
12281231
d[UsdMayaJobExportArgsTokens->jobContext] = std::vector<VtValue>();
12291232
d[UsdMayaJobExportArgsTokens->stripNamespaces] = false;
12301233
d[UsdMayaJobExportArgsTokens->hideSourceData] = false;
1234+
d[UsdMayaJobExportArgsTokens->copyAndRepathMaterials] = false;
12311235
d[UsdMayaJobExportArgsTokens->worldspace] = false;
12321236
d[UsdMayaJobExportArgsTokens->verbose] = false;
12331237
d[UsdMayaJobExportArgsTokens->staticSingleSample] = false;
@@ -1336,6 +1340,7 @@ const VtDictionary& UsdMayaJobExportArgs::GetGuideDictionary()
13361340
d[UsdMayaJobExportArgsTokens->jobContext] = _stringVector;
13371341
d[UsdMayaJobExportArgsTokens->stripNamespaces] = _boolean;
13381342
d[UsdMayaJobExportArgsTokens->hideSourceData] = _boolean;
1343+
d[UsdMayaJobExportArgsTokens->copyAndRepathMaterials] = _boolean;
13391344
d[UsdMayaJobExportArgsTokens->worldspace] = _boolean;
13401345
d[UsdMayaJobExportArgsTokens->verbose] = _boolean;
13411346
d[UsdMayaJobExportArgsTokens->staticSingleSample] = _boolean;

lib/mayaUsd/fileio/jobs/jobArgs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ TF_DECLARE_PUBLIC_TOKENS(
123123
(remapUVSetsTo) \
124124
(stripNamespaces) \
125125
(hideSourceData) \
126+
(copyAndRepathMaterials) \
126127
(verbose) \
127128
(staticSingleSample) \
128129
(geomSidedness) \
@@ -289,6 +290,7 @@ struct UsdMayaJobExportArgs
289290
const bool preserveUVSetNames;
290291
const bool stripNamespaces;
291292
const bool hideSourceData;
293+
const bool copyAndRepathMaterials;
292294
// Export root prims using their worldspace transform instead of local transform.
293295
const bool worldspace;
294296
// Write default values at default time.

lib/mayaUsd/resources/scripts/mayaUsdMergeToUSDOptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,4 +283,5 @@ def getDefaultMergeToUSDOptionsDict():
283283
"stripNamespaces": 0,
284284
"worldspace": 0,
285285
"hideSourceData": 0,
286+
"copyAndRepathMaterials": 0,
286287
}

plugin/adsk/scripts/mayaUSDRegisterStrings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@
248248
"kExportWorldspaceLbl": "Worldspace Roots",
249249
"kHideSourceDataAnn": "Hide the Maya nodes that are used as the source data.",
250250
"kHideSourceDataLbl": "Hide Source Data",
251+
"kCopyAndRepathMaterialsAnn": "<b>Copy and Repath</b><br>Copies texture and material files to the export location and repaths references to the copied files.",
252+
"kCopyAndRepathMaterialsLbl": "Copy and Repath",
251253
"kExportRootPrimAnn": "Name the root/parent prim for your exported data.",
252254
"kExportRootPrimLbl": "Create Root Prim:",
253255
"kExportRootPrimPht": "USD Prim Name",

plugin/adsk/scripts/mayaUsdTranslatorExport.mel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,8 @@ global proc mayaUsdTranslatorExport_SetFromOptions(string $currentOptions, int $
979979
mayaUsdTranslatorExport_SetCheckbox($optionBreakDown[1], $enable, "worldspaceCheckBox");
980980
} else if ($optionBreakDown[0] == "hideSourceData") {
981981
mayaUsdTranslatorExport_SetCheckbox($optionBreakDown[1], $enable, "hideSourceDataCheckBox");
982+
} else if ($optionBreakDown[0] == "copyAndRepathMaterials") {
983+
mayaUsdTranslatorExport_SetCheckbox($optionBreakDown[1], $enable, "copyAndRepathMaterialsCheckBox");
982984
}
983985
}
984986

@@ -1157,6 +1159,7 @@ global proc int mayaUsdTranslatorExport (string $parent,
11571159
int $canExportStagesAsRefs = 1;
11581160
int $canControlUpAxisAndUnit = 1;
11591161
int $canHideSourceData = 0;
1162+
int $cancopyAndRepathMaterials = 0;
11601163
int $canSetAccessibility = 1;
11611164

11621165
if (stringArrayContains("duplicate", $sectionNames)) {
@@ -1167,6 +1170,7 @@ global proc int mayaUsdTranslatorExport (string $parent,
11671170

11681171
if (stringArrayContains("createComponent", $sectionNames)) {
11691172
$canHideSourceData = 1;
1173+
$cancopyAndRepathMaterials = 1;
11701174
}
11711175

11721176
if (stringArrayContains("mergeToUSD", $sectionNames)) {
@@ -1292,6 +1296,10 @@ global proc int mayaUsdTranslatorExport (string $parent,
12921296
menuItem -l `getMayaUsdString("kExportRelativeTexturesAbsoluteLbl")` -ann "absolute";
12931297
menuItem -l `getMayaUsdString("kExportRelativeTexturesRelativeLbl")` -ann "relative";
12941298

1299+
if ($cancopyAndRepathMaterials) {
1300+
checkBoxGrp -label "" -label1 `getMayaUsdString("kCopyAndRepathMaterialsLbl")` -annotation `getMayaUsdString("kCopyAndRepathMaterialsAnn")` copyAndRepathMaterialsCheckBox;
1301+
}
1302+
12951303
separator -style "none";
12961304
setParent ..;
12971305
setParent ..;
@@ -1487,6 +1495,7 @@ global proc int mayaUsdTranslatorExport (string $parent,
14871495
$currentOptions = mayaUsdTranslatorExport_AppendOppositeFromCheckbox($currentOptions, "stripNamespaces", "includeNamespacesCheckBox");
14881496
$currentOptions = mayaUsdTranslatorExport_AppendFromCheckbox($currentOptions, "worldspace", "worldspaceCheckBox");
14891497
$currentOptions = mayaUsdTranslatorExport_AppendFromCheckbox($currentOptions, "hideSourceData", "hideSourceDataCheckBox");
1498+
$currentOptions = mayaUsdTranslatorExport_AppendFromCheckbox($currentOptions, "copyAndRepathMaterials", "copyAndRepathMaterialsCheckBox");
14901499
$currentOptions = mayaUsdTranslatorExport_AppendFromCheckbox($currentOptions, "exportStagesAsRefs", "exportStagesAsRefsCheckBox");
14911500
$currentOptions = mayaUsdTranslatorExport_AppendFromPopup($currentOptions, "upAxis", "upAxisPopup");
14921501
$currentOptions = mayaUsdTranslatorExport_AppendFromPopup($currentOptions, "unit", "unitPopup");

0 commit comments

Comments
 (0)