FIlling gaps between complex hollow objects

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

FIlling gaps between complex hollow objects

Chocrates
Is there a good way to fill in the spaces between hollow objects?

For instance if I have two torus's translated away from each other, how can
we fill in the gaps between them so they can print as a single unit, with
the center's of the torus's at the specified distance?

<http://forum.openscad.org/file/t2113/zVwx9Un.png>

<http://forum.openscad.org/file/t2113/cixnwg5.png>

I can't hull them together because it will fill in the torus's.  
My real goal is to plot objects along a parabolic curve and fill the space
in between them, so I need to find a generic way to do this as the slope
between objects changes.



--
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: FIlling gaps between complex hollow objects

fred_dot_u
My first thought would be to create a solid object independent of the tori
but describing the ultimately desired shape. That's probably the biggest
challenge. If you find that using hull causes everything to fill in, but the
outer shape is acceptable, use the hulled shape as the base solid.

Perform a difference between the hulled shape and the foundation tori
followed by removal of the center segments that the hull operation created.

As noted from the image, the angled tori will likely fill in the area
between the two especially in the Z direction. If this is not desired, it
complicates things, of course.

Just a notion.



--
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: FIlling gaps between complex hollow objects

Chocrates
Hey Thanks, thats an idea.
I think hull is probably a no go with my current understanding of it.  When
hulling objects translated on the Z axis I need just the space along the
curve filled in.  
I can probably try and build a "negative" object of the hollow space to use
in a difference and worry about building out the shape of the curve with a
complex polyhedron.  I guess I could even dispense with the difference
method and just build the polyhedron to include the hollow bits.

This <https://github.com/Chocrates/keyboard/blob/master/demo.scad>   is the
actual generated scad of the objects I am trying to connect for reference.



--
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: FIlling gaps between complex hollow objects

JordanBrown
In reply to this post by Chocrates
[ Oops resend from correct address. ]

On 12/29/2017 4:07 PM, Chocrates wrote:
Is there a good way to fill in the spaces between hollow objects?

For instance if I have two torus's translated away from each other, how can
we fill in the gaps between them so they can print as a single unit, with
the center's of the torus's at the specified distance? 

<http://forum.openscad.org/file/t2113/zVwx9Un.png> 

<http://forum.openscad.org/file/t2113/cixnwg5.png> 

I can't hull them together because it will fill in the torus's.  
My real goal is to plot objects along a parabolic curve and fill the space
in between them, so I need to find a generic way to do this as the slope
between objects changes.

Not that I would necessarily be able to make any helpful suggestions, but I'm having a hard time understanding exactly what you mean.
What would the result look like?

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

Re: FIlling gaps between complex hollow objects

cacb
On 2017-12-30 02:07, Jordan Brown wrote:
>  Not that I would necessarily be able to make any helpful suggestions,
> but I'm having a hard time understanding exactly what you mean.
>  What would the result look like?
>

I have the same question. The main problem as I see it is that the
problem is not well defined, there are many ways of 'filling the gap'.

Carsten Arnholm

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

Re: FIlling gaps between complex hollow objects

TLC123
In reply to this post by Chocrates
You can try to play around with projection and joining upp a bunch but its
pretty limited and still very hands on.
<http://forum.openscad.org/file/t1678/connect.png>


$fn=20;
 for(r=[0:30:360])
rotate([0,r,0])translate([0,0,19])join(2)
{ rotate([0,15,0])translate([5,0,0])torus(1,3);
 mirror([1,0,0])
 rotate([0,15,0])translate([5,0,0])torus(1,3);}
module join(w){
children();
segs=4;
for(i=[0:w/segs:w])
{ planecutX(1+i, 1-(i/w)*0.8)
children(0);
planecutX(-1-i, 1-(i/w)*0.8)
children(1);}}
module planecutX(offs=0,s=0.75)
{rotate([0,-90,0])
translate([0,0,-offs])
mirror([0,0,min(0,sign(offs))])
linear_extrude( abs(offs),scale=max(0,s))
projection(cut = true) {
translate([0,0,offs])rotate([0,90,0])children();
//translate([0,0,-offs])rotate([0,90,0])children();
}}
 module torus(r1=1,r2=3)
{rotate_extrude()
translate([r2,0,0])circle(r1);}



--
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: FIlling gaps between complex hollow objects

Chocrates
Apologies, for a more concrete example, I have these housings that I would
like to connect together so they print as a single piece.
https://github.com/Chocrates/keyboard/blob/master/demo.scad

So connect together in this case means that for the object centered at the
origin, I would like to connect the edge at -x and -y with the object next
to it.  



