nophead / NopSCADlib

Library of parts modelled in OpenSCAD and a framework for making projects
GNU General Public License v3.0
1.17k stars 155 forks source link

Python error: too many values to unpack (expected 2) #257

Closed hotwolf closed 1 year ago

hotwolf commented 1 year ago

I've modified a working NopSCADlib design. The updated design renders fine in OpenSCAD, but when I run make_all.py, I get the following error:

openscad -D $bom=2 -D $preview=true -o openscad.echo -d bom/bom.deps scad/bom.scad --hardwarnings 
Generating bom ... too many values to unpack (expected 2)

My project is located here: https://github.com/hotwolf/DIYLaserBed. The NopSCADlib scripts run fine on "revA", but not on "revB".

Has anyone run into this issue before? What could be the cause?

Thanks for your help!

nophead commented 1 year ago

It's a Python error meaning a miss-match between the number of items returned by a function and the number of variables to accept them. E.g. if you name a, b = func() and func returns three values.

I don't understand why there isn't a stack trace to show which line the problem is in.

Do you get any files generated in the bom directory?

hotwolf commented 1 year ago

I'm not sure anymore, but I think the bom directory was empty. In the meantime I've traced through the assembly hierarchy by commenting out lower level assemblies step by step. The problem is in one of my self made vitamins:

module flatSection(length=100,center=true) {
    description = str("Flat section: 15mmx2mm, ", length, "mm");
    vitamin(str("flatSection(): ", description));

    color("Silver") cube([length,2,15],center=center);    
}

If I don't instantiate this vitamin, the make_all.py script seems to run through. But, I still don't understand the cause of the problem.

nophead commented 1 year ago

It is the colon in the description that is causing the issue.

hotwolf commented 1 year ago

Thanks for the tip. But how is this colon different from the colon in the "extrusion" example:

module extrusion(type, length, center = true, cornerHole = false) { //! Draw the specified extrusion

    vitamin(str("extrusion(", type[0], ", ", length, arg(cornerHole, false, "cornerHole"), "): Extrusion ", type[0], " x ", length, "mm"));

    color(grey(90))
        linear_extrude(length, center = center, convexity = 8)
            extrusion_cross_section(type, cornerHole);
}
nophead commented 1 year ago

The colon is used as a separator between the module call and the description. You have a second one in the description.

hotwolf commented 1 year ago

I see. Thanks so much for your help!

nophead commented 1 year ago

I will try to fix the code so you can have colons in the description.

nophead commented 1 year ago

Fixed by https://github.com/nophead/NopSCADlib/commit/b1592f51d4b16a125d9b28edae56f758fcac2f02