summaryrefslogtreecommitdiff
path: root/common/lc_application.cpp
diff options
context:
space:
mode:
authorleo2009-02-21 08:33:06 +0000
committerleo2009-02-21 08:33:06 +0000
commit83f1097598a63b64d2fec04f92f6f9c9e511b5af (patch)
tree83518aaf6991c8227ed939ad9be7351a6d08b14c /common/lc_application.cpp
parent98288502360f565f018b15e3437f8bc5a88c614e (diff)
Added support for importing pieces from the command line.
git-svn-id: http://svn.leocad.org/tags/leocad-0.75@738 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common/lc_application.cpp')
-rw-r--r--common/lc_application.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/common/lc_application.cpp b/common/lc_application.cpp
index ef57f5d..7743737 100644
--- a/common/lc_application.cpp
+++ b/common/lc_application.cpp
@@ -133,6 +133,9 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* SysLibPath)
// File to open.
char* ProjectName = NULL;
+ // First piece to import.
+ int ImportPieceArg = 0;
+
// Parse the command line arguments.
for (int i = 1; i < argc; i++)
{
@@ -180,6 +183,17 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* SysLibPath)
ImageInstructions = true;
else if (strcmp(Param, "--highlight") == 0)
ImageHighlight = true;
+ else if (strcmp(Param, "--importpieces") == 0)
+ {
+ if ((i == argc) || (argv[i+1][0] == '-'))
+ {
+ printf("Expected file name after --importpiece.");
+ return false;
+ }
+
+ ImportPieceArg = i+1;
+ break;
+ }
else if ((strcmp(Param, "-v") == 0) || (strcmp(Param, "--version") == 0))
{
printf("LeoCAD version " LC_VERSION_TEXT LC_VERSION_TAG " for "LC_VERSION_OSNAME"\n");
@@ -214,6 +228,7 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* SysLibPath)
printf(" --animation: Saves animations frames.\n");
printf(" --instructions: Saves instructions steps.\n");
printf(" --highlight: Highlight pieces in the steps they appear.\n");
+ printf(" --importpiece [file]: Import pieces into the library.\n");
printf(" \n");
}
else
@@ -387,6 +402,15 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* SysLibPath)
project->OnNewDocument();
}
+ if (ImportPieceArg)
+ {
+ for (int i = ImportPieceArg; i < argc; i++)
+ if (!ImportLDrawPiece(argv[i]))
+ break;
+
+ return false;
+ }
+
return true;
}