discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

difference a include file, does it work?

D
Droidene
Sun, Jun 25, 2017 2:40 PM

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.

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.
DM
doug moen
Sun, Jun 25, 2017 3:06 PM

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

On Sunday, 25 June 2017, Droidene koford@gmail.com 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
Discuss@lists.openscad.org javascript:;
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Try putting braces around the include statement. "Include" just does macro substitution. On Sunday, 25 June 2017, Droidene <koford@gmail.com> 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 > Discuss@lists.openscad.org <javascript:;> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
IO
Ian Oliver
Sun, Jun 25, 2017 3:12 PM

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.

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.
TP
Torsten Paul
Sun, Jun 25, 2017 3:13 PM

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.

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.
D
Droidene
Sun, Jun 25, 2017 4:41 PM

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.

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

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. -- View this message in context: http://forum.openscad.org/difference-a-include-file-does-it-work-tp21743p21747.html Sent from the OpenSCAD mailing list archive at Nabble.com.