[OpenSCAD] What's the best way to accomplish splitting these elements?

guaranteed_interwoven kerryhall at gmail.com
Mon Jul 8 05:01:31 EDT 2019


Never mind, I think I have it solved:

$fn = 20;
delta = 0.5;

module gen_node(coords, d, h)
{
  translate(coords)
  cylinder(d1=d, d2=0, h=h);
}     

data = [
  [[4, 5, 0], 10, 10],
  [[0, 0, 0], 10, 20],
  [[-5, 3, 0], 15, 10],
  [[-2, 6, 0], 15, 7],
  [[2, 16, 0], 20, 20],
];

module embedded(target)
{
  intersection() 
  {
    gen_node(data[target][0], data[target][1], data[target][2]);
    linear_extrude(height=1000)
    projection()
    {
      difference() 
      {
        gen_node(data[target][0], data[target][1], data[target][2]);
        for(i=[0:len(data)])
        {
          if(i != target)
          {
            gen_node(data[i][0], data[i][1] + delta, data[i][2]);
          }
        }
      }
    }
  }
}



for(i = [0:len(data)])
{
  embedded(i);
}

Having to embed the module call in the actual operation feels wrong to me,
but I don't think it's possible any other way.



--
Sent from: http://forum.openscad.org/



More information about the Discuss mailing list