coloring parts

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

coloring parts

jon_bondy

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.

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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: coloring parts

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

On Sun, 7 Feb 2021 at 22:11, jon <[hidden email]> 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.

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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: coloring parts

jon_bondy

Great suggestion.  But it does not work...

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 <[hidden email]> 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.

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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: coloring parts

nophead
Do the objects all overlap each other? It should work if they don't.

On Sun, 7 Feb 2021 at 22:29, jon <[hidden email]> wrote:

Great suggestion.  But it does not work...

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 <[hidden email]> 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.

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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: coloring parts

nophead
Also you might want to add render around each difference to avoid z fighting between the different coloured negative cubes.

On Sun, 7 Feb 2021 at 22:31, nop head <[hidden email]> wrote:
Do the objects all overlap each other? It should work if they don't.

On Sun, 7 Feb 2021 at 22:29, jon <[hidden email]> wrote:

Great suggestion.  But it does not work...

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 <[hidden email]> 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.

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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: coloring parts

RevarBat
In reply to this post by jon_bondy
When you have code like:

    difference() {
        color(“red”) Shape1();
        color(“blue”) Shape2();
    }

Then the color of the interior of Shape1() that is exposed by removing Shape2() will be colored like Shape2().  Ie, for this example, you will see a red Shape1(); exterior, with the interior parts colored blue.

If you make them both the same color, then you can get a homogeneously colored part.

- Revar



On Feb 7, 2021, at 2:10 PM, jon <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: coloring parts

jon_bondy
In reply to this post by nophead

Excellent!  if each object has a color() of a render() of the object, then the colors work!

Thanks so much!


On 2/7/2021 5:37 PM, nop head wrote:
Also you might want to add render around each difference to avoid z fighting between the different coloured negative cubes.

On Sun, 7 Feb 2021 at 22:31, nop head <[hidden email]> wrote:
Do the objects all overlap each other? It should work if they don't.

On Sun, 7 Feb 2021 at 22:29, jon <[hidden email]> wrote:

Great suggestion.  But it does not work...

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 <[hidden email]> 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.

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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: coloring parts

MichaelAtOz
Administrator
In reply to this post by RevarBat
RevarBat wrote

> When you have code like:
>
>     difference() {
>         color(“red”) Shape1();
>         color(“blue”) Shape2();
>     }
>
> Then the color of the interior of Shape1() that is exposed by removing
> Shape2() will be colored like Shape2().  Ie, for this example, you will
> see a red Shape1(); exterior, with the interior parts colored blue.
>
> If you make them both the same color, then you can get a homogeneously
> colored part.

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.



-----
OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.
Reply | Threaded
Open this post in threaded view
|

Re: coloring parts

RevarBat
In reply to this post by jon_bondy
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);
}


- Revar



On Feb 7, 2021, at 2:29 PM, jon <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: coloring parts

RevarBat
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);
}


- Revar


On Feb 7, 2021, at 3:20 PM, Revar Desmera <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: coloring parts

RevarBat
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org




_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: coloring parts

JordanBrown
In reply to this post by MichaelAtOz
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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org