--
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: FIlling gaps between complex hollow objects

TLC123
ok sure thing
So to not go completely crazy i put all repeating code in modules.
The hull didn't work out as mentioned before.
<http://forum.openscad.org/file/t1678/1.jpg>

One way around is to make special versions of the key thing with
just the right edge and just the left edge and pair them up
with the convex hull operator.
<http://forum.openscad.org/file/t1678/Capturwe.jpg>

code here:
  https://gist.github.com/TLC123/33a4fa73ff0ae028b1ad8ff85599e518
<https://gist.github.com/TLC123/33a4fa73ff0ae028b1ad8ff85599e518>  




--
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: FIlling gaps between complex hollow objects

Ronaldo
I haven't seen Torleif's code but from his images I think I had basically the same idea.

I correct the arrangement of the frames in order to make them tangent to the parabola.
And added two more frames just for fun.



a    = 2/20/20; // parabola constant
step =  20;
xini = -80;
xend =  80;

for(x =[xini:step:xend]) {
  position(x) frame();
  if(x>xini)
  hull(){ // left gap filling
    position(x)      slice( 19/2) frame();
    position(x-step) slice(-19/2) frame();
  }
}

module position(x) { // along the parabola
  translate([-x, 0, a*x*x])
      rotate([0, atan(2*a*x), 0])
        children();
}

// cut a slice of children
module slice(x=10) {
  // x is the slice position
  thickness = 0.1;
  intersection(){
    children();
    translate([x,0,0]) cube([thickness,10000,10000],center=true);
  }
}

module frame() {
    union () {
      difference () {
        cube ([19, 19, 4.9], center=true);
        cube ([15, 15,  10], center=true);
      }
      translate ([0, -7.125, 0]) frame_tappet();
      translate ([0,  7.125, 0]) frame_tappet();
    }
      
  module frame_tappet()
    rotate (a=90.0, v=[0, 0, 1]) 
      rotate (a=180.0, v=[0, 1, 0]) 
        difference () {
          cube ([0.75, 2.9, 3.85], center=true);
          translate ([0.5, 0, 3.85])
            rotate (a=45.0, v=[0, 1, 0])
              cube ([7.5, 3, 3.85], center=true);
        }
}


2017-12-30 16:16 GMT-02:00 TLC123 <[hidden email]>:
ok sure thing
So to not go completely crazy i put all repeating code in modules.
The hull didn't work out as mentioned before.
<http://forum.openscad.org/file/t1678/1.jpg>

One way around is to make special versions of the key thing with
just the right edge and just the left edge and pair them up
with the convex hull operator.
<http://forum.openscad.org/file/t1678/Capturwe.jpg>

code here:
  https://gist.github.com/TLC123/33a4fa73ff0ae028b1ad8ff85599e518
<https://gist.github.com/TLC123/33a4fa73ff0ae028b1ad8ff85599e518>




--
Sent from: http://forum.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: FIlling gaps between complex hollow objects

Ronaldo
It works equally well with tori!



  a    = 2/20/20; // parabola constant
  step =  20;
  xini = -80;
  xend =  80;

  for(x =[xini:step:xend]) {
    position(x) torus(2,9);
    color("red")
    if(x>xini)
    hull(){ // left gap filling
      position(x)      slice( 9) torus(2,9);
      position(x-step) slice(-9) torus(2,9);
    }
  }

   module torus(r1=1,r2=3) 
     rotate_extrude() translate([r2,0,0])circle(r1);

Certainly the slice cut position (9 in this case) should be adjusted appropriately for each object.


2017-12-30 16:44 GMT-02:00 Ronaldo Persiano <[hidden email]>:
I haven't seen Torleif's code but from his images I think I had basically the same idea.

I correct the arrangement of the frames in order to make them tangent to the parabola.
And added two more frames just for fun.



a    = 2/20/20; // parabola constant
step =  20;
xini = -80;
xend =  80;

for(x =[xini:step:xend]) {
  position(x) frame();
  if(x>xini)
  hull(){ // left gap filling
    position(x)      slice( 19/2) frame();
    position(x-step) slice(-19/2) frame();
  }
}

module position(x) { // along the parabola
  translate([-x, 0, a*x*x])
      rotate([0, atan(2*a*x), 0])
        children();
}

// cut a slice of children
module slice(x=10) {
  // x is the slice position
  thickness = 0.1;
  intersection(){
    children();
    translate([x,0,0]) cube([thickness,10000,10000],center=true);
  }
}

module frame() {
    union () {
      difference () {
        cube ([19, 19, 4.9], center=true);
        cube ([15, 15,  10], center=true);
      }
      translate ([0, -7.125, 0]) frame_tappet();
      translate ([0,  7.125, 0]) frame_tappet();
    }
      
