# center of cylinder

18 messages
Open this post in threaded view
|

## center of cylinder

 I use OpenSCAD for 3D as well as 2D designs.   I am making a pattern for drilling holes in wood, once my design is done I think use the projection function so I can print the drill pattern. How would I go about putting cross hairs in the center of the cylinder so that I make sure I am drilling directly in the center of the cylinder?  This particular design do not have to be super accurate but very close would be nice.  It is for a piece of plywood 12" x 13.5" with a bunch 1.5" holes drilled. Would I have to make 2 very thin cubes in the center of the cylinder or is there a better way to do this? -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: center of cylinder

Open this post in threaded view
|

## Re: center of cylinder

 In reply to this post by fractorr One of hundred ways is to draw everything with 2D primitives using 2 or better 4 rects as crosshairs and differences of circles as circle lines. Then switch to top view (Ctrl+4) and save with file/export/image. After that print the image in the desired size. You also can show the axes as cross hairs (Ctrl+2). e.g. \$fn=60; for (r = [10:14])   difference()   {     circle(r);     circle((r-.04 ));   } for(i = [0:90:360])     rotate([0,0,i])  translate([2.8,0,0]) square([5,.1], center = true); -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: center of cylinder

Open this post in threaded view
|

## Re: center of cylinder

 In reply to this post by fractorr I's make my own cylinder module. I'd probably call it hole, just for code clarity. Then, I'd add a parameter crosshairs, and if false, it just does the cylinder as normal, if true, it instead does the crosshairs (and anything else I might want, such as printed dimensions). Then, first call it in the difference() to make the hole, then call it again outside with the same parameters, but with crosshairs=true to draw the crosshair. This kind of stuff is pretty common, and it would be much easier if OpenSCAD handled "negative objects", because then, the hole could be negative and the crosshair positive, so you could add them in one operation. But, it doesn't, so we need a workaround. -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: center of cylinder

Open this post in threaded view
|

## negative objects (was Re: center of cylinder)

 In reply to this post by Troberg On 8/15/2018 10:10 PM, Troberg wrote: ```This kind of stuff is pretty common, and it would be much easier if OpenSCAD handled "negative objects", because then, the hole could be negative and the crosshair positive, so you could add them in one operation. But, it doesn't, so we need a workaround. ``` I think about negative objects occasionally, and when I start to think about them too deeply I realize that I don't know what they would really mean. It seems "obvious" that a 3" sphere unioned with a negative 2" sphere is a hollow sphere.  But then what do you get if you union in a 1" sphere?  Do you get a sphere floating inside a sphere, or does the negativeness of the 2" sphere win and destroy the 1" sphere?  You might think that you could do addition and subtraction, so that a positive object plus a negative object plus a positive object yields a positive object, but that wouldn't be right either - often you'd want to drill a hole through something that is itself a union of several things. Does anybody have a full model for how negative objects would behave? _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: negative objects (was Re: center of cylinder)

 On 16. aug. 2018 18:14, Jordan Brown wrote:  > It seems "obvious" that a 3" sphere unioned with a negative 2"  > sphere is a hollow sphere. Result = S3 + -S2  = S3 - S2 I.e. a "union with a negative" is the same as difference. Negative objects are not required.  > But then what do you get if you union in a 1" sphere?  > Do you get a sphere floating inside a sphere, Sure, just try it: union() {     difference()     {        sphere(30);        sphere(20);     }     sphere(10); } To see the inside of it, cut away an octant difference() {     union()     {        difference()        {           sphere(30);           sphere(20);        }        sphere(10);     }     cube(50); } Standard stuff. Carsten Arnholm _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: center of cylinder

Open this post in threaded view
|

## Re: center of cylinder

 factorr, I'm not particularly qualified to address the overall code, but wanted to point out something that may bite you in the future. module crosshairs() {     for(i = [0:90:360])           rotate([0, 0, i])               translate([0, 0, 75])                 cube([20, 1, 50], center = true); The for loop will generate five features. Starting point of zero is one and the 90° increment to the ending point of 360 is number five. I believe in your specific instance it won't matter, but watch out for zero starting points and desired ending points for these types of loops. You can see that changing the end loop figure to 270 gives the same visual results without the "overlap" of the feature being created. -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: negative objects (was Re: center of cylinder)

 In reply to this post by cacb On 8/16/2018 12:02 PM, Carsten Arnholm wrote: On 16. aug. 2018 18:14, Jordan Brown wrote: > It seems "obvious" that a 3" sphere unioned with a negative 2" > sphere is a hollow sphere. Result = S3 + -S2  = S3 - S2 I.e. a "union with a negative" is the same as difference. Negative objects are not required. When people talk about "negative objects", I think they mean an object that, when *unioned* with another object, cuts into it.  It's like the negative object is made of antimatter, so when you juxtapose it with normal matter the normal matter is annihilated. Consider, for instance, Troberg's "hole with crosshairs".  It's an object, of sorts, with a negative component (the hole) and a positive component (the crosshairs).  If you unioned it with a cube, you'd drill a hole through the cube, except for crosshairs. I'm reminded of portable holes. Without getting into how it would *actually* work (again, remember that my original comment was that I didn't see how it *could* work), you would have something like so: union () {     hole_with_crosshairs();     cube(...); } module hole_with_crosshairs() {     // hole     negative() cylinder(...);     // crosshairs     cube(...);     cube(...); } ... but I don't think there's a definition that will really work in the general case. [ Various combinations involving difference() } Standard stuff. Sure.  But that's not the question. _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: center of cylinder

Open this post in threaded view
|

## Re: center of cylinder

Open this post in threaded view
|

## Re: center of cylinder

 In reply to this post by nophead > When crosshairs is true you could make hole draw the difference between a cylinder and a cross. That way you don't need to call it twice. Of course, why didn't I think of that, it's the neatest solution! -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: negative objects (was Re: center of cylinder)

 In reply to this post by JordanBrown > When people talk about "negative objects", I think they mean an object that, when *unioned* with another object, cuts into it.  It's like the negative object is made of antimatter, so when you juxtapose it with normal matter the normal matter is annihilated. > Consider, for instance, Troberg's "hole with crosshairs".  It's an object, > of sorts, with a negative component (the hole) and a positive component > (the crosshairs).  If you unioned it with a cube, you'd drill a hole > through the cube, except for crosshairs. Yep, pretty much. In this case, there are simple workarounds, but in my constructions, I often make complex parts, with bolts that fit into holes in other complex parts. Sometimes, it's a lot of math to make the holes line up properly with the bolts, so it would be nice if the bolt could "bring its own hole", so to speak. There are probably plenty of other examples, one is mentioned in the tutorial section, about holes in a PCB. -- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|