discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Help with two problems with SCAD

M
MichaelAtOz
Thu, May 11, 2017 5:56 AM

If you stick render() before each union in the difference it works,
highlights lots of coincident faces. (takes a while to preview the first
time)

difference (){
union(){
difference()
{
// Cutting 120 Degrees of Circle, Screw Holes  from
render()
union(){
...
}  // End of Union of first group for Difference
render()
union(){
...
}  // End of Union of Cuting elements
}  // End of Difference for Paddle making
} // End of Union of everything
// Note NO difference
} // End of Difference


Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21436.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

If you stick render() before each union in the difference it works, highlights lots of coincident faces. (takes a while to preview the first time) difference (){ union(){ difference() { // Cutting 120 Degrees of Circle, Screw Holes from render() union(){ ... } // End of Union of first group for Difference render() union(){ ... } // End of Union of Cuting elements } // End of Difference for Paddle making } // End of Union of everything // Note NO difference } // End of Difference ----- Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21436.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MP
Marijan Pollak
Thu, May 11, 2017 8:42 PM

I have dine that this morning by myself, no changes in problem, Object is
intentionaly hollowand cavitied serve special mpurpose, Just latr
Differencewere usung object with heavy thicknessand not positioned right so
it cut trough center instead at offset from center.
It is new Wind turbine composed of conical walls and vertical  ones. After
half day of rendering it is more normal looking but is I touch anythinmg it
wipes screen and is non responding again. It should be centered on 0,0,0 as
it is circular and multy symetrical. it is as should be but I cannot see it
except as overlarge, so only part of surface fir the screen.

--
View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21440.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I have dine that this morning by myself, no changes in problem, Object is intentionaly hollowand cavitied serve special mpurpose, Just latr Differencewere usung object with heavy thicknessand not positioned right so it cut trough center instead at offset from center. It is new Wind turbine composed of conical walls and vertical ones. After half day of rendering it is more normal looking but is I touch anythinmg it wipes screen and is non responding again. It should be centered on 0,0,0 as it is circular and multy symetrical. it is as should be but I cannot see it except as overlarge, so only part of surface fir the screen. -- View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21440.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MP
Marijan Pollak
Thu, May 11, 2017 9:16 PM

      render()  Helped, at least it is not "not respondimg"........

--
View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21441.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

      render() Helped, at least it is not "not respondimg"........ -- View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21441.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Thu, May 11, 2017 10:28 PM

Your code is very crude and seems to create and use a bunch of empty
differences. No wonder that it does not behave very well.

Just one example out of many: Look at the call

makeMantle (he=th, ro=tr+1, ri=tr, mccr=ccr);

It is not properly defaulted (which is bad style) and it F6-renders into a
non-valid 2-manifold. No way to head on already at this point ...

Some hints:

  • If you compose a design from multiple components, every component has to
    be a valid 2 manifold, otherwise you are in trouble.

  • When debugging a component, try to successfully render each of its
    components first. Do this in a bottom-up fashion.

  • If you don't see what you expect, omit Boolean operations first by
    commenting them out. To "find" a component within a composed object mark it
    with #.

  • use well chosen default values to ease testing and simplify calls as much
    as possible.

  • Reduce complexity (and increase readability) as much as possible, by:

  1. poperly indenting your code with aligned brackets and bodies;

  2. omitting (tons of) superfluous curly bracket pairs for operators like
    translate() rotate() and for() that have only a single operand. E.g. it is
    perfectly ok to stack something like: /scale(A) linear_extrude(B) for(i=C)
    rotate(D) translate(E) myModule(...);/  without putting a single curly
    bracket pair.

  3. omitting explicit unions, where OpenSCAD puts implicit unions. This is
    essentially almost everywhere possible. An exception would be a boolean
    expression like difference() where the first (!) operand is explicitly
    composed by the union of several objects or an intersection with such an
    operand. Operators like translate(), scale() rotate(), for() use an implict
    union, if they operate over a list of operands. See also the difference
    between intersection() and intersection_for().

Good code is: readable and well structured into meaningful modules,
submodules and functions. Each chunk of code should be designed in a way, so
that can be easily tested on its own. It omits lengthy and crude sequences
of badly organized and wildly transformed components. If you want to keep
control over code, try to keep the body of any module as small as possible
and test it and its parameter range properly before you use it as component
in a larger context. Otherwise it will start to play with you and you will
spend 99% of your time with debugging.

--
View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21442.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Your code is very crude and seems to create and use a bunch of empty differences. No wonder that it does not behave very well. Just one example out of many: Look at the call > makeMantle (he=th, ro=tr+1, ri=tr, mccr=ccr); It is not properly defaulted (which is bad style) and it F6-renders into a non-valid 2-manifold. No way to head on already at this point ... Some hints: - If you compose a design from multiple components, every component has to be a valid 2 manifold, otherwise you are in trouble. - When debugging a component, try to successfully render each of its components first. Do this in a bottom-up fashion. - If you don't see what you expect, omit Boolean operations first by commenting them out. To "find" a component within a composed object mark it with #. - use well chosen default values to ease testing and simplify calls as much as possible. - Reduce complexity (and increase readability) as much as possible, by: 1. poperly indenting your code with aligned brackets and bodies; 2. omitting (tons of) superfluous curly bracket pairs for operators like translate() rotate() and for() that have only a single operand. E.g. it is perfectly ok to stack something like: /scale(A) linear_extrude(B) for(i=C) rotate(D) translate(E) myModule(...);/ without putting a single curly bracket pair. 3. omitting explicit unions, where OpenSCAD puts implicit unions. This is essentially almost everywhere possible. An exception would be a boolean expression like difference() where the first (!) operand is explicitly composed by the union of several objects or an intersection with such an operand. Operators like translate(), scale() rotate(), for() use an implict union, if they operate over a list of operands. See also the difference between intersection() and intersection_for(). Good code is: readable and well structured into meaningful modules, submodules and functions. Each chunk of code should be designed in a way, so that can be easily tested on its own. It omits lengthy and crude sequences of badly organized and wildly transformed components. If you want to keep control over code, try to keep the body of any module as small as possible and test it and its parameter range properly before you use it as component in a larger context. Otherwise it will start to play with you and you will spend 99% of your time with debugging. -- View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21442.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MP
Marijan Pollak
Sat, May 13, 2017 12:21 AM

Thanks for lecture. Unfortunately I do not understand You entirely. First
English is not my Native Language, and second this is progran in works, I am
adding and commenting out lot of things while testing results. How would I
know module is properly defaulted? Whsat is "valid 2 manifold"? I am usualy
making indentatiions, and when program finally work I clean up and make
order, and Differences it seems empty to You are actually necesary and not
empty. Maybe when I would use  SCAD longer, I would find some shortcuts. but
I reason that putting curly brackets cannot make code less readable. What I
try to achieve are thin conical walls joined together on top, to be strong
and light, and I think 3D printer can print it, if it would do exactly what
I programmed it for.  As there is no function to make pipe of desired
diameter  I am making it by making difference from two cylinders, but i need
only parts of this pipe of certain number of degrees and that is also not
easy to do, so I am forced to improvise, and do best I can. Global variables
do not exist in SCAD so Modules do not see what is not explicitely passed as
parameter, and that goes double for modules called from other modules, as
they have to be nested and defined within module that call them
what means same module cannot be called in another that can use itif I
understood some rules I have to find hard way.
This not easy for me because I am from another time and carry legacy of 26+
programming languages some in several generations add on different Platforms
and from different Vendors on same Platform.
But in ganeral I find SCAD usefull for my work as Inventor, and I have done
lot for few months I am using it. I am asking for help only when I cannot
finf solution by my own efforts.
right now next problem I am facing is to construct machine that use lot of
pipes  that must be positioned precosely and have bends thar are half
circular, and my method of creating pipes from difference of two cilinders
is good only for straight pipes. if anyone know function to create such
pipes, please tell me where to find it.
http://forum.openscad.org/file/n21446/PerpetumMobiusDupliIstostraniPomaknutProziran.jpg

--
View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21446.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Thanks for lecture. Unfortunately I do not understand You entirely. First English is not my Native Language, and second this is progran in works, I am adding and commenting out lot of things while testing results. How would I know module is properly defaulted? Whsat is "valid 2 manifold"? I am usualy making indentatiions, and when program finally work I clean up and make order, and Differences it seems empty to You are actually necesary and not empty. Maybe when I would use SCAD longer, I would find some shortcuts. but I reason that putting curly brackets cannot make code less readable. What I try to achieve are thin conical walls joined together on top, to be strong and light, and I think 3D printer can print it, if it would do exactly what I programmed it for. As there is no function to make pipe of desired diameter I am making it by making difference from two cylinders, but i need only parts of this pipe of certain number of degrees and that is also not easy to do, so I am forced to improvise, and do best I can. Global variables do not exist in SCAD so Modules do not see what is not explicitely passed as parameter, and that goes double for modules called from other modules, as they have to be nested and defined within module that call them what means same module cannot be called in another that can use itif I understood some rules I have to find hard way. This not easy for me because I am from another time and carry legacy of 26+ programming languages some in several generations add on different Platforms and from different Vendors on same Platform. But in ganeral I find SCAD usefull for my work as Inventor, and I have done lot for few months I am using it. I am asking for help only when I cannot finf solution by my own efforts. right now next problem I am facing is to construct machine that use lot of pipes that must be positioned precosely and have bends thar are half circular, and my method of creating pipes from difference of two cilinders is good only for straight pipes. if anyone know function to create such pipes, please tell me where to find it. <http://forum.openscad.org/file/n21446/PerpetumMobiusDupliIstostraniPomaknutProziran.jpg> -- View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21446.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MP
Marijan Pollak
Sat, May 13, 2017 12:30 AM

Actualy it is not that simple:
http://forum.openscad.org/file/n21447/Photo-0001.jpg

i have made this by hand from just ONE piece of pipe, it would be much
better 3D printed.

--
View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21447.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Actualy it is not that simple: <http://forum.openscad.org/file/n21447/Photo-0001.jpg> i have made this by hand from just ONE piece of pipe, it would be much better 3D printed. -- View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21447.html Sent from the OpenSCAD mailing list archive at Nabble.com.
CA
Carsten Arnholm
Sat, May 13, 2017 6:55 AM

On 13. mai 2017 02:21, Marijan Pollak wrote:

right now next problem I am facing is to construct machine that use lot of
pipes  that must be positioned precosely and have bends thar are half
circular, and my method of creating pipes from difference of two cilinders
is good only for straight pipes. if anyone know function to create such
pipes, please tell me where to find it.
http://forum.openscad.org/file/n21446/PerpetumMobiusDupliIstostraniPomaknutProziran.jpg

So basically you have 2 closed pipe loops consisting of straight and
circular segments, and the 2 loops are independent of each other (not
connected to each other) and rotated 45 degrees relative. Is that right?

I tried to open the OpenSCAD file of your original post, but it didn't
look anything like the photo above. To get any further I think it would
be a good idea to clarify whether the above photo is indeed what you
want to create.

Parts of your hand made thing below seems to be in loose agreement with
the above photo, but the details are unclear.
http://forum.openscad.org/file/n21447/Photo-0001.jpg

I have no idea if this thing would do anything meaningful, it just seems
like a few bent pipes with no entrance/exit, but it should be possible
to model if the top photo is representative.

So is it the "PerpetumMobiusDupliIstostraniPomaknutProziran.jpg" layout
as shown you are attempting to recreate, with the dimensions from the
.scad file in your original post?

Carsten Arnholm

On 13. mai 2017 02:21, Marijan Pollak wrote: > right now next problem I am facing is to construct machine that use lot of > pipes that must be positioned precosely and have bends thar are half > circular, and my method of creating pipes from difference of two cilinders > is good only for straight pipes. if anyone know function to create such > pipes, please tell me where to find it. > <http://forum.openscad.org/file/n21446/PerpetumMobiusDupliIstostraniPomaknutProziran.jpg> So basically you have 2 closed pipe loops consisting of straight and circular segments, and the 2 loops are independent of each other (not connected to each other) and rotated 45 degrees relative. Is that right? I tried to open the OpenSCAD file of your original post, but it didn't look anything like the photo above. To get any further I think it would be a good idea to clarify whether the above photo is indeed what you want to create. Parts of your hand made thing below seems to be in loose agreement with the above photo, but the details are unclear. http://forum.openscad.org/file/n21447/Photo-0001.jpg I have no idea if this thing would do anything meaningful, it just seems like a few bent pipes with no entrance/exit, but it should be possible to model if the top photo is representative. So is it the "PerpetumMobiusDupliIstostraniPomaknutProziran.jpg" layout as shown you are attempting to recreate, with the dimensions from the .scad file in your original post? Carsten Arnholm
MP
Marijan Pollak
Sun, May 14, 2017 1:56 PM

Hi, I must correct You, there is no overlaping FACES, just overlaping EDGES,
as conical and vertical walls are joined on top. that creates walls that
have no external faces as verticall walls are inside between two conical
walls. I do not see why this shouls be preblem as every wallis created
separatelly and joined to others with union () while each wall is difference
betveen two cylinders or two conuses. So if each is rendered and then joined
together as it is written all should be as intended to be.
I followed adwice to remove as many curly brackets and use implied unions,
asnd found that object wihin for loop are not impilcitely part of union in
fact thex are not created at all if union doed not precede for loops and
have curly brackets.
I tried to simplifa program cut results are still slower rendering with both
f5 ans f6 use.

--
View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21467.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hi, I must correct You, there is no overlaping FACES, just overlaping EDGES, as conical and vertical walls are joined on top. that creates walls that have no external faces as verticall walls are inside between two conical walls. I do not see why this shouls be preblem as every wallis created separatelly and joined to others with union () while each wall is difference betveen two cylinders or two conuses. So if each is rendered and then joined together as it is written all should be as intended to be. I followed adwice to remove as many curly brackets and use implied unions, asnd found that object wihin for loop are not impilcitely part of union in fact thex are not created at all if union doed not precede for loops and have curly brackets. I tried to simplifa program cut results are still slower rendering with both f5 ans f6 use. -- View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21467.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MP
Marijan Pollak
Sun, May 14, 2017 2:26 PM

Well sory for confusion. This is not strictly related to first example and
first picture is simplified version  to show what I need while photo is of
actual machine built by hand that has to be made precisely an symetrically
drawn in SCAD, and which is more complicated specially as it is made from
one piece of hose. There could be two or more systems turned certain numbers
of dehrees in relatiom to one another.It is Gravity motor, but I did not
asked for help with that, only in creating round pipes or cylinders which I
can made difference from cylindrical plate to get pipes inside. I intend to
put it in bottom  of turbine in first example, or any of my hawt turbines so
they would turn even without wind.
I got example of "Macaroni Maker" exanple wihich I have to study jet, but as
I ecplained I would prefer that to be cylinders instead of pipes so I can
hide system from ones who does not believe such things is possible, and also
because Patent Office would Label it Perpetum Mobile and that is forbidden
for patenting.
Thank You  in advance.

--
View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21470.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Well sory for confusion. This is not strictly related to first example and first picture is simplified version to show what I need while photo is of actual machine built by hand that has to be made precisely an symetrically drawn in SCAD, and which is more complicated specially as it is made from one piece of hose. There could be two or more systems turned certain numbers of dehrees in relatiom to one another.It is Gravity motor, but I did not asked for help with that, only in creating round pipes or cylinders which I can made difference from cylindrical plate to get pipes inside. I intend to put it in bottom of turbine in first example, or any of my hawt turbines so they would turn even without wind. I got example of "Macaroni Maker" exanple wihich I have to study jet, but as I ecplained I would prefer that to be cylinders instead of pipes so I can hide system from ones who does not believe such things is possible, and also because Patent Office would Label it Perpetum Mobile and that is forbidden for patenting. Thank You in advance. -- View this message in context: http://forum.openscad.org/Re-Help-with-two-problems-with-SCAD-tp21425p21470.html Sent from the OpenSCAD mailing list archive at Nabble.com.
CA
Carsten Arnholm
Sun, May 14, 2017 3:38 PM

On 14. mai 2017 16:26, Marijan Pollak wrote:

It is Gravity motor, but I did not
asked for help with that, only in creating round pipes or cylinders which I
can made difference from cylindrical plate to get pipes inside.

I would recommend something like below for creating pipes, instead of
subtracting cylinders. This avoids the problem that the inner cylinder
has to extend at both ends, to avoid numerical problems:

$fn=30;
module StraightPipe(ro=10, th=1, l=100)
{
linear_extrude(l)
difference() { circle(ro); circle(ro-th); }
}

module CurvedPipe(ro=10, th=1, radius=100, angle=60)
{
rotate([90,0,0])
translate([-radius,0,0])
rotate_extrude(angle=angle,$fn=60)
translate([radius,0,0])
difference() { circle(ro); circle(ro-th); }
}

translate([-50,0,0]) CurvedPipe();
translate([+50,0,0]) StraightPipe();


The angle parameter in rotate_extrude requires a recent version of OpenSCAD.

Btw. the "PerpetumMobius" photo or the model you made with hoses imply
non-planar bent pipes. That isn't possible with rotate_extrude in OpenSCAD.

Carsten Arnholm

On 14. mai 2017 16:26, Marijan Pollak wrote: > It is Gravity motor, but I did not > asked for help with that, only in creating round pipes or cylinders which I > can made difference from cylindrical plate to get pipes inside. I would recommend something like below for creating pipes, instead of subtracting cylinders. This avoids the problem that the inner cylinder has to extend at both ends, to avoid numerical problems: $fn=30; module StraightPipe(ro=10, th=1, l=100) { linear_extrude(l) difference() { circle(ro); circle(ro-th); } } module CurvedPipe(ro=10, th=1, radius=100, angle=60) { rotate([90,0,0]) translate([-radius,0,0]) rotate_extrude(angle=angle,$fn=60) translate([radius,0,0]) difference() { circle(ro); circle(ro-th); } } translate([-50,0,0]) CurvedPipe(); translate([+50,0,0]) StraightPipe(); ---- The angle parameter in rotate_extrude requires a recent version of OpenSCAD. Btw. the "PerpetumMobius" photo or the model you made with hoses imply non-planar bent pipes. That isn't possible with rotate_extrude in OpenSCAD. Carsten Arnholm