From 83f1097598a63b64d2fec04f92f6f9c9e511b5af Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 21 Feb 2009 08:33:06 +0000 Subject: 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 --- common/lc_application.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'common/lc_application.cpp') 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; } -- cgit v1.2.3