discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Problem in openscad script from Thingiverse

K
kak
Sat, Dec 5, 2015 11:02 AM

I have a problem with this http://www.thingiverse.com/thing:140343 project
when rendering in openscad. The logo is extruded out from the surface, but
does not go into the surface to make the negative on the other side of the
hinge. Can someone help me?

Before rendering:
http://forum.openscad.org/file/n14953/ska.png

After rendering:
http://forum.openscad.org/file/n14953/Sk%C3%A6rmbillede_2015-12-05_kl.png

"code"
// preview[view:south, tilt:top]

/* [Global] */

// Load a 100x100 pixel image.(images will be stretched to fit) Simple, high
contrast images work best. Make sure to click the Invert Colors checkbox!
image_file = "cp.dat"; // [image_surface:100x100]

// Where would you like the hinge in relation to your image?
hinge_placement = 1; // [1:top,2:left,3:bottom,4:right]

// What height would you like for the embossed area (mm)?
emboss_height = 1.5;

/* [Hidden] */
$fa = 6;
$fs = 1.5;
image_width = 40;
image_length = 40;
image_padding = 4;

handle_width = image_width + image_padding*2;
handle_length = 70;
handle_height = emboss_height+2.5;
nub = 3; // hinge size
tol = 0.4; // spacing between hinge pieces

assembly();

module assembly() {
stamp_top(90hinge_placement);
stamp_bottom(90
hinge_placement);
}

module stamp_top(rot=90) {
translate([1,0,0])
union() {
difference () {
translate([handle_length + nub + tol, -handle_width/2, 0])
rotate([0,0,90]) handle();

translate([handle_length-image_length/2+nub+tol,0,handle_height])
rotate([0,180,rot]) plate();
}

    // hinge
    translate([-1,handle_width/2-2*nub,handle_height]) hinge_m();
    mirror([0,1,0]) translate([-1,handle_width/2-2*nub,handle_height])

hinge_m();
translate([-1,-nub,handle_height]) hinge_m();
mirror([0,1,0]) translate([-1,-nub,handle_height]) hinge_m();
}
}

module stamp_bottom(rot=90) {
translate([-1,0,0])
union() {
translate([-handle_length + image_length/2-nub-tol,0,handle_height])
rotate([0,0,-rot]) plate();
mirror([1,0,0]) translate([handle_length + nub + tol,
-handle_width/2, 0])
rotate([0,0,90]) handle();

    // hinge
    translate([1,-nub-tol,handle_height]) hinge_f();
    mirror([0,1,0]) translate([1,-nub-tol,handle_height]) hinge_f();
}

}

module handle() {
difference() {
hull() {
cube([handle_width, handle_length, handle_height]);
translate([image_padding,0,0]) cylinder(r=image_padding,
h=handle_height);
translate([handle_width-image_padding,0,0])
cylinder(r=image_padding, h=handle_height);
}
guide();
}

}

module guide() {
translate([image_padding,0,-.5])
difference() {
cube([image_width, image_length, 1]);
translate([1,1,-0.5]) cube([image_width-2, image_length-2, 2]);
}
}

module hinge_m() {
difference () {
rotate([0,45,0]) union(){
translate([0,0,-nub]) cube ([nub3,nub2, nub2]);
rotate([90,0,0]) {
translate([0,0,-2
nub]) cylinder(r=nub,h=2nub);
cylinder(r1=nub,r2=0,h=nub);
}
}
translate([-nub,-nub/2,-handle_height-nub
5]) cube([nub5, nub3,
nub*5]);
}
}

module hinge_f() {
len = handle_width/2 - 3nub - 2tol;

difference() {
    rotate([90,-45,0]) 
    difference() {
        union() {
            cylinder(r=nub, h=len);
            translate([-3*nub,-nub,0]) cube([nub*3,nub*2,len]);
        }
        translate([0,0,-0.1]) cylinder(r1=nub+tol,r2=0,h=nub);
        translate([0,0,len-nub+0.1]) cylinder(r1=0,r2=nub+tol,h=nub);
    }
    translate([-nub*4,-len-nub/2,-handle_height-nub*5]) cube([nub*5,

len+nub, nub*5]);
}
}

module plate() {
scale([(image_width)/100,(image_length)/100,emboss_height])
surface(file=image_file, center=true, convexity=5);
}

