From d2425ca4f77740b53a0e293e9123a853a396397d Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 28 Feb 2003 22:53:33 +0000 Subject: [PATCH] maya 4.5 --- pandatool/src/maya/mayaApi.cxx | 17 +++++++++++++++++ pandatool/src/maya/maya_funcs.cxx | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/pandatool/src/maya/mayaApi.cxx b/pandatool/src/maya/mayaApi.cxx index 518ab46b23..5fdce8bc22 100644 --- a/pandatool/src/maya/mayaApi.cxx +++ b/pandatool/src/maya/mayaApi.cxx @@ -27,6 +27,10 @@ #include #include "post_maya_include.h" +#ifdef WIN32_VC +#include // for chdir() +#endif + MayaApi *MayaApi::_global_api = (MayaApi *)NULL; //////////////////////////////////////////////////////////////////// @@ -37,7 +41,19 @@ MayaApi *MayaApi::_global_api = (MayaApi *)NULL; //////////////////////////////////////////////////////////////////// MayaApi:: MayaApi(const string &program_name) { + // Beginning with Maya4.5, the call to initialize seems to change + // the current directory! Yikes! + Filename cwd = ExecutionEnvironment::get_cwd(); MStatus stat = MLibrary::initialize((char *)program_name.c_str()); + + // Restore the current directory. + string dirname = cwd.to_os_specific(); + if (chdir(dirname.c_str()) < 0) { + maya_cat.warning() + << "Unable to restore current directory to " << cwd + << " after initializing Maya.\n"; + } + if (!stat) { stat.perror("MLibrary::initialize"); _is_valid = false; @@ -151,6 +167,7 @@ read(const Filename &filename) { MFileIO::newFile(true); maya_cat.info() << "Reading " << filename << "\n"; + // Load the file into Maya string os_filename = filename.to_os_specific(); diff --git a/pandatool/src/maya/maya_funcs.cxx b/pandatool/src/maya/maya_funcs.cxx index c025fb00b4..a1cf5a8299 100644 --- a/pandatool/src/maya/maya_funcs.cxx +++ b/pandatool/src/maya/maya_funcs.cxx @@ -77,7 +77,7 @@ get_bool_attribute(MObject &node, const string &attribute_name, if (!get_maya_attribute(node, attribute_name, value)) { maya_cat.error() << "Attribute " << attribute_name - << " does not have an bool value.\n"; + << " does not have a bool value.\n"; describe_maya_attribute(node, attribute_name); return false; } @@ -267,7 +267,7 @@ set_string_attribute(MObject &node, const string &attribute_name, if (!get_maya_attribute(node, attribute_name, string_object)) { maya_cat.error() << "Attribute " << attribute_name - << " does not have an string object value.\n"; + << " does not have a string object value.\n"; describe_maya_attribute(node, attribute_name); return false; } @@ -291,7 +291,7 @@ set_string_attribute(MObject &node, const string &attribute_name, if (!set_maya_attribute(node, attribute_name, string_object)) { maya_cat.error() << "Attribute " << attribute_name - << " suddenly does not have an string object value.\n"; + << " suddenly does not have a string object value.\n"; return false; }