#include "util.h"
#include "NodeIteratorVisitorHelper.h"
#include "AbcImport.h"
#include <maya/MArgList.h>
#include <maya/MArgParser.h>
#include <maya/MFileIO.h>
#include <maya/MFileObject.h>
#include <maya/MGlobal.h>
#include <maya/MDGModifier.h>
#include <maya/MSelectionList.h>
#include <maya/MStringArray.h>
#include <maya/MString.h>
#include <maya/MSyntax.h>
#include <maya/MTime.h>
namespace
{
" \n\
AbcImport [options] File \n\n\
Options: \n\
-rpr/ reparent DagPath \n\
reparent the whole hierarchy under a node in the \n\
current Maya scene \n\
-ftr/ fitTimeRange \n\
Change Maya time slider to fit the range of input file. \n\
-rcs / recreateAllColorSets \n\
IC3/4fArrayProperties with face varying scope on \n\
IPolyMesh and ISubD are treated as color sets even if \n\
they weren't written out of Maya. \n\
-ct / connect string node1 node2 ... \n\
The nodes specified in the argument string are supposed to\
be the names of top level nodes from the input file. \n\
If such a node doesn't exist in the provided input file, a\
warning will be given and nothing will be done. \n\
If Maya DAG node of the same name doesn't exist in the \
current Maya scene, a warning will be given and nothing will be done. \n\
If such a node exists both in the input file and in the \
current Maya scene, data for the whole hierarchy from the nodes down \n\
(inclusive) will be substituted by data from the input file,\
and connections to the AlembicNode will be made or updated accordingly. \n\
If string \"/\" is used as the root name, all top level \
nodes from the input file will be used for updating the current Maya scene. \n\
Again if certain node doesn't exist in the current scene, \
a warning will be given and nothing will be done. \n\
If a single node is specified and it exists in the Maya \
scene but doesn't exist in the archive, children of that node will be connected\
to the children of the archive. \n\
-crt/ createIfNotFound \n\
Used only when -connect flag is set. \n\
-rm / removeIfNoUpdate \n\
Used only when -connect flag is set. \n\
-sts/ setToStartFrame \n\
Set the current time to the start of the frame range \n\
-m / mode string (\"open\"|\"import\"|\"replace\") \n\
Set read mode to open/import/replace (default to import)\n\
-ft / filterObjects \"regex1 regex2 ...\" \n\
Selective import cache objects whose name matches with \n\
-eft / excludeFilterObjects \"regex1 regex2 ...\" \n\
Selective exclude cache objects whose name matches with \n\
the input regular expressions. \n\
-h / help Print this message \n\
-d / debug Turn on debug message printout \n\n\
Example: \n\
AbcImport -h; \n\
AbcImport -d -m open \"/tmp/test.abc\"; \n\
AbcImport -ftr -ct \"/\" -crt -rm \"/mcp/test.abc\"; \n\
AbcImport -ct \"root1 root2 root3 ...\" \"/mcp/test.abc\"; \n"
);
};
AbcImport::AbcImport()
{
}
AbcImport::~AbcImport()
{
}
{
return syntax;
}
void* AbcImport::creator()
{
return new AbcImport();
}
{
bool swap = false;
bool createIfNotFound = false;
bool removeIfNoUpdate = false;
bool debugOn = false;
if (argData.isFlagSet("help"))
{
return status;
}
if (argData.isFlagSet("debug"))
debugOn = true;
if (argData.isFlagSet("reparent"))
{
status = argData.getFlagArgument("reparent", 0, parent);
&& getDagPathByName(parent, reparentDagPath) ==
MS::kSuccess)
{
reparentObj = reparentDagPath.
node();
}
else
{
theWarning +=
MString(
" is not a valid DagPath");
printWarning(theWarning);
}
}
if (!argData.isFlagSet("connect") && argData.isFlagSet("mode"))
{
argData.getFlagArgument("mode", 0, modeStr);
if (modeStr == "replace")
deleteCurrentSelection();
else if (modeStr == "open")
{
}
}
else if (argData.isFlagSet("connect"))
{
swap = true;
argData.getFlagArgument("connect", 0, connectRootNodes);
if (argData.isFlagSet("createIfNotFound"))
{
createIfNotFound = true;
}
if (argData.isFlagSet("removeIfNoUpdate"))
removeIfNoUpdate = true;
}
if (argData.isFlagSet("filterObjects"))
{
argData.getFlagArgument("filterObjects", 0, filterString);
}
if (argData.isFlagSet("excludeFilterObjects"))
{
argData.getFlagArgument("excludeFilterObjects", 0, excludeFilterString);
}
bool recreateColorSets = false;
if (argData.isFlagSet("recreateAllColorSets"))
{
recreateColorSets = true;
}
status = argData.getCommandArgument(0, filename);
{
{
MString alembicFileRule =
"alembicCache";
MString alembicFilePath =
"cache/alembic";
queryFileRuleCmd.
format(
"workspace -q -fre \"^1s\"",
alembicFileRule);
queryFolderCmd.
format(
"workspace -en `workspace -q -fre \"^1s\"`",
alembicFileRule);
{
}
{
expandName = alembicFilePath;
}
#if MAYA_API_VERSION < 201300
{
#else
#endif
MString absoluteFileName = directoryName +
"/" + filename;
}
else
{
}
}
{
ArgData inputData(filename, debugOn, reparentObj,
swap, connectRootNodes, createIfNotFound, removeIfNoUpdate,
recreateColorSets, filterString, excludeFilterString);
abcNodeName = createScene(inputData);
if (inputData.mSequenceStartTime != inputData.mSequenceEndTime &&
inputData.mSequenceStartTime != -DBL_MAX &&
inputData.mSequenceEndTime != DBL_MAX)
{
if (argData.isFlagSet("fitTimeRange"))
{
setPlayback(
}
if (argData.isFlagSet("setToStartFrame"))
{
}
}
}
else
{
MString theError(
"In AbcImport::doIt(), ");
theError += filename;
theError +=
MString(
" doesn't exist");
printError(theError);
}
}
return status;
}