summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dxfdim.cc4
-rw-r--r--src/import.cc3
-rw-r--r--src/linearextrude.cc3
-rw-r--r--src/module.cc5
-rw-r--r--src/openscad.cc3
-rw-r--r--src/rotateextrude.cc3
-rw-r--r--src/surface.cc3
7 files changed, 17 insertions, 7 deletions
diff --git a/src/dxfdim.cc b/src/dxfdim.cc
index 555ed49..66842d2 100644
--- a/src/dxfdim.cc
+++ b/src/dxfdim.cc
@@ -30,6 +30,7 @@
#include "dxfdata.h"
#include "builtin.h"
#include "printutils.h"
+#include "fileutils.h"
#include "evalcontext.h"
#include "mathc99.h"
@@ -54,7 +55,8 @@ Value builtin_dxf_dim(const Context *ctx, const EvalContext *evalctx)
// See issue #217
for (size_t i = 0; i < evalctx->numArgs(); i++) {
if (evalctx->getArgName(i) == "file")
- filename = evalctx->getAbsolutePath(evalctx->getArgValue(i).toString());
+ filename = lookup_file(evalctx->getArgValue(i).toString(),
+ evalctx->documentPath(), ctx->documentPath());
if (evalctx->getArgName(i) == "layer")
layername = evalctx->getArgValue(i).toString();
if (evalctx->getArgName(i) == "origin")
diff --git a/src/import.cc b/src/import.cc
index bd8f830..bb44d70 100644
--- a/src/import.cc
+++ b/src/import.cc
@@ -33,6 +33,7 @@
#include "dxfdata.h"
#include "dxftess.h"
#include "printutils.h"
+#include "fileutils.h"
#include "handle_dep.h" // handle_dep()
#ifdef ENABLE_CGAL
@@ -97,7 +98,7 @@ AbstractNode *ImportModule::instantiate(const Context *ctx, const ModuleInstanti
PRINT("DEPRECATED: filename= is deprecated. Please use file=");
}
}
- std::string filename = inst->getAbsolutePath(v.isUndefined() ? "" : v.toString());
+ std::string filename = lookup_file(v.isUndefined() ? "" : v.toString(), inst->path(), ctx->documentPath());
import_type_e actualtype = this->type;
if (actualtype == TYPE_UNKNOWN) {
std::string extraw = boosty::extension_str( fs::path(filename) );
diff --git a/src/linearextrude.cc b/src/linearextrude.cc
index c64a235..3b9db02 100644
--- a/src/linearextrude.cc
+++ b/src/linearextrude.cc
@@ -29,6 +29,7 @@
#include "module.h"
#include "evalcontext.h"
#include "printutils.h"
+#include "fileutils.h"
#include "builtin.h"
#include "PolySetEvaluator.h"
#include "openscad.h" // get_fragments_from_r()
@@ -74,7 +75,7 @@ AbstractNode *LinearExtrudeModule::instantiate(const Context *ctx, const ModuleI
if (!file.isUndefined()) {
PRINT("DEPRECATED: Support for reading files in linear_extrude will be removed in future releases. Use a child import() instead.");
- node->filename = inst->getAbsolutePath(file.toString());
+ node->filename = lookup_file(file.toString(), inst->path(), c.documentPath());
}
// if height not given, and first argument is a number,
diff --git a/src/module.cc b/src/module.cc
index 9503f05..8b84c07 100644
--- a/src/module.cc
+++ b/src/module.cc
@@ -71,7 +71,10 @@ IfElseModuleInstantiation::~IfElseModuleInstantiation()
/*!
Returns the absolute path to the given filename, unless it's empty.
- */
+
+ NB! This will actually search for the file, to be backwards compatible with <= 2013.01
+ (see issue #217)
+*/
std::string ModuleInstantiation::getAbsolutePath(const std::string &filename) const
{
if (!filename.empty() && !boosty::is_absolute(fs::path(filename))) {
diff --git a/src/openscad.cc b/src/openscad.cc
index 6a0d057..7c54762 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -359,7 +359,8 @@ int main(int argc, char **argv)
fs::path fpath = boosty::absolute(fs::path(filename));
fs::path fparent = fpath.parent_path();
fs::current_path(fparent);
-
+ top_ctx.setDocumentPath(fparent.string());
+
AbstractNode::resetIndexCounter();
absolute_root_node = root_module->instantiate(&top_ctx, &root_inst, NULL);
diff --git a/src/rotateextrude.cc b/src/rotateextrude.cc
index 2f9a28b..e073a69 100644
--- a/src/rotateextrude.cc
+++ b/src/rotateextrude.cc
@@ -28,6 +28,7 @@
#include "module.h"
#include "evalcontext.h"
#include "printutils.h"
+#include "fileutils.h"
#include "builtin.h"
#include "polyset.h"
#include "visitor.h"
@@ -70,7 +71,7 @@ AbstractNode *RotateExtrudeModule::instantiate(const Context *ctx, const ModuleI
if (!file.isUndefined()) {
PRINT("DEPRECATED: Support for reading files in rotate_extrude will be removed in future releases. Use a child import() instead.");
- node->filename = inst->getAbsolutePath(file.toString());
+ node->filename = lookup_file(file.toString(), inst->path(), c.documentPath());
}
node->layername = layer.isUndefined() ? "" : layer.toString();
diff --git a/src/surface.cc b/src/surface.cc
index b3246c1..46ddc07 100644
--- a/src/surface.cc
+++ b/src/surface.cc
@@ -30,6 +30,7 @@
#include "evalcontext.h"
#include "builtin.h"
#include "printutils.h"
+#include "fileutils.h"
#include "handle_dep.h" // handle_dep()
#include "visitor.h"
@@ -82,7 +83,7 @@ AbstractNode *SurfaceModule::instantiate(const Context *ctx, const ModuleInstant
c.setVariables(args, evalctx);
Value fileval = c.lookup_variable("file");
- node->filename = inst->getAbsolutePath(fileval.isUndefined() ? "" : fileval.toString());
+ node->filename = lookup_file(fileval.isUndefined() ? "" : fileval.toString(), inst->path(), c.documentPath());
Value center = c.lookup_variable("center", true);
if (center.type() == Value::BOOL) {
contact: Jan Huwald // Impressum