difference a include file, does it work?

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

difference a include file, does it work?

Droidene
I a trying to make a hole into this box, iv done like this:

difference () {
    color ("black", 1)
    cube ([233,533,451]);
    translate ([5,5,5]) cube ([243,523,441]);
    translate ([56.5,95,440]) cylinder_array(21,5,25) cylinder(r=2, h=15);
    }
   
    module cylinder_array( count, distance, rows )
        for (i = [0 : count - 1], h = [0 : rows-1])
            translate([distance * h, distance * i, 0])
                children();

This works, but i want less code by include a file by doing this:

difference () {
    color ("black", 1)
    cube ([233,533,451]);
    translate ([5,5,5]) cube ([243,523,441]);
    translate ([56.5,95,440]) include <pin.scad>;
    }

This aint working why?
Does this means you cannot difference a include file?
Reply | Threaded
Open this post in threaded view
|

Re: difference a include file, does it work?

doug.moen
Try putting braces around the include statement. "Include" just does macro substitution.

On Sunday, 25 June 2017, Droidene <[hidden email]> wrote:
I a trying to make a hole into this box, iv done like this:

difference () {
    color ("black", 1)
    cube ([233,533,451]);
    translate ([5,5,5]) cube ([243,523,441]);
    translate ([56.5,95,440]) cylinder_array(21,5,25) cylinder(r=2, h=15);
    }

    module cylinder_array( count, distance, rows )
        for (i = [0 : count - 1], h = [0 : rows-1])
            translate([distance * h, distance * i, 0])
                children();

This works, but i want less code by include a file by doing this:

difference () {
    color ("black", 1)
    cube ([233,533,451]);
    translate ([5,5,5]) cube ([243,523,441]);
    translate ([56.5,95,440]) include <pin.scad>;
    }

This aint working why?
Does this means you cannot difference a include file?




--
View this message in context: http://forum.openscad.org/difference-a-include-file-does-it-work-tp21743.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;Discuss@lists.openscad.org&#39;)">Discuss@...
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: difference a include file, does it work?

Gadgetmind
In reply to this post by Droidene
On 2017-06-25 15:40, Droidene wrote:
> Does this means you cannot difference a include file?

It doesn't really make much sense TBH. Define a module in the include
file and difference that module.


_______________________________________________
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: difference a include file, does it work?

tp3
In reply to this post by doug.moen
The suggested way of doing this would be to define the parts as
module in the other file and load it via use<>.

Example:

--- file: part.scad

module part() {
        cube(10);
}

--- file: main.scad

use <part.scad>

module array( count, distance, rows )
    for (i = [0 : count - 1], h = [0 : rows-1])
        translate([distance * h, distance * i, 0])
            children();

array(10, 20, 2) part();

---

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: difference a include file, does it work?

Droidene
In reply to this post by Gadgetmind
Thank you all, yea i made module in that include and just simple difference that cylinder.
It works.

Awsome guys.
Im sure to be back with another post later on, iv learned a lot already.