Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Duplicate lpart id's #17

Closed
krbeesley opened this issue Sep 4, 2020 · 4 comments
Closed

Error: Duplicate lpart id's #17

krbeesley opened this issue Sep 4, 2020 · 4 comments

Comments

@krbeesley
Copy link

I'm still having problems running laserscad on OS X. Here's the background:

On OS X v 10.13.6
Using laserscad v0.3.2

$ which openscad
returns /usr/local/bin/openscad

which is an executable bash script that looks like this:

#!/bin/bash
/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD $*

When I cd to the new v0.3.2 laserscad/dist and
invoke

$ make cut model=/Users/beesley/perso/shop/3D/openscad/projects/pads/pads.scad

it creates directory _laserscad_temp/ in pads/, puts file pads.echo in it, and then finds an error,
returning

$ make cut model=/Users/beesley/perso/shop/3D/openscad/projects/pads/pads.scad
Getting object bounding boxes...
OpenSCAD reports:
WARNING: Ignoring unknown variable 'lidentify'.
WARNING: Ignoring unknown variable 'lmargin'.
WARNING: Ignoring unknown variable 'lkerf'.
Error: Duplicate lpart id's: pad
make: *** [/Users/beesley/perso/shop/3D/openscad/projects/pads/_laserscad_temp/pads_bb.csv] Error 1

and exits. There's no further output.

The pads.scad file looks like this:
// pads.scad
// Kenneth R. Beesley
/*
Design pads (basically just circles) for saxophone keys to be cut
out of material by a laser cutter

The "material" will be a sandwich of neoprene rubber sheet (1/16"
to 1/8" thick) with a card backing already glued on.  The laser
cutter will need to cut through the rubber and the card backing.

The thickness of the material will vary.  Needs to be specified
for the laser-cutter, I assume?

*/

include <laserscad.scad>

// width of cut left by the laser cutter (see details of the machine)
kerf = 0.5;

thickness = 3; // affects only the development preview in OpenSCAD

// $fn value controls the roundness of the circles
$fn = 200;
font_color = "black";
font_size = 1.5;

module pad(diam) {
lpart("pad", [diam, diam]) {
// text to be engraved
lengrave(thickness, true){
color(font_color)
text(font="DejaVu Sans", size=font_size, str(diam),
halign="center", valign="center");
}
// engrave the text onto a basic cylinder
cylinder(h=thickness, d=diam + kerf);

}

}

module pad_with_hole(odiam, idiam) {
lpart("pad_with_hole", [odiam, odiam]) {
// text to be engraved
lengrave(thickness, true){
color(font_color)
translate([0, 2, 0])
text(font="DejaVu Sans", size=font_size, str(odiam), halign="center",
valign="center");
}

    // engrave the text onto a cylinder with a hole in the middle
    difference() {
        cylinder(h=thickness, d=odiam + kerf);

        translate([0, 0, -1])
        cylinder(h=thickness + 2, d=idiam - kerf);
    }
}

}

union() {
translate([-24, 0, 0])
pad(8.5);

translate([-13, 0, 0])
pad(10);

pad(13);

translate([16, 0, 0])
pad_with_hole(15, 2);

}

********* end of pads.scad ********

So that's where I'm stuck.

What do I need to do to get this working?

Thanks,

Ken

@mbugert
Copy link
Owner

mbugert commented Sep 12, 2020

Hi Ken,

the library requires each lpart to have a unique name so that it can identify them during the arrangement process later on. You define an lpart named pad and instantiate it three times, therefore it returns Error: Duplicate lpart id's: pad.

A quick fix would be to include the diameter in the lpart names, i.e. by writing lpart(str("pad", diam), [diam, diam]) and lpart(str("pad_with_hole", odiam, idiam), [odiam, odiam]).

If you need multiple pads of the same diameter, this will fail for the same reason as before of course. You could then do the following:

include <laserscad.scad>

kerf = 0.5;
thickness = 3;
$fn = 200;
font_color = "black";
font_size = 1.5;

module pad(diam, id="") {
    lpart(str("pad", diam, id), [diam, diam]) {
        lengrave(thickness, true){
            color(font_color)
            text(font="DejaVu Sans", size=font_size, str(diam),
            halign="center", valign="center");
        }
        cylinder(h=thickness, d=diam + kerf);
    }
}

for (x=[1:4], y=[1:4]) {
    translate([x*10,y*10,0])
        pad(8, id=str(x,y));
}

@mbugert mbugert changed the title laserscad and OS X problem Error: Duplicate lpart id's Sep 12, 2020
@krbeesley
Copy link
Author

krbeesley commented Sep 12, 2020 via email

@mbugert
Copy link
Owner

mbugert commented Sep 13, 2020

Yeah, I agree that it's not particularly obvious from the readme. I'll update that.

I’ll get back on it.

👍👍

@mbugert mbugert closed this as completed Sep 13, 2020
@krbeesley
Copy link
Author

krbeesley commented Sep 13, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants