Hi there,
I am working on a (sort of) general scad in wich I need to present certain objects that are set up as either STL or SVG formats.
These files are stored in the same folder as the scad script.
Example:
ImportAnObject="Select a base object"; //[None,PerfectHeart_Outline.svg,DraadLamp_Model01_Raam.svg,DraadLamp1_Kanaal.svg,DraadLamp_Model01_FilledFrame.svg,RealityScan_Kruidnagel_HD_Model_Simple50K.stl,DefaultEgg.stl,DefaultEgg_Horizontal.stl,Paashaas.stl,Scad_SpechtFrame.stl,Scad_SpechtSilouette.stl,SpechtSilouette.svg,SpechtSilouette_V3.svg]
But I need to alter the scad script itself when I need to add a new object that hes to show in the drop-down in the customizer.
So I want to create a JSON file in wich the names of these objects are listed and then import this JSON as the source of the objectnames as: ImportAnObject=import("ObjectFileNames.json");
But I get an error/warning:
Compiling design (CSG Tree generation)...
Can somebody please help me out how to get this working with an example for this problem?
Thanks,
Jos.
On 3/31/2026 1:13 AM, jos.richters--- via Discuss wrote:
So I want to create a JSON file in wich the names of these objects are
listed and then import this JSON as the source of the objectnames as:
ImportAnObject=import("ObjectFileNames.json");
You can import a JSON file for your program to operate on, and you're
doing it right. But you cannot use a JSON file as the source of the
names in a Customizer drop-down, because those lists are not the result
of your program executing.
But I get an error/warning:
Compiling design (CSG Tree generation)...
WARNING: Failed to parse file
'E:/3D_PotteryToVoronoids/5_Voronoid_Scad/ARTBaseVoronoiObjects\ObjectFileNames.json':
%s in file , line 195
<195,E:/3D_PotteryToVoronoids/5_Voronoid_Scad/ARTBaseVoronoiObjects/ArtVoronoi_BaseModel.scad>
Can somebody please help me out how to get this working with an
example for this problem?
It's saying that it doesn't like your JSON file. Unfortunately, there's
a bug in the error message that causes it to lose the exact error.
If you can send a copy of the JSON file, I'd be happy to take a look at
it and try to read it with an OpenSCAD with that bug fixed.
The json file (test edition):
{
"fileFormatVersion": "1",
"parameterSets": {
"fileFormatVersion": "1",
"BaseObjects": {
"None",
",PerfectHeart_Outline.svg"
}
}
On Mar 31, 2026, at 6:35 AM, jos.richters--- via Discuss discuss@lists.openscad.org wrote:
The json file (test edition):
{
"fileFormatVersion": "1",
"parameterSets": {
"fileFormatVersion": "1",
"BaseObjects": {
"None",
",PerfectHeart_Outline.svg"
}
}
I see 3 opening curly braces, but only 2 closing curly braces. Also, that comma inside the doublequote, just before PerfectHeart_Outline.svg looks suspicious.
-Revar
Hi Revar,
You are right. I fixed the braces but the error is still there….
Thanks, Jos.
[ Sigh. I sent this early this morning, but for some reason it didn't
go out with the right From address. ]
Reformatted for readability:
{
"fileFormatVersion": "1",
"parameterSets": {
"fileFormatVersion": "1",
"BaseObjects": {
"None",
",PerfectHeart_Outline.svg"
}
}
Two problems:
With the error handling fixed, it finds the second problem first:
WARNING: Failed to parse file
'C:/Users/Jordan/OneDrive/linux.home/openscad\junk.json':
[json.exception.parse_error.101] parse error at line 6, column 19:
syntax error while parsing object separator - unexpected ','; expected
':' in file ., line 1
PR#6745 is a fix for the JSON error message.
Hi Jordan,
I installed the latest nightly build and tested the new error report. That works well:
Now looking for the solution of my function to read data from an external source.
Thanks for now.
Jos.