discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Wish: explicitly negative volume components

PW
Piotr Wyderski
Sun, Oct 15, 2017 8:58 AM

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 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); } }
RP
Ronaldo Persiano
Sun, Oct 15, 2017 1:24 PM

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" piotr.wyderski@gmail.com
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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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" <piotr.wyderski@gmail.com> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
K
KarijnWessing
Sun, Oct 15, 2017 9:57 PM

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/

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/
DM
doug moen
Sun, Oct 15, 2017 10:08 PM

The Relativity library already has support for negative volumes.
https://www.thingiverse.com/thing:349943

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".
https://github.com/openscad/openscad/issues/1608

On 15 October 2017 at 04:58, Piotr Wyderski piotr.wyderski@gmail.com
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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

The Relativity library already has support for negative volumes. https://www.thingiverse.com/thing:349943 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". https://github.com/openscad/openscad/issues/1608 On 15 October 2017 at 04:58, Piotr Wyderski <piotr.wyderski@gmail.com> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
G
Gadgetmind
Mon, Oct 16, 2017 11:01 AM

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.

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.
NH
nop head
Mon, Oct 16, 2017 11:53 AM

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 lists@foxhill.co.uk 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <lists@foxhill.co.uk> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
PW
Piotr Wyderski
Mon, Oct 16, 2017 12:32 PM

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 nop.head@gmail.com:

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 lists@foxhill.co.uk 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <nop.head@gmail.com>: > 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 <lists@foxhill.co.uk> 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 >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
T
Troberg
Thu, Dec 7, 2017 9:50 AM

This just gave me an idea. When doing odd shapes, hull is good for doing
convex corners, but not as good for concave corners.

With negative objects, this could be solved. Where a positive object
"stretches the surface" outside it, the negative object would instead
stretch it so that the object is outside the resulting object.

So, for example, a boomerang could be modelled (and I'm simplifying things
here, the actual viability of the boomerang is not the point) as the hull of
three short, wide cylinders in a triangle, and a negative cylinder in the
"V".

Of course, for this to work, the order of the objects needs to be taken into
account.

Would be very useful in making softer, more organic shapes.

Still, has some problems which needs to be sorted out, of course. I'm just
planting ideas...

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

This just gave me an idea. When doing odd shapes, hull is good for doing convex corners, but not as good for concave corners. With negative objects, this could be solved. Where a positive object "stretches the surface" outside it, the negative object would instead stretch it so that the object is outside the resulting object. So, for example, a boomerang could be modelled (and I'm simplifying things here, the actual viability of the boomerang is not the point) as the hull of three short, wide cylinders in a triangle, and a negative cylinder in the "V". Of course, for this to work, the order of the objects needs to be taken into account. Would be very useful in making softer, more organic shapes. Still, has some problems which needs to be sorted out, of course. I'm just planting ideas... -- Sent from: http://forum.openscad.org/
NH
nop head
Thu, Dec 7, 2017 1:27 PM

Yes I proposed a concave_hull() operator a while ago. It would be like
difference where the first object is positive and the rest are negative.

On 7 December 2017 at 09:50, Troberg troberg.anders@gmail.com wrote:

This just gave me an idea. When doing odd shapes, hull is good for doing
convex corners, but not as good for concave corners.

With negative objects, this could be solved. Where a positive object
"stretches the surface" outside it, the negative object would instead
stretch it so that the object is outside the resulting object.

So, for example, a boomerang could be modelled (and I'm simplifying things
here, the actual viability of the boomerang is not the point) as the hull
of
three short, wide cylinders in a triangle, and a negative cylinder in the
"V".

Of course, for this to work, the order of the objects needs to be taken
into
account.

Would be very useful in making softer, more organic shapes.

Still, has some problems which needs to be sorted out, of course. I'm just
planting ideas...

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


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

Yes I proposed a concave_hull() operator a while ago. It would be like difference where the first object is positive and the rest are negative. On 7 December 2017 at 09:50, Troberg <troberg.anders@gmail.com> wrote: > This just gave me an idea. When doing odd shapes, hull is good for doing > convex corners, but not as good for concave corners. > > With negative objects, this could be solved. Where a positive object > "stretches the surface" outside it, the negative object would instead > stretch it so that the object is outside the resulting object. > > So, for example, a boomerang could be modelled (and I'm simplifying things > here, the actual viability of the boomerang is not the point) as the hull > of > three short, wide cylinders in a triangle, and a negative cylinder in the > "V". > > Of course, for this to work, the order of the objects needs to be taken > into > account. > > Would be very useful in making softer, more organic shapes. > > Still, has some problems which needs to be sorted out, of course. I'm just > planting ideas... > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
P
Parkinbot
Fri, Dec 8, 2017 5:00 PM

Piotr Wyderski wrote

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

}

I would say, the real power comes from using the appropriate Boolean
operation:

module ball_hole()
difference { cube(0.1, center=true); sphere(r=1, center=true);  }

A negative object will exend to infinite. It can't be rendered and will
obviously create a bag full of problems if used as operand in the Boolean
operations difference() and union(), while just intersection is save.
Where is the problem in using a difference() operation, which was indeed
introduced to get along without negation?

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

Piotr Wyderski wrote > 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); > } > } I would say, the real power comes from using the appropriate Boolean operation: > module ball_hole() > difference { cube(0.1, center=true); sphere(r=1, center=true); } A negative object will exend to infinite. It can't be rendered and will obviously create a bag full of problems if used as operand in the Boolean operations difference() and union(), while just intersection is save. Where is the problem in using a difference() operation, which was indeed introduced to get along *without* negation? -- Sent from: http://forum.openscad.org/