--
View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I have a problem with this http://www.thingiverse.com/thing:140343 project when rendering in openscad. The logo is extruded out from the surface, but does not go into the surface to make the negative on the other side of the hinge. Can someone help me? Before rendering: <http://forum.openscad.org/file/n14953/ska.png> After rendering: <http://forum.openscad.org/file/n14953/Sk%C3%A6rmbillede_2015-12-05_kl.png> "code" // preview[view:south, tilt:top] /* [Global] */ // Load a 100x100 pixel image.(images will be stretched to fit) Simple, high contrast images work best. Make sure to click the Invert Colors checkbox! image_file = "cp.dat"; // [image_surface:100x100] // Where would you like the hinge in relation to your image? hinge_placement = 1; // [1:top,2:left,3:bottom,4:right] // What height would you like for the embossed area (mm)? emboss_height = 1.5; /* [Hidden] */ $fa = 6; $fs = 1.5; image_width = 40; image_length = 40; image_padding = 4; handle_width = image_width + image_padding*2; handle_length = 70; handle_height = emboss_height+2.5; nub = 3; // hinge size tol = 0.4; // spacing between hinge pieces assembly(); module assembly() { stamp_top(90*hinge_placement); stamp_bottom(90*hinge_placement); } module stamp_top(rot=90) { translate([1,0,0]) union() { difference () { translate([handle_length + nub + tol, -handle_width/2, 0]) rotate([0,0,90]) handle(); translate([handle_length-image_length/2+nub+tol,0,handle_height]) rotate([0,180,rot]) plate(); } // hinge translate([-1,handle_width/2-2*nub,handle_height]) hinge_m(); mirror([0,1,0]) translate([-1,handle_width/2-2*nub,handle_height]) hinge_m(); translate([-1,-nub,handle_height]) hinge_m(); mirror([0,1,0]) translate([-1,-nub,handle_height]) hinge_m(); } } module stamp_bottom(rot=90) { translate([-1,0,0]) union() { translate([-handle_length + image_length/2-nub-tol,0,handle_height]) rotate([0,0,-rot]) plate(); mirror([1,0,0]) translate([handle_length + nub + tol, -handle_width/2, 0]) rotate([0,0,90]) handle(); // hinge translate([1,-nub-tol,handle_height]) hinge_f(); mirror([0,1,0]) translate([1,-nub-tol,handle_height]) hinge_f(); } } module handle() { difference() { hull() { cube([handle_width, handle_length, handle_height]); translate([image_padding,0,0]) cylinder(r=image_padding, h=handle_height); translate([handle_width-image_padding,0,0]) cylinder(r=image_padding, h=handle_height); } guide(); } } module guide() { translate([image_padding,0,-.5]) difference() { cube([image_width, image_length, 1]); translate([1,1,-0.5]) cube([image_width-2, image_length-2, 2]); } } module hinge_m() { difference () { rotate([0,45,0]) union(){ translate([0,0,-nub]) cube ([nub*3,nub*2, nub*2]); rotate([90,0,0]) { translate([0,0,-2*nub]) cylinder(r=nub,h=2*nub); cylinder(r1=nub,r2=0,h=nub); } } translate([-nub,-nub/2,-handle_height-nub*5]) cube([nub*5, nub*3, nub*5]); } } module hinge_f() { len = handle_width/2 - 3*nub - 2*tol; difference() { rotate([90,-45,0]) difference() { union() { cylinder(r=nub, h=len); translate([-3*nub,-nub,0]) cube([nub*3,nub*2,len]); } translate([0,0,-0.1]) cylinder(r1=nub+tol,r2=0,h=nub); translate([0,0,len-nub+0.1]) cylinder(r1=0,r2=nub+tol,h=nub); } translate([-nub*4,-len-nub/2,-handle_height-nub*5]) cube([nub*5, len+nub, nub*5]); } } module plate() { scale([(image_width)/100,(image_length)/100,emboss_height]) surface(file=image_file, center=true, convexity=5); } -- View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Sat, Dec 5, 2015 11:36 PM

Can you upload the cp.dat file you are using.


Newly minted Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p14971.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Can you upload the cp.dat file you are using. ----- Newly minted Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p14971.html Sent from the OpenSCAD mailing list archive at Nabble.com.
K
kak
Sun, Dec 6, 2015 1:15 PM

Hi Michael

Here is the file. https://www.dropbox.com/s/umqyfgg2wv63bq3/cp.dat?dl=0

I am also getting the same error with the other .dat's in the project.

--
View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p14978.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hi Michael Here is the file. https://www.dropbox.com/s/umqyfgg2wv63bq3/cp.dat?dl=0 I am also getting the same error with the other .dat's in the project. -- View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p14978.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Sun, Dec 6, 2015 8:28 PM

Well some error has slithered into later releases...

I get the same error, but not in 2013.06, I'll try some other versions and
see if I can drill down to the root cause.

http://forum.openscad.org/file/n14983/2013-0_v_2015-10-17.jpg

If your project is urgent you can find 2013.06  here
http://files.openscad.org/


Newly minted Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p14983.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Well some error has slithered into later releases... I get the same error, but not in 2013.06, I'll try some other versions and see if I can drill down to the root cause. <http://forum.openscad.org/file/n14983/2013-0_v_2015-10-17.jpg> If your project is urgent you can find 2013.06 here <http://files.openscad.org/> ----- Newly minted Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p14983.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Sun, Dec 6, 2015 8:39 PM

2014.03 is also OK.


Newly minted Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p14984.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

2014.03 is also OK. ----- Newly minted Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p14984.html Sent from the OpenSCAD mailing list archive at Nabble.com.
K
kak
Sun, Dec 6, 2015 8:52 PM

This did the trick Michael, thank you so much for your valuable help! It has
helped me a lot!

Best regards
Anders, Denmark

--
View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p14986.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

This did the trick Michael, thank you so much for your valuable help! It has helped me a lot! Best regards Anders, Denmark -- View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p14986.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Sun, Dec 6, 2015 10:52 PM

Seems to be an issue with scale() and surface().

Issue 1512 raised https://github.com/openscad/openscad/issues/1512


Newly minted Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p15002.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Seems to be an issue with scale() and surface(). Issue 1512 raised <https://github.com/openscad/openscad/issues/1512> ----- Newly minted Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p15002.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Thu, Jan 7, 2016 1:45 AM

I found that if you remove the coincident faces the problem goes away.

In the translate() before the two plate() calls, change the z to
handle_height+0.01.


Newly minted Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p15529.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I found that if you remove the coincident faces the problem goes away. In the translate() before the two plate() calls, change the z to handle_height+0.01. ----- Newly minted Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/Problem-in-openscad-script-from-Thingiverse-tp14953p15529.html Sent from the OpenSCAD mailing list archive at Nabble.com.