Preserve "holes" in module objects

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

Preserve "holes" in module objects

jellsworth
Apologies if this is an old question or too basic. I have been looking, but I have not found an answer.

My issue is, I am using a module to create a somewhat complex object, let's say a cube with a threaded hole. I then want to use that module multiple times in a union with a larger object, let's say to add feet to a larger cube that can accept bolts. My obvious problem is that in the union, the larger object fills in the threaded hole I carefully created in my module.

I realize that I could fix this by creating and calling separate modules for the smaller cubes and the threaded holes, but that gets unwieldy quickly as that module object gets more complex.

Is there a way to preserve critical "empty space" in an object created by a module, even when embedded in another object?
Reply | Threaded
Open this post in threaded view
|

Re: Preserve "holes" in module objects

jellsworth
Small example:
union() { 
        cube([300,300,300]);       
        translate([100, 100, 220]) { //only leaves 20mm hole
            subpart();
        }         
}
module subpart() {
    difference() { //should have 90mm hole
        cube([100,100,100]);
        translate([50, 50, 10]) {
            cylinder(r=10, h=100);
        }
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Preserve "holes" in module objects

kintel
Administrator
In reply to this post by jellsworth
On May 1, 2015, at 21:29 PM, jellsworth <[hidden email]> wrote:

> *Is there a way to preserve critical "empty space" in an object created by a
> module, even when embedded in another object?*
>
Interesting question.
The typical way of solving this is to perform unions first, then differences. This would require you to split up your modular objects in two though.
What you’re after sounds a bit like a “mask”. Not sure how we would implement that though, but ideas are welcome.

 -Marius


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

Re: Preserve "holes" in module objects

jdawgaz
you know, I have wondered this too.
I come from a OO programming background.

I kinda consider a module as an object (sort of). And it would be nice if whatever the module "produced" remained intact.
So, If I made a union() with that module, it would add whatever the module produced to the final result.
Same with difference(), whatever the module "produced" would be differenced() (if it was second ... n in line of course)
etc.

Is that what you are looking for?


Jerry

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime. 
- Anonymous

If writing good code requires very little comments, then writing really excellent code requires no comments at all!
- Ken Thompson


On Fri, May 1, 2015 at 8:21 PM, Marius Kintel <[hidden email]> wrote:
On May 1, 2015, at 21:29 PM, jellsworth <[hidden email]> wrote:

> *Is there a way to preserve critical "empty space" in an object created by a
> module, even when embedded in another object?*
>
Interesting question.
The typical way of solving this is to perform unions first, then differences. This would require you to split up your modular objects in two though.
What you’re after sounds a bit like a “mask”. Not sure how we would implement that though, but ideas are welcome.

 -Marius


_______________________________________________
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: Preserve "holes" in module objects

hagen
In reply to this post by jellsworth
in theory the following works:

union()
{
        difference()
        {
            cube([300,300,300]);  
            position() hull () subpart();
        }
        position() subpart();        
}

module position()
{
    translate([100,100,220]) children(0);
}

module subpart()
{
    difference()
    {
        cube([100,100,100]);
        translate([50, 50, 10]) cylinder(r=10, h=100);
    }
}

in practice it is probably a bit expensive and it could lead to non-manifold models
Reply | Threaded
Open this post in threaded view
|

Re: Preserve "holes" in module objects

jellsworth
In reply to this post by jdawgaz
Yes, that is the thought. Would be nice!

Thanks,
Jerry E
Reply | Threaded
Open this post in threaded view
|

Re: Preserve "holes" in module objects

jellsworth
In reply to this post by hagen
Thanks.

I guess I have confirmed I am not missing something simple, and I found Jeremie Francois' Part 4 tutorial on children which gives an example addressing this issue:
http://www.tridimake.com/2014/11/how-to-use-openscad-4-children-and.html

To me that helps minimize the pain, but it is complicated and doesn't fix the underlying issue. I guess I will get used to working around it.

Thanks,
Jerry E
Reply | Threaded
Open this post in threaded view
|

Re: Preserve "holes" in module objects

stonysmith
In reply to this post by jellsworth
(humor)

We just need a way to specify the material for each part.

Then you can simply use:
   cylinder(r=1,h=100,material=antimatter);

(/humor)
Reply | Threaded
Open this post in threaded view
|

Re: Preserve "holes" in module objects

jellsworth
Now that's funny, but I think it might work! :-)

-Jerry E
Reply | Threaded
Open this post in threaded view
|

heart symbol

yvette
hi,

i'm trying to 3d print a heart symbol.  i'm using write.scad.

i've tried unicode 2665 and cut-and-pasting a heart symbol.  neither
work; the space where the heart should go remains blank.

i'm sure the problem is that the heart symbol is not defined in
"letters.dxf".  i've found other .dxf files but none seem to have a
heart symbol defined.

i did find a bracelet with hearts on thingiverse, but sadly, only the
.stl files are downloadable.

anybody have any ideas?  i appreciate all comments!

thanks
-y-


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

Re: Preserve "holes" in module objects

yvette
In reply to this post by stonysmith
On 05/02/2015 09:28 AM, stonysmith wrote:

> Then you can simply use:
>     cylinder(r=1,h=100,material=antimatter);

i prefer using unobtanium.  you can collect antimatter at CERN;
unobtanium is ... well, unobtainable.  8^O

-y-


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

Re: heart symbol

tp3
In reply to this post by yvette
On 05/02/2015 06:41 PM, Yvette S. Hirth, CCP, CDP wrote:
> i've tried unicode 2665 and cut-and-pasting a heart symbol. neither work;
 > the space where the heart should go remains blank.
>
> i'm sure the problem is that the heart symbol is not defined in "letters.dxf".
 > i've found other .dxf files but none seem to have a heart  symbol defined.
>
Try this version of write.scad: https://github.com/brodykenrick/text_on_OpenSCAD

This is updated to use the new native text() feature.

Or if you really just need the heart:

linear_extrude(height = 2) text("\u2665", 20, font = "Arial");

ciao,
   Torsten.


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

Re: Preserve "holes" in module objects

tp3
In reply to this post by jellsworth
On 05/02/2015 06:32 PM, jellsworth wrote:
> Now that's funny, but I think it might work! :-)
>
Nope, it wouldn't. It would just explode the model into a huge amount of energy...

ciao,
   Torsten.



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

Re: heart symbol

yvette
In reply to this post by tp3
On 05/02/2015 10:08 AM, Torsten Paul wrote:

>> i'm sure the problem is that the heart symbol is not defined in
>> "letters.dxf".

>>
> Try this version of write.scad:
> https://github.com/brodykenrick/text_on_OpenSCAD
>
> This is updated to use the new native text() feature.
>
> Or if you really just need the heart:
>
> linear_extrude(height = 2) text("\u2665", 20, font = "Arial");

youDaMan!  worked like a champ - thanks!
-y-


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

Re: heart symbol

shadowwynd
Can also do it this way:

module heart()
{
        // From Inkscape --> OpenSCAD

   scale([25.4/90, -25.4/90, 1]) union()
   {
 
polygon([[191.428575,-43.743294],[191.086969,-34.093746],[190.060750,-25.298315],[188.381989,-17.295250],[186.082757,-10.022800],[183.195124,-3.419214],[179.751161,2.577259],[175.782939,8.028371],[171.322528,12.995872],[166.402000,17.541512],[161.053424,21.727044],[155.308873,25.614219],[149.200415,29.264786],[136.020066,36.103105],[121.768944,42.736008],[106.703613,49.657505],[91.080640,57.361604],[83.140214,61.661506],[75.156590,66.342311],[67.161839,71.465771],[59.188030,77.093637],[51.267235,83.287658],[43.431524,90.109587],[35.712969,97.621175],[28.143640,105.884172],[20.755607,114.960330],[13.580941,124.911399],[6.651714,135.799131],[-0.000005,147.685276],[-5.310523,135.704535],[-11.052693,124.722789],[-17.187685,114.678839],[-23.676665,105.511486],[-30.480801,97.159532],[-37.561262,89.561777],[-44.879215,82.657023],[-52.395827,76.384071],[-60.072267,70.681722],[-67.869701,65.488776],[-75.749299,60.744036],[-83.672227,56.386302],[-99.492747,48.587058],[-115.020603,41.601453],[
-129.945136,34.939896],[-143.955689,28.112797],[-150.521142,24.484171],[-156.741603,20.630563],[-162.578241,16.490774],[-167.992222,12.003605],[-172.944714,7.107857],[-177.396886,1.742331],[-181.309905,-4.154172],[-184.644939,-10.642850],[-187.363155,-17.784902],[-189.425721,-25.641528],[-190.793805,-34.273925],[-191.428575,-43.743294],[-191.276904,-51.104222],[-190.461954,-58.453654],[-189.012029,-65.755332],[-186.955434,-72.972998],[-184.320473,-80.070393],[-181.135451,-87.011260],[-177.428674,-93.759340],[-173.228445,-100.278374],[-168.563069,-106.532106],[-163.460851,-112.484277],[-157.950095,-118.098628],[-152.059107,-123.338901],[-145.816191,-128.168839],[-139.249651,-132.552183],[-132.387793,-136.452675],[-125.258921,-139.834057],[-117.891340,-142.660070],[-110.313354,-144.894457],[-102.553268,-146.500959],[-94.639387,-147.443318],[-86.600016,-147.685276],[-78.463458,-147.190575],[-70.258020,-145.922956],[-62.012005,-143.846163],[-53.753718,-140.923935],[-45.511464,-137.120016
],[-37.313548,-132.398146],[-29.188274,-126.722069],[-21.163947,-120.055525],[-13.268872,-112.362257],[-5.531353,-103.606006],[2.020305,-93.750514],[10.354280,-103.147373],[18.739208,-111.474733],[27.154412,-118.768836],[35.579217,-125.065926],[43.992947,-130.402246],[52.374927,-134.814038],[60.704481,-138.337546],[68.960933,-141.009012],[77.123608,-142.864680],[85.171829,-143.940791],[93.084922,-144.273590],[100.842211,-143.899319],[108.423019,-142.854221],[115.806672,-141.174538],[122.972494,-138.896515],[129.899809,-136.056393],[136.567941,-132.690416],[142.956215,-128.834826],[149.043955,-124.525867],[154.810486,-119.799781],[160.235131,-114.692811],[165.297216,-109.241201],[169.976064,-103.481192],[174.251000,-97.449029],[178.101348,-91.180954],[181.506433,-84.713209],[184.445579,-78.082039],[186.898110,-71.323685],[188.843351,-64.474390],[190.260626,-57.570398],[191.129259,-50.647952],[191.428575,-43.743294]]);
   }
}

heart();




On 5/2/2015 3:00 PM, Yvette S. Hirth, CCP, CDP wrote:

> On 05/02/2015 10:08 AM, Torsten Paul wrote:
>
>>> i'm sure the problem is that the heart symbol is not defined in
>>> "letters.dxf".
>
>>>
>> Try this version of write.scad:
>> https://github.com/brodykenrick/text_on_OpenSCAD
>>
>> This is updated to use the new native text() feature.
>>
>> Or if you really just need the heart:
>>
>> linear_extrude(height = 2) text("\u2665", 20, font = "Arial");
>
> youDaMan!  worked like a champ - thanks!
> -y-
>
>
> _______________________________________________
> 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
tp3
Reply | Threaded
Open this post in threaded view
|

Re: heart symbol

tp3
On 05/03/2015 01:12 PM, Ezra Reynolds wrote:
> Can also do it this way:
>
> module heart()
> {
>      // From Inkscape --> OpenSCAD
>
Or, welcome math :-) ...

// see http://mathworld.wolfram.com/HeartCurve.html
function heart(t) = [ 16 * pow(sin(t), 3), 13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t) ];
polygon([ for (t = [0 : 360 ]) heart(t) ]);

ciao,
   Torsten.


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

Re: heart symbol

yvette
In reply to this post by shadowwynd
On 05/03/2015 04:12 AM, Ezra Reynolds wrote:

> Can also do it this way:

> module heart()
(snippage)
> }
>
> heart();

thanks!
yvette

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

Re: heart symbol

yvette
In reply to this post by tp3
On 05/03/2015 05:08 AM, Torsten Paul wrote:

> On 05/03/2015 01:12 PM, Ezra Reynolds wrote:
>> Can also do it this way:
>>
>> module heart()
>> {
>>      // From Inkscape --> OpenSCAD
>>
> Or, welcome math :-) ...
>
> // see http://mathworld.wolfram.com/HeartCurve.html
> function heart(t) = [ 16 * pow(sin(t), 3), 13 * cos(t) - 5 * cos(2 * t)
> - 2 * cos(3 * t) - cos(4 * t) ];
> polygon([ for (t = [0 : 360 ]) heart(t) ]);

now we're talking!
yvette

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

Re: Preserve "holes" in module objects

bobc
In reply to this post by stonysmith
stonysmith wrote
(humor)

We just need a way to specify the material for each part.

Then you can simply use:
   cylinder(r=1,h=100,material=antimatter);

(/humor)
I know that was a joke, but I think it might be a way to do it. AMF supports a material id=0, which is used to indicate a void. In a sense, it's a material with a density of 0.

Having an explicitly defined void might enable holes to be "added" to other shapes.