Reminder: this is about the import() function, which reads a data file
and returns it as OpenSCAD data. It's distinct from the import()
module, which reads a geometry file and adds it to the model.
PR #6993 https://github.com/openscad/openscad/pull/6993 (merged
yesterday) tightens up the rules for the experimental import() function,
and prepares it for future expansion.
Before: import() of any file would attempt to read it as a JSON file.
For some file types (e.g. DXF, some CSV) this would "succeed", but the
result would be useless: it would return the number at the top of the
file, and ignore the rest.
Now: The file type is inferred from the file extension or, if
necessary, can be explicitly specified with the new "type" parameter.
This is an incompatible change, in that before this change you could be
reading a JSON file with a name that doesn't end in .json, and after
this change that won't work and in that case you must explicitly specify
type="json".
The actual import functionality remains unchanged. The only file format
supported is JSON, with the file extension ".json" and type "json".
I've updated (rewritten, actually) the section in the manual:
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Importing_Geometry#import()_function:_Importing_data
Note: I realized that maybe the data type should be expressed as a MIME
type, so that we're using somebody else's namespace. That's a possible
future change; it would change the type to "application/json".
Examples:
Old New Notes
x = import("foo.json");
Unchanged.
x = import("foo"); x = import("foo", type="json"); Original now fails.
x = import("foo.dxf"); x = import("foo.dxf", type="json"); Original
now fails. Both will "succeed", but neither will do anything useful.
x = import("foo.csv"); x = import("foo.csv", type="json"); Original
now fails. Both might or might not "succeed", but will probably not be
useful.
x = import("foo.csv"); Maybe some day we might support true CSV import.