discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] How do I assemble .scad objects I have designed on to one screen

J
jazzjohn
Wed, Mar 15, 2017 12:26 PM

Just translate each object as you call it. For example:

Include <myModuleFile.scad>

//will place at origin:
OneOfTheModules();

//will place elsewhere:
translate([100, 200, 100])
OneOfTheModules();

--
View this message in context: http://forum.openscad.org/How-do-I-assemble-scad-objects-I-have-designed-on-to-one-screen-tp20893p20916.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Just translate each object as you call it. For example: Include <myModuleFile.scad> //will place at origin: OneOfTheModules(); //will place elsewhere: translate([100, 200, 100]) OneOfTheModules(); -- View this message in context: http://forum.openscad.org/How-do-I-assemble-scad-objects-I-have-designed-on-to-one-screen-tp20893p20916.html Sent from the OpenSCAD mailing list archive at Nabble.com.
D
doug
Wed, Mar 15, 2017 7:09 PM

The suggestion is:

//will place at origin:
OneOfTheModules();

//will place elsewhere:
translate([100, 200, 100])
OneOfTheModules();

My question is:

If I do something like that with multiple parts that have to fit
together and they use dimensions that have to match: Is there any way to
avoid the problem of the treatment of "variables" where one has to be
careful about defining them once and only once?

As of now I am defining what I would call globals and drawing the parts
in modules which are given dimensions as arguments using a bunch of what
I call subroutine calls and I have to fool with // pairs in front of the
parts I want to suppress. It's impossible to tell the boss, who wonders
why I ever use a keyboard, how to do that himself.

The suggestion is: //will place at origin: OneOfTheModules(); //will place elsewhere: translate([100, 200, 100]) OneOfTheModules(); My question is: If I do something like that with multiple parts that have to fit together and they use dimensions that have to match: Is there any way to avoid the problem of the treatment of "variables" where one has to be careful about defining them once and only once? As of now I am defining what I would call globals and drawing the parts in modules which are given dimensions as arguments using a bunch of what I call subroutine calls and I have to fool with // pairs in front of the parts I want to suppress. It's impossible to tell the boss, who wonders why I ever use a keyboard, how to do that himself.
J
jazzjohn
Wed, Mar 15, 2017 7:23 PM

Please post the code in the included module file. You might be drawing the
objects in the include file (at the origin) and your call to  the include
file might not be doing anything.

Not sure what's going on, but seeing the code would make it easier for
others to help you.

--
View this message in context: http://forum.openscad.org/How-do-I-assemble-scad-objects-I-have-designed-on-to-one-screen-tp20893p20925.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Please post the code in the included module file. You might be drawing the objects in the include file (at the origin) and your call to the include file might not be doing anything. Not sure what's going on, but seeing the code would make it easier for others to help you. -- View this message in context: http://forum.openscad.org/How-do-I-assemble-scad-objects-I-have-designed-on-to-one-screen-tp20893p20925.html Sent from the OpenSCAD mailing list archive at Nabble.com.
K
Kappelmeister
Wed, Mar 15, 2017 7:47 PM

Indeed both of my 'include' modules were created centered at the origin, but
I don't understand why neither of them respond to the 'translate' command.

If it will help you help me then I will include the complete code but you
might find it rather shabbily constructed.  I have not been using Scad for
very long.

--
View this message in context: http://forum.openscad.org/How-do-I-assemble-scad-objects-I-have-designed-on-to-one-screen-tp20893p20926.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Indeed both of my 'include' modules were created centered at the origin, but I don't understand why neither of them respond to the 'translate' command. If it will help you help me then I will include the complete code but you might find it rather shabbily constructed. I have not been using Scad for very long. -- View this message in context: http://forum.openscad.org/How-do-I-assemble-scad-objects-I-have-designed-on-to-one-screen-tp20893p20926.html Sent from the OpenSCAD mailing list archive at Nabble.com.
EN
Ed Nisley
Wed, Mar 15, 2017 8:30 PM

On 03/15/2017 03:09 PM, doug wrote:

I have to fool with // pairs in front of the parts I want to suppress

You can use if() statements to control what's generated. For example, I
set a Layout constant up near the top of the file:

Layout = "BuildFinCap";

Then, after defining all the modules & whatnot, near the bottom:

if (Layout == "BuildFinCap")
translate([0,0,FinCapSize[LENGTH]])
rotate([180,0,0])
FinCap();

While creating the model, sometimes I need a cross-section:

Layout = "FinCap";
Section = true;

...

if (Layout == "FinCap") {
if (Section) render(convexity=5)
difference() {
FinCap();
translate([-FinCapSize[OD],0,FinCapSize[LENGTH]])
cube([2FinCapSize[OD],
2
FinCapSize[OD],
3*FinCapSize[LENGTH]],center=true);
}
else
FinCap();
}

That requires figuring out what you want to do beforehand, then setting
up the code to make that happen, which is not entirely a Bad Thing. It
tends to remind me what I was thinking when I started writing the code,
anyhow. [grin]

--
Ed
http://softsolder.com

On 03/15/2017 03:09 PM, doug wrote: > I have to fool with // pairs in front of the parts I want to suppress You can use if() statements to control what's generated. For example, I set a Layout constant up near the top of the file: Layout = "BuildFinCap"; Then, after defining all the modules & whatnot, near the bottom: if (Layout == "BuildFinCap") translate([0,0,FinCapSize[LENGTH]]) rotate([180,0,0]) FinCap(); While creating the model, sometimes I need a cross-section: Layout = "FinCap"; Section = true; ... if (Layout == "FinCap") { if (Section) render(convexity=5) difference() { FinCap(); translate([-FinCapSize[OD],0,FinCapSize[LENGTH]]) cube([2*FinCapSize[OD], 2*FinCapSize[OD], 3*FinCapSize[LENGTH]],center=true); } else FinCap(); } That requires figuring out what you want to do beforehand, then setting up the code to make that happen, which is not entirely a Bad Thing. It tends to remind me what I was thinking when I started writing the code, anyhow. [grin] -- Ed http://softsolder.com
J
jazzjohn
Wed, Mar 15, 2017 8:49 PM

Here's a simple example. You can compare it to what you have.

MyIncludeFile.scad
http://forum.openscad.org/file/n20930/MyIncludeFile.scad

callingProgram.scad
http://forum.openscad.org/file/n20930/callingProgram.scad

--
View this message in context: http://forum.openscad.org/How-do-I-assemble-scad-objects-I-have-designed-on-to-one-screen-tp20893p20930.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Here's a simple example. You can compare it to what you have. MyIncludeFile.scad <http://forum.openscad.org/file/n20930/MyIncludeFile.scad> callingProgram.scad <http://forum.openscad.org/file/n20930/callingProgram.scad> -- View this message in context: http://forum.openscad.org/How-do-I-assemble-scad-objects-I-have-designed-on-to-one-screen-tp20893p20930.html Sent from the OpenSCAD mailing list archive at Nabble.com.
D
doug
Wed, Mar 15, 2017 9:41 PM

I donno about limits for attachments but:

Enclosed is a .scad from which I have removed a bunch of stuff that
isn't working -- yet.

The three parts of the code have comments about introducing // pairs to
be able to look inside.

It has been working for me and even includes a use command, commented
out, which I'm working on to merge the dimensions with much longer perl5
code that handles the circuit board and has to be altered so everything
fits in the end.

The only real problem is that other people, my boss and a machinist,
have a real problem understanding.

It would be nice to offer them Apple-style click and shove to see what
I'm doing. Perhaps my scheme will help the originator of this thread.

I donno about limits for attachments but: Enclosed is a .scad from which I have removed a bunch of stuff that isn't working -- yet. The three parts of the code have comments about introducing // pairs to be able to look inside. It has been working for me and even includes a use command, commented out, which I'm working on to merge the dimensions with much longer perl5 code that handles the circuit board and has to be altered so everything fits in the end. The only real problem is that other people, my boss and a machinist, have a real problem understanding. It would be nice to offer them Apple-style click and shove to see what I'm doing. Perhaps my scheme will help the originator of this thread.
K
Kappelmeister
Wed, Mar 15, 2017 9:58 PM

BINGO!

When I named my module in the .scad file I wrote "module MidSectionFront();"
I noticed that in your example you did not put in the ";".
When I removed that from the .scad file, everything worked fine.

Many Thanks for your help. Problem solved!

--
View this message in context: http://forum.openscad.org/How-do-I-assemble-scad-objects-I-have-designed-on-to-one-screen-tp20893p20932.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

BINGO! When I named my module in the .scad file I wrote "module MidSectionFront();" I noticed that in your example you did not put in the ";". When I removed that from the .scad file, everything worked fine. Many Thanks for your help. Problem solved! -- View this message in context: http://forum.openscad.org/How-do-I-assemble-scad-objects-I-have-designed-on-to-one-screen-tp20893p20932.html Sent from the OpenSCAD mailing list archive at Nabble.com.
J
jon
Wed, Mar 15, 2017 10:04 PM

Yeah.  One extra semi-colon can be pretty annoying (and difficult to
spot).  A syntax-oriented editor that could display the extent of a
statement could be helpful here.

On 3/15/2017 5:58 PM, Kappelmeister wrote:

BINGO!

When I named my module in the .scad file I wrote "module MidSectionFront();"
I noticed that in your example you did not put in the ";".
When I removed that from the .scad file, everything worked fine.

Many Thanks for your help. Problem solved!

Yeah. One extra semi-colon can be pretty annoying (and difficult to spot). A syntax-oriented editor that could display the extent of a statement could be helpful here. On 3/15/2017 5:58 PM, Kappelmeister wrote: > BINGO! > > When I named my module in the .scad file I wrote "module MidSectionFront();" > I noticed that in your example you did not put in the ";". > When I removed that from the .scad file, everything worked fine. > > Many Thanks for your help. Problem solved! >