discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

coloring parts

RD
Revar Desmera
Sun, Feb 7, 2021 11:42 PM

Just for fun, have a battery:

color("red")
difference() {
cylinder(d=50,h=100);
cylinder(d=20,h=105);
translate([0,0,-5]) cylinder(d=40,h=100);
translate([0,-1000,-500]) cube(1000);
}

color("silver")
difference() {
cylinder(d=40,h=95);
translate([0,0,5]) cylinder(d=30,h=95);
translate([-0.01,-1000+0.01,-500]) cube(1000);
}

color("green")
translate([0,0,5])
difference() {
cylinder(d=30,h=90);
translate([0,0,5]) cylinder(d=20,h=90);
translate([-0.02,-1000+0.02,-500]) cube(1000);
}

color("gray")
translate([0,0,10])
difference() {
cylinder(d=20,h=95);
translate([-0.03,-1000+0.03,-500]) cube(1000);
}

  • Revar

On Feb 7, 2021, at 3:27 PM, Revar Desmera revarbat@gmail.com wrote:

Ahhhh.  I see.  If the removed cube has coincident faces to the other parts, the last cube’s color wins.  You can get the result you want by making the cubes very slightly offset from one another.

color("red")
difference() {
cylinder(d=50,h=100);
cylinder(d=40,h=1000, center=true);
translate([0,-1000,-500]) cube(1000);
}
color("green")
difference() {
cylinder(d=40,h=90);
cylinder(d=30,h=1000, center=true);
translate([-0.01,-1000+0.01,-500]) cube(1000);
}

<Screen Shot 2021-02-07 at 3.26.58 PM.png>

  • Revar

On Feb 7, 2021, at 3:20 PM, Revar Desmera <revarbat@gmail.com mailto:revarbat@gmail.com> wrote:

Odd. It works for me in OpenSCAD 2021.01 (OS X):

color("red")
difference() {
cylinder(d=50,h=100);
translate([0,-1000,-500]) cube(1000);
}

<Screen Shot 2021-02-07 at 3.18.50 PM.png>

  • Revar

On Feb 7, 2021, at 2:29 PM, jon <jon@jonbondy.com mailto:jon@jonbondy.com> wrote:

Great suggestion.  But it does not work...

<mcgpbpmffakdoboa.png>

I have four sections like this:

color("red")
difference() {
Plunger();
translate([0, 0, -20])
cube(1000);
}

There are four objects, colored red, blue, green, and orange.  The internal color is always the color of the last object.

Puzzling

On 2/7/2021 5:12 PM, nop head wrote:

I think the only way is to make four separate differences and colour them.

On Sun, 7 Feb 2021 at 22:11, jon <jon@jonbondy.com mailto:jon@jonbondy.com> wrote:
I am making an assembly for a customer consisting of 4 interlocking parts.  I colored each and then cut into the assembly with a difference() of a cube(), expecting the colors of the parts to persist throughout the entire part.  Not so.

<bdmbalicpfleleoa.png>

I don't know if this would be feasible, but the utility is obvious.

Anyone know of another way to visualize a series of parts like this?  Think of it as a complex syringe...


OpenSCAD mailing list
Discuss@lists.openscad.org mailto:Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


OpenSCAD mailing list
Discuss@lists.openscad.org mailto:Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Just for fun, have a battery: color("red") difference() { cylinder(d=50,h=100); cylinder(d=20,h=105); translate([0,0,-5]) cylinder(d=40,h=100); translate([0,-1000,-500]) cube(1000); } color("silver") difference() { cylinder(d=40,h=95); translate([0,0,5]) cylinder(d=30,h=95); translate([-0.01,-1000+0.01,-500]) cube(1000); } color("green") translate([0,0,5]) difference() { cylinder(d=30,h=90); translate([0,0,5]) cylinder(d=20,h=90); translate([-0.02,-1000+0.02,-500]) cube(1000); } color("gray") translate([0,0,10]) difference() { cylinder(d=20,h=95); translate([-0.03,-1000+0.03,-500]) cube(1000); } - Revar > On Feb 7, 2021, at 3:27 PM, Revar Desmera <revarbat@gmail.com> wrote: > > Ahhhh. I see. If the removed cube has coincident faces to the other parts, the last cube’s color wins. You can get the result you want by making the cubes very slightly offset from one another. > > color("red") > difference() { > cylinder(d=50,h=100); > cylinder(d=40,h=1000, center=true); > translate([0,-1000,-500]) cube(1000); > } > color("green") > difference() { > cylinder(d=40,h=90); > cylinder(d=30,h=1000, center=true); > translate([-0.01,-1000+0.01,-500]) cube(1000); > } > > <Screen Shot 2021-02-07 at 3.26.58 PM.png> > > - Revar > > >> On Feb 7, 2021, at 3:20 PM, Revar Desmera <revarbat@gmail.com <mailto:revarbat@gmail.com>> wrote: >> >> Odd. It works for me in OpenSCAD 2021.01 (OS X): >> >> color("red") >> difference() { >> cylinder(d=50,h=100); >> translate([0,-1000,-500]) cube(1000); >> } >> >> <Screen Shot 2021-02-07 at 3.18.50 PM.png> >> >> - Revar >> >> >> >>> On Feb 7, 2021, at 2:29 PM, jon <jon@jonbondy.com <mailto:jon@jonbondy.com>> wrote: >>> >>> Great suggestion. But it does not work... >>> >>> <mcgpbpmffakdoboa.png> >>> >>> I have four sections like this: >>> >>> color("red") >>> difference() { >>> Plunger(); >>> translate([0, 0, -20]) >>> cube(1000); >>> } >>> >>> There are four objects, colored red, blue, green, and orange. The internal color is always the color of the last object. >>> >>> Puzzling >>> >>> >>> >>> On 2/7/2021 5:12 PM, nop head wrote: >>>> I think the only way is to make four separate differences and colour them. >>>> >>>> On Sun, 7 Feb 2021 at 22:11, jon <jon@jonbondy.com <mailto:jon@jonbondy.com>> wrote: >>>> I am making an assembly for a customer consisting of 4 interlocking parts. I colored each and then cut into the assembly with a difference() of a cube(), expecting the colors of the parts to persist throughout the entire part. Not so. >>>> >>>> <bdmbalicpfleleoa.png> >>>> >>>> I don't know if this would be feasible, but the utility is obvious. >>>> >>>> Anyone know of another way to visualize a series of parts like this? Think of it as a complex syringe... >>>> >>>> >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> >>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> >>>> >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> >>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> >> >
JB
Jordan Brown
Mon, Feb 8, 2021 4:43 PM

On 2/7/2021 3:11 PM, MichaelAtOz wrote:

To clarify, technically there is no interior colour. ATM colour is a
surface property of the faces of the object (ie the triangles or
polygons). The colour of the faces resulting from a difference, ie the
cut face, has the colour of the negative object. Hence, as above, cut
face of Shape1() is blue.

On 2/7/2021 3:11 PM, MichaelAtOz wrote: > To clarify, technically there is no interior colour. ATM colour is a > surface property of the faces of the object (ie the triangles or > polygons). The colour of the faces resulting from a difference, ie the > cut face, has the colour of the negative object. Hence, as above, cut > face of Shape1() is blue. See issue #1608:  https://github.com/openscad/openscad/issues/1608