  module frame_tappet()
    rotate (a=90.0, v=[0, 0, 1]) 
      rotate (a=180.0, v=[0, 1, 0]) 
        difference () {
          cube ([0.75, 2.9, 3.85], center=true);
          translate ([0.5, 0, 3.85])
            rotate (a=45.0, v=[0, 1, 0])
              cube ([7.5, 3, 3.85], center=true);
        }
}


2017-12-30 16:16 GMT-02:00 TLC123 <[hidden email]>:
ok sure thing
So to not go completely crazy i put all repeating code in modules.
The hull didn't work out as mentioned before.
<http://forum.openscad.org/file/t1678/1.jpg>

One way around is to make special versions of the key thing with
just the right edge and just the left edge and pair them up
with the convex hull operator.
<http://forum.openscad.org/file/t1678/Capturwe.jpg>

code here:
  https://gist.github.com/TLC123/33a4fa73ff0ae028b1ad8ff85599e518
<https://gist.github.com/TLC123/33a4fa73ff0ae028b1ad8ff85599e518>




--
Sent from: http://forum.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: FIlling gaps between complex hollow objects

TLC123
Nice job Ro. I guess there is a bunch of ways to skin that cat.

I often find there is a difference between cad programming and software
programming in that there is less returned value in the effort to find very
general solutions to a loose set of problems. For me it's usually more
efficient to just find a simple solution to a specific problem. If i
encounter a similar problem again, i just cut an paste the right snippets
rater than librarify it. I maybe make the wrong assumption that probably no
one is going to maintain my code after it has produced the intended
geometry.



--
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: FIlling gaps between complex hollow objects

Ronaldo
Hi, Torleif.

We surely have different perspectives. I have some difficulties at operational level (I have never been able to memorize the multiplication table, for instance) and some skills at the conceptual level. So I usually try to understand what is behind before seeing the front end. That is why I use functions and modules a lot. Each one has a meaning and represent a concept. And as they usually have fewer lines and key comments, I can understand them months or years later. The same happens with code formatting: I need a minimum of ruled format style to easily understand a code.

I use that approach even for building an ad hoc code. Eventually I found there something that may be reusable and worth to have in a library although that is not my goal.

I rarely consider operator modules during the development phase. They sometimes emerge later when I try to "wring" the code, a phase required by some obsession. 

If there is really such a discrimination, yes, I am more a software programmer than a CAD programmer.

2017-12-30 18:53 GMT-02:00 TLC123 <[hidden email]>:
Nice job Ro. I guess there is a bunch of ways to skin that cat.

I often find there is a difference between cad programming and software
programming in that there is less returned value in the effort to find very
general solutions to a loose set of problems. For me it's usually more
efficient to just find a simple solution to a specific problem. If i
encounter a similar problem again, i just cut an paste the right snippets
rater than librarify it. I maybe make the wrong assumption that probably no
one is going to maintain my code after it has produced the intended
geometry.



--
Sent from: http://forum.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: FIlling gaps between complex hollow objects

Chocrates
Awesome thank you guys.  Still going through your solutions but they look
exactly like what I was trying to do.  

Regarding CAD Programming vs General Programming,  when you are building
geometry in CAD, do you ever expect to need to maintain it again to produce
a different iteration on your result?  
I imagine if there is a piece of functionality that keeps getting copied and
pasted, that is when you make it in to a general solution in a library.  
I was pointed to this one a while ago: https://github.com/jreinhardt/BOLTS,
but it doesn't look maintained so I wonder if people in general don't find
much value in cad libraries in general?




--
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: FIlling gaps between complex hollow objects

G. Wade Johnson
On Sun, 31 Dec 2017 09:17:46 -0700 (MST)
Chocrates <[hidden email]> wrote:

> Awesome thank you guys.  Still going through your solutions but they
> look exactly like what I was trying to do.  
>
> Regarding CAD Programming vs General Programming,  when you are
> building geometry in CAD, do you ever expect to need to maintain it
> again to produce a different iteration on your result?  
> I imagine if there is a piece of functionality that keeps getting
> copied and pasted, that is when you make it in to a general solution
> in a library. I was pointed to this one a while ago:
> https://github.com/jreinhardt/BOLTS, but it doesn't look maintained
> so I wonder if people in general don't find much value in cad
> libraries in general?

I have my own libraries that I maintain in version control exactly like
I do any other code. I have used some libraries from others.

Honestly, I suspect that maintenance of cad libraries will follow the
same model as code libraries: some maintained, some not; some forked,
some not.

Remember that many people working with OpenSCAD are not programmers and
may not immediately think of libraries as a resource. Also OpenSCAD is
relatively new as languages go, this can result in many libraries
that scratch one person's itch but are not quite as re-usable or
simple as needed for others to use. Some language issues have also made
general libraries harder to make and maintain than we'd like.

These issues are improving, so keep an eye out.

G. Wade

> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


--
Be careful about reading health books. You may die of a misprint.
                                                       -- Mark Twain

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

Re: FIlling gaps between complex hollow objects

nophead
In reply to this post by Chocrates
I use my own library in all but my simplest projects and find I need to​ add to it for most projects. It is mainly models of non printed parts that I use in assemblies but does have some utilities and some printed parts that I use across projects such as boxes, feet, handles and fixing blocks. I started it about a year ago. I include it in every printed part design because at the very least it sets $fa and $fs for printing and defines polyholes. These are the the larger things I have made with it over the last year.

Cover and laser mount for HydraRaptor.



RPI LCD display case.



ATX lab PSU.



Mains PSU.




WiFi controlled photographic turntable.



Solder fume filter.




On 31 December 2017 at 16:17, Chocrates <[hidden email]> wrote:
Awesome thank you guys.  Still going through your solutions but they look
exactly like what I was trying to do.

Regarding CAD Programming vs General Programming,  when you are building
geometry in CAD, do you ever expect to need to maintain it again to produce
a different iteration on your result?
I imagine if there is a piece of functionality that keeps getting copied and
pasted, that is when you make it in to a general solution in a library.
I was pointed to this one a while ago: https://github.com/jreinhardt/BOLTS,
but it doesn't look maintained so I wonder if people in general don't find
much value in cad libraries in general?




--
Sent from: http://forum.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: FIlling gaps between complex hollow objects

doug.moen
In reply to this post by Chocrates
I have a lot of small library components that I continually reuse in other projects.

CAD libraries can be useful, but there are a lot of factors involved:
 1. Is the library well designed and easy to use?
 2. Is the library robust, or does it fail on edge cases. This is related to ease of use.
 3. Is the library well documented? An issue for using someone else's library.
 4. How easy is it to install the library and start using it?
 5. How compelling is the library? Is it easier to write the code from scratch than it
     is to figure out how to install and use the library? An issue for using someone
     else's library.

Factors 1-3 are a job for the library designer. It's lot of work to make a library useful to other people: you need well designed interfaces, robustness, good documentation. About half of my "reusable code" can only be reused by copying, pasting and hacking the code, since I haven't figured out good general purpose APIs, or the code only works for a narrow range of cases.

Factor 4 is a tool issue. In web programming, you can often start using a 3rd party javascript library just by pasting a URL into your web page, which is super easy. In the Rust language, it's the same, if you use the cargo tool: you can reference an external library using the URL of a git repo. This means you can download somebody else's program and external library dependencies are automatically taken care of, you don't need to think about it. In OpenSCAD, it's not so easy.

On 31 December 2017 at 11:17, Chocrates <[hidden email]> wrote:
Awesome thank you guys.  Still going through your solutions but they look
exactly like what I was trying to do.

Regarding CAD Programming vs General Programming,  when you are building
geometry in CAD, do you ever expect to need to maintain it again to produce
a different iteration on your result?
I imagine if there is a piece of functionality that keeps getting copied and
pasted, that is when you make it in to a general solution in a library.
I was pointed to this one a while ago: https://github.com/jreinhardt/BOLTS,
but it doesn't look maintained so I wonder if people in general don't find
much value in cad libraries in general?




--
Sent from: http://forum.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: FIlling gaps between complex hollow objects

Troberg
In reply to this post by TLC123
> I often find there is a difference between cad programming and software
programming in that there is less returned value in the effort to find very
general solutions to a loose set of problems.

I don't agree, I find it extremely useful to have a good library of useful
generic code, both for convenience and for readability.

Unlike most here, I use OpenSCAD for making plans for builds, not for 3D
printing. So, I have a library with all the parts I use, screws, eyebolts,
threaded bars, nuts, washers, wooden parts, chains, hinges and so on. I also
have some useful math functions. There is also a bunch of useful operations,
such as modules to put a radius on a corner, drilling holes, making
transition curves and so on.

How does this help me?

* I don't have to re-do each part.

* If I make a better, more detailed model, it'll be replaced in every
design. Fix once, apply everywhere.

* Sure, I could just to a difference with a cylinder to make a hole, but if
I make a difference with a hole object, it will clearly say "hole" in the
code. Likewise, a threaded bar is simply a cylinder if a certain diameter in
a certain color, but it makes for clearer code if it says threadedbar().

* Since each object has it's own call, I get a part list. I know exactly how
many screws I need, how many meters of each type of wood I need and so on. I
get it with prices, where to buy it, product number, sometimes even which
shelf in the store, and even the weight of the parts.

* Since each object and operation have it's own call, I also get an
"operations list". So, I know that I will have to measure and drill 300
holes, and that'll take approximataley so many minutes. I know that I'll
have to cut this many planks, and it'll take this long. If I want, I can
also add extra operations that aren't parts-based, or just because I know
that "rigging this up squarely will take some extra time...".

* It helps me remember what resources I have. Often, I sit and think "how
will I solve this problem?", looking at the parts and suddenly "Hmm, if I
take a hinge and lock it with a slide bolt...".

* It helps me keep a certain selection of standard parts. Nothing wrong with
having more different parts, but if there is no good reason for it, stick
with a part you have.

* You can adapt the modules so that it's more handy to use. For example, my
screws and bits that goes on screws (nuts, washers, wingnuts...) all have a
z-offset and a parameter to flip them (where applicable). So, I create the
screw, then simply stack everything that goes on it using only the z-offset,
then move it in place. Example:

    bolt_M10(3);
    squarewasher_M10(0,false);
    squarewasher_M10(45,true);
    wingnut_M10(48,true);

This creates a bolt with a wingnut on the other end, and two square washers.
This can then be translated and rotated to wherever it's supposed to be.
Very simple and clear code.



--
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: FIlling gaps between complex hollow objects

TLC123
I respect that OpenScad has a bunch of uses other than 3D printing.
For parts, i totally get it. Its a resource library in software analogy.
For functions its handy and i should probably maintain a basic library for
myself.

For modules as operators on unknown children i find it almost pointless to
package them up for general black box usage by others.
Sure it may function as shorthand sugar but as long as a module
cant know anything or reason about the children it  cant provide
profound value for someone that don't understand the modules inner workings.

Point being, OpenScad scripts is not software, it's markup with the luxury
of evaluated expression.
I just belive it's somewhat important to note that distinction from time to
time.

Happy New Year to all of ya here.




--
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: FIlling gaps between complex hollow objects

Troberg
That I agree with. I find it endlessly frustrating that I can't just do
something like:

sphere(d=100,name="thissphere");

and then later, after it's been moved around and all that do a:

translate([thissphere.x,thissphere.y,thissphere.z])
cylinder(d=thissphere.d,1000);

Or, stuff like my parts list. Since variables are kind of wonked compared to
other languages, I have to echo a line for each part, then copy the echo
output to another program I wrote which parses it and sums things up.

I've been thinking a lot about encapsulating the 3D markup in some framework
in some kind of "real script language", such as VBScript, JavaScript or
Rexx, but I haven't got around to actually doing anything.



--
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: FIlling gaps between complex hollow objects

cacb
On 02. jan. 2018 15:19, Troberg wrote:

> That I agree with. I find it endlessly frustrating that I can't just do
> something like:
>
> sphere(d=100,name="thissphere");
>
> and then later, after it's been moved around and all that do a:
>
> translate([thissphere.x,thissphere.y,thissphere.z])
> cylinder(d=thissphere.d,1000);
>
> Or, stuff like my parts list. Since variables are kind of wonked compared to
> other languages, I have to echo a line for each part, then copy the echo
> output to another program I wrote which parses it and sums things up.
>
> I've been thinking a lot about encapsulating the 3D markup in some framework
> in some kind of "real script language", such as VBScript, JavaScript or
> Rexx, but I haven't got around to actually doing anything.
I guess this is the recurring talk about the functional language in
OpenSCAD. The features you describe imply a procedural language. I have
had similar ideas regarding use of a scripting language. Your example
can be expressed as below using my AngelScript* implementation.

*AngelScript is a procedural language with strong types
http://www.angelcode.com/angelscript/sdk/docs/manual/doc_script.html
The @ notation refers to "object handles".

shape@ main_shape()
{
    solid@ sph = translate(200,300,400)*sphere(r:50);
    sphere@ s  = cast<sphere@>(sph);
    pos3d@ c   = s.box().center();
    return translate(c.x(),c.y(),c.z())*
           cylinder(r:s.radius(),h:1000) + s;
}

It may be possible to eliminate the second line to make it more compact,
but this runs as shown now creating an explicit union of a cylinder and
the given sphere 's', much like you explained.

The attached OpenSCAD file was generated from the above script.

Carsten Arnholm

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

openscad.csg (702 bytes) Download Attachment