Wish: explicitly negative volume components

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

Wish: explicitly negative volume components

Piotr Wyderski
OpenSCAD already has a feature to remove a part of a solid using the difference() operator.
However, the (very intuitive) inherently additive nature of OpenSCAD modelling does not allow
one to perform subtractive modelling using modules. That is, one cannot return from a module
a volume to be implicitly subtracted from the already existing objects. To achieve this currently
one has to split the model into two parts: the first one adds volume, the other subtracts it.
This is very tedious and doesn't allow for good modularization of the design. In reality the
module-defined comonents have both positive volume parts (they add solid pieces to the
universe) and the negative ones (they indicate holes to be drilled, trenches milled, texts
embossed etc.). To support this, I propose the following extension:

 negative() { contents }

This acts like a union within the braces and then indicates that the combined result
should be permanently subtractive. Then it could be seamlessly integrated with the
default additive semantics as follows:

module ball_hole() {

   negative() sphere(r=1, center=true);
}

cube(1, center=true);
ball_hole();

The real power comes from the ability to combine both positive and negative
volumes within a single module.

module ball_hole() {

   union { negative() sphere(r=1, center=true);
               cube(0.1, center=true);
   }
}
 

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

Re: Wish: explicitly negative volume components

Ronaldo
To be well defined, it is necessary to know what results from composing the operator negative() with other operators besides union() like:

intersection() {A() ; negative() B() ;}

difference() {negative() A() ; B() ; negative() C() ;} 

and what would be rendered for each:

negative() cube() ;

negative() difference() {cube() ; cube()} 



Em 15 de out de 2017 06:59, "Piotr Wyderski" <[hidden email]> escreveu:
OpenSCAD already has a feature to remove a part of a solid using the difference() operator.
However, the (very intuitive) inherently additive nature of OpenSCAD modelling does not allow
one to perform subtractive modelling using modules. That is, one cannot return from a module
a volume to be implicitly subtracted from the already existing objects. To achieve this currently
one has to split the model into two parts: the first one adds volume, the other subtracts it.
This is very tedious and doesn't allow for good modularization of the design. In reality the
module-defined comonents have both positive volume parts (they add solid pieces to the
universe) and the negative ones (they indicate holes to be drilled, trenches milled, texts
embossed etc.). To support this, I propose the following extension:

 negative() { contents }

This acts like a union within the braces and then indicates that the combined result
should be permanently subtractive. Then it could be seamlessly integrated with the
default additive semantics as follows:

module ball_hole() {

   negative() sphere(r=1, center=true);
}

cube(1, center=true);
ball_hole();

The real power comes from the ability to combine both positive and negative
volumes within a single module.

module ball_hole() {

   union { negative() sphere(r=1, center=true);
               cube(0.1, center=true);
   }
}
 

_______________________________________________
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: Wish: explicitly negative volume components

KarijnWessing
In reply to this post by Piotr Wyderski
You can make a module that operates on it's childeren

module makePin()
{
    union()
    {
        difference()
        {
            // here the magic happens:
            union(){ children(); }
           
            cube([5, 3, 10], center=true);
            cube([3, 5, 10], center=true);
        }
        cube([5, 1, 1], center=true);
        cube([1, 5, 1], center=true);
    }
}
// subtract a cross from the cube and add soething into it
//
makePin() cube([10, 10, 1], center=true);




--
Sent from: http://forum.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: Wish: explicitly negative volume components

doug.moen
In reply to this post by Piotr Wyderski
The Relativity library already has support for negative volumes.

You would do this by tagging negative volumes with the class name "negative" (or any name you want), then subtract the negative shapes from the model at the top level.

Issue #1608 discusses a proposal for adding a similar feature to OpenSCAD in a general way (the terminology used here is "part names" rather than "class names".

On 15 October 2017 at 04:58, Piotr Wyderski <[hidden email]> wrote:
OpenSCAD already has a feature to remove a part of a solid using the difference() operator.
However, the (very intuitive) inherently additive nature of OpenSCAD modelling does not allow
one to perform subtractive modelling using modules. That is, one cannot return from a module
a volume to be implicitly subtracted from the already existing objects. To achieve this currently
one has to split the model into two parts: the first one adds volume, the other subtracts it.
This is very tedious and doesn't allow for good modularization of the design. In reality the
module-defined comonents have both positive volume parts (they add solid pieces to the
universe) and the negative ones (they indicate holes to be drilled, trenches milled, texts
embossed etc.). To support this, I propose the following extension:

 negative() { contents }

This acts like a union within the braces and then indicates that the combined result
should be permanently subtractive. Then it could be seamlessly integrated with the
default additive semantics as follows:

module ball_hole() {

   negative() sphere(r=1, center=true);
}

cube(1, center=true);
ball_hole();

The real power comes from the ability to combine both positive and negative
volumes within a single module.

module ball_hole() {

   union { negative() sphere(r=1, center=true);
               cube(0.1, center=true);
   }
}
 

_______________________________________________
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: Wish: explicitly negative volume components

Gadgetmind
In reply to this post by Piotr Wyderski
On 2017-10-15 09:58, Piotr Wyderski wrote:
> That is, one cannot return from a module
> a volume to be implicitly subtracted from the already existing objects.

I have done this by having a negative flag that's set false by default,
so the module creates its positive objects, and the module is then
called again from difference () with flag set to let it subtract its
negative spaces.

OK, so a bit messy, but it does give the localisation of positive and
negative into the same module and lots of transformations can be shared.


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

Re: Wish: explicitly negative volume components

nophead
I just factor the positioning transformations so that they can be shared.

I do complex assemblies that join and make mounting holes, etc without any desire for negative volumes or named attachments.

On 16 October 2017 at 12:01, Gadgetmind <[hidden email]> wrote:
On 2017-10-15 09:58, Piotr Wyderski wrote:
That is, one cannot return from a module
a volume to be implicitly subtracted from the already existing objects.

I have done this by having a negative flag that's set false by default, so the module creates its positive objects, and the module is then called again from difference () with flag set to let it subtract its negative spaces.

OK, so a bit messy, but it does give the localisation of positive and negative into the same module and lots of transformations can be shared.


_______________________________________________
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: Wish: explicitly negative volume components

Piotr Wyderski
Agreed, you can do all that transformations manually, but you just
shouldn't: it is the task of a machine, not a human. A human should
be provided with a set of convenient tools to create models efficiently
and correctly. After several days of using OpenSCAD I was able to
identify two of them, hence the wish list posts. I have modelled the
parts correctly and then suddenly discovered that there are no tools
to compose them into a higher-order entity.

    Best regards, Piotr


2017-10-16 13:53 GMT+02:00 nop head <[hidden email]>:
I just factor the positioning transformations so that they can be shared.

I do complex assemblies that join and make mounting holes, etc without any desire for negative volumes or named attachments.

On 16 October 2017 at 12:01, Gadgetmind <[hidden email]> wrote:
On 2017-10-15 09:58, Piotr Wyderski wrote:
That is, one cannot return from a module
a volume to be implicitly subtracted from the already existing objects.

I have done this by having a negative flag that's set false by default, so the module creates its positive objects, and the module is then called again from difference () with flag set to let it subtract its negative spaces.

OK, so a bit messy, but it does give the localisation of positive and negative into the same module and lots of transformations can be shared.


_______________________________________________
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