
123

This post has NOT been accepted by the mailing list yet.
I am trying to modulate an object by not changing it's suface so I designed a code for it to be sliced and the slices be rearranged after a custom equation. The problem I have is that if the object is not flat and has holes that need to be preserved, hull does not help much. As a test, we place two objects and use the code, the two join. Of course, in a simplified case, I can cut the object and create a module out of every cut, but is there a way to automize this for, let's say, 100 modules?
module test() {
cube([200,10,2]);
translate([0,12,0])
cube([200,10,2]);
}
//variables for cut points
ca1=8.89;
ca2=8.9;
cb1=9.89;
cb2=9.9;
//variables for equation
a=110;
b=125;
c=250;
//variables for y cut points
yca1=8.89;
yca2=8.9;
ycb1=9.89;
ycb2=9.9;
//variables for y equation
ya=110;
yb=125;
yc=250;
module x2() {
for (z = [1:50])
hull() {
translate([0,0,log(z+a)*b+c])
{
difference() {
test();
translate([z+ca1,10,1]) cube([300,200,200]);
translate([ca2300+z,100,1]) cube([300,200,200]);
}
}
translate([0,0,log(z+a1)*b+c])
{
difference() {
test();
translate([z+cb1,10,1]) cube([300,200,200]);
translate([300+cb2+z,100,1]) cube([300,200,200]);
}
}
}
}
x2();

Administrator

rav0r wrote
I am trying to modulate an object by not changing it's suface so I designed a code for it to be sliced and the slices be rearranged after a custom equation. The problem I have is that if the object is not flat and has holes that need to be preserved, hull does not help much. As a test, we place two objects and use the code, the two join. Of course, in a simplified case, I can cut the object and create a module out of every cut, but is there a way to automize this for, let's say, 100 modules?
module test() {
cube([200,10,2]);
translate([0,12,0])
cube([200,10,2]);
}
//variables for cut points
ca1=8.89;
ca2=8.9;
cb1=9.89;
cb2=9.9;
//variables for equation
a=110;
b=125;
c=250;
//variables for y cut points
yca1=8.89;
yca2=8.9;
ycb1=9.89;
ycb2=9.9;
//variables for y equation
ya=110;
yb=125;
yc=250;
module x2() {
for (z = [1:50])
hull() {
translate([0,0,log(z+a)*b+c])
{
difference() {
test();
translate([z+ca1,10,1]) cube([300,200,200]);
translate([ca2300+z,100,1]) cube([300,200,200]);
}
}
translate([0,0,log(z+a1)*b+c])
{
difference() {
test();
translate([z+cb1,10,1]) cube([300,200,200]);
translate([300+cb2+z,100,1]) cube([300,200,200]);
}
}
}
}
x2();
bump, as it didn't make it to the mailing list.
Admin  email* me if you need anything, or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.
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!


On 20160325 02:41, MichaelAtOz wrote:
> rav0r wrote
>> I am trying to modulate an object by not changing it's suface so I
>> designed a code for it to be sliced and the slices be rearranged after
>> a
>> custom equation. The problem I have is that if the object is not flat
>> and
>> has holes that need to be preserved, hull does not help much. As a
>> test,
>> we place two objects and use the code, the two join. Of course, in a
>> simplified case, I can cut the object and create a module out of every
>> cut, but is there a way to automize this for, let's say, 100 modules?
You could perhaps slice the model by means of many intersection()'s with
a thin+wide cube(), stacked on top of each other. This could be in z,y,z
or some other direction. Then reassemble by modulating the slices as
preferred and scale up the slice thickness slightly. Finally union() the
modulated slices.
This should preserve holes and surface shapes. Not sure if it will work
in practice, but you could try.
Carsten Arnholm
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


Do you mean something like that:
module test2() {
translate([100,0,0])
difference(){
cylinder(r=100,h=10,center=true);
cylinder(r=50,h=12,center=true);
}
}
module slice(x,d) {
intersection(){
children();
translate([x,0,0])
cube([d,1000,1000],center=true);
}
}
function shear_transf(x1,x2,d) = let( r=d/(x2x1) )
[ [1,0,0,0], [0,1,0,0], [r,0,1,r*x1], [0,0,0,1] ];
module shear(x1,x2,d) {
multmatrix(shear_transf(x1,x2,d)) children();
}
function f(x,a,b,c) = a*x*x+b*x+c;
module modulate(a,b,c,x1,x2,d){
for(x=[x1:d:x2]) {
translate([0,0,f(x,a,b,c)])
shear(x,x+d,f(x+d,a,b,c)f(x,a,b,c)) slice(x,d) children();
}
}
modulate(0.01, 1.5, 10, 0, 200, 2) test2();
translate([0,0,200]) test2();


I love it!
Jon
On 3/25/2016 9:38 AM, Ronaldo wrote:
> module test2() {
> translate([100,0,0])
> difference(){
> cylinder(r=100,h=10,center=true);
> cylinder(r=50,h=12,center=true);
> }
> }
>
> module slice(x,d) {
> intersection(){
> children();
> translate([x,0,0])
> cube([d,1000,1000],center=true);
> }
> }
>
> function shear_transf(x1,x2,d) = let( r=d/(x2x1) )
> [ [1,0,0,0], [0,1,0,0], [r,0,1,r*x1], [0,0,0,1] ];
>
> module shear(x1,x2,d) {
> multmatrix(shear_transf(x1,x2,d)) children();
> }
>
> function f(x,a,b,c) = a*x*x+b*x+c;
>
> module modulate(a,b,c,x1,x2,d){
> for(x=[x1:d:x2]) {
> translate([0,0,f(x,a,b,c)])
> shear(x,x+d,f(x+d,a,b,c)f(x,a,b,c)) slice(x,d) children();
> }
> }
>
> modulate(0.01, 1.5, 10, 0, 200, 2) test2();
> translate([0,0,200]) test2();
>
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


@ Ronaldo: Very good example usage of multmatrix. Thx for sharing.


There was a mistake in the definition of module modulate. The correct one would be:
module modulate(a,b,c,x1,x2,dx){
for(x=[x1:dx:x2]) {
translate([0,0,f(x+dx/2,a,b,c)])
shear(x,x+dx,f(x+dx,a,b,c)f(x,a,b,c)) slice(x,dx) children();
}
}


This post was updated on .
It did work, I came up with this idea, but it takes days to render. Will try out Ronaldo's version.


All depends on the complexity of your starting model and the slice width. If you could share your model we could suggest other alternatives. For instance, if your model has only vertical throughout holes, you would get a little time gain doing the differences after modulation. Anyway, please share your final solution. I am interested in it.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


It's a frame with a grid, about 250mm long, 80 mm wide and 5 bars (longtitudinal) plus 3 cross bars. Openscad is the only application that can work without issues in regard to "full" stl's, not only facets.


I would take a very different approach for your problem. I would "modulate" the center lines of each bar, sweep each with the bar section and union everything. A sweep module may be found in:
https://github.com/openscad/listcomprehensiondemosTake the sweeppath.scad as an example. And ask for help if you need.


That is easier said than done, but the frame has an irregular shape. I could, of course use this module http://www.thingiverse.com/thing:210099 for the extrusion but I need all the grid's elements to have a specific bevel and 3D orientation. I guess the whole job is harder than I thought, though, for a core 2 duo cpu. Probably an i7 would do just fine.


Rendering Polygon Mesh using CGAL...
WARNING: CGAL Evaluator: Root node didn't fit into cache
PolySets in cache: 9
PolySet cache size in bytes: 221448
CGAL Polyhedrons in cache: 597
CGAL cache size in bytes: 104854928
Top level object is a 3D object:
Simple: yes
Vertices: 175957
Halfedges: 529502
Edges: 264751
Halffacets: 191240
Facets: 95620
Volumes: 3420
Total rendering time: 20 hours, 48 minutes, 39 seconds
Rendering finished.
In reality, it took 3 times that much as it says.


Well, it is a lot of rendering time indeed for an object so simple. And because of its simplicity, the slicing approach doesn't seem to be the best. Do you need a so fine slicing? You have more than 1000 slices!
What OpenSCAD version are you using? "Let" was not recognized by your version! I am sure you would have a huge benefit from using sweep. But certainly it would not work with older versions like yours. You will need the last official version. Would you share the code of your grid frame?
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


//bevel
use <bevel_extrude.scad>
module grila() {
union() {
//grid
translate ([0,0,0]){
bevel_extrude(height=10,bevel_depth=6,$fn=16)import("rama_pct.dxf");
}
//horizontal
translate ([0,0,0]){
bevel_extrude(height=10,bevel_depth=6,$fn=16)import("rama_oriz_1.dxf");
}
translate ([0,0,0]){
bevel_extrude(height=10,bevel_depth=6,$fn=16)import("rama_oriz_2.dxf");
}
translate ([0,0,0]){
bevel_extrude(height=10,bevel_depth=6,$fn=16)import("rama_oriz_3.dxf");
}
translate ([0,0,0]){
bevel_extrude(height=10,bevel_depth=6,$fn=16)import("rama_oriz_4.dxf");
}
translate ([0,0,0]){
bevel_extrude(height=10,bevel_depth=6,$fn=16)import("rama_oriz_5.dxf");
}
//vertical
translate ([0,0,0]){
linear_extrude(height=3)
import("rama_vert.dxf");
}
}
}
grila();


Thank you for that. I agree that my suggestion of using sweep is hard, if not impossible, to implement if your sections come from dxf files like this one. To adopt sweep you will need the 2D shapes expressed as a list of points and there is no way in the language, and this is an unfortunate missing feature of OpenSCAD, to access the points of dxf files.
If you are able to generate the list of points of your dxf files I am sure you would have a huge time gain by using sweep to get your intent. The chamfer in the bars would not be an obstacle to the sweep approach.

123
