3

I'm trying regularly to join the different points to draw the straight line in OpenScad. But I could'nt able to find any way to draw the line. But I can able to draw the definite shapes like cubes,spheres,cylinders,etc... So please help me by directing to get into the correct program coding to draw the straight lines by joining the different points.

16807
  • 1,418
  • 2
  • 18
  • 32
  • Welcome to SO. Please have a look at [the tour](http://stackoverflow.com/tour). You may also want to check [How to ask a good question](http://stackoverflow.com/help/how-to-ask), and how to create a [Minimal, Complete and Verifiable example](http://stackoverflow.com/help/mcve). Post the code you have tried and the errors you have received. Be as specific as possible as it will lead to better answers. You can use this [question checklist](http://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist) in order to make sure your question is not missing anything important. – José Luis Mar 28 '18 at 11:36

1 Answers1

8

OpenSCAD currently doesn't have a line primitive; all primitives have to be closed volumes or closed polygons. You can simulate a "line" in space by using hull(), and even package that as a module:

module line(start, end, thickness = 1) {
    hull() {
        translate(start) sphere(thickness);
        translate(end) sphere(thickness);
    }
}

line([0,0,0], [5,23,42]);
kintel
  • 425
  • 3
  • 4
  • 2
    Or the better approach from the manual to draw a cylinder between two points: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks#Drawing_%22lines%22_in_OpenSCAD – Goswin von Brederlow Jun 19 '18 at 14:44
  • While drawing a cylinder is okay for a 3d shape, for a 2D one, you can draw a "square" between two points, by giving a vector for its size. – jpaugh Mar 25 '21 at 03:06