Openscad help please > Making Centering Ring STL files

The Rocketry Forum

Help Support The Rocketry Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Flash

Well-Known Member
Joined
Jan 22, 2009
Messages
639
Reaction score
48
I downloaded OpenSCUD, no problems. I'm trying to design centering rings and save them into STL format.
Here is my problem, when I size you a new centering ring, lets say 34mm x 24mm x 2mm and save it as a STL file and open it in cura, the outside, and most likely the inside measurements come out double > 68mm.
What am I doing wrong? I'm afraid that if I reduce it, I'll loose the inside 24mm measurement.
Should I Simply put 17 x 12 x 2 mm to get what I'm looking for?
Thank you!
 
change the r to d in your cylinder....
Post your scad file. should only be about 3 lines for what you're doing. Copy and paste this into a new SCAD file. Ideally install the developer version of SCAD. This allows paramater variables to be adjustable within the limits set. First line min 10:increment 0.1:max 100

OD=34;//[10:0.1:100]
ID=24;//[10:0.1:100]
Thk=2;//[0.1:0.1:50]
difference(){
cylinder(d=OD,h=Thk,center=true);
cylinder(d=ID,h=Thk,center=true); }
 
Last edited:
Thank you!
I had nothing else to do.... :) Good luck in your 3D printing journey. Feel free to PM me if you need any further assistance. Throw in a default facet number if you want to smooth it out. Bigger is smoother and takes longer to render. Not an issue for this simple object but worth remembering for more complex shapes.

$fn=80;
OD=34;//[10:0.1:100]
ID=24;//[10:0.1:100]
Thk=2;//[0.1:0.1:50]
difference(){
cylinder(d=OD,h=Thk,center=true);
cylinder(d=ID,h=Thk,center=true); }
 
Last edited:
Sorry for the delay, that worked perfect! Thank you very much!
 
FWIW - you can design parts that integrate the centering ring, thrust ring / engine block, and motor retainer if you want to experiment (once you are 3D printing parts the additional weight may not be significant and you can save assembly time / complexity... Be sure to print with ABS or something that is energy resistant.

1628786922321.png
 
Ideally install the developer version of SCAD. This allows paramater variables to be adjustable within the limits set. First line min 10:increment 0.1:max 100

OD=34;//[10:0.1:100]...
I'm a novice user, and rusty. That is to say, I've done a couple of rather simple things, and those were five to seven years ago. So...

I don't get what you're doing here. If you've set OD to 34 then what is being or may be adjusted in the specified range? Sure, you might want anything from 10 to 100 in 0.1 increments, but you've already picked 34. And if later you want 57 (or whatever) instead, you'd change the line to OD=57; so what is the rest doing for you?
 
Just FYI, the way OpenSCAD creates circles generally results in slightly undersized openings. You can write a simple function or module to correct this. I printed several sizes on my printer and measured them and came up with a 'fudge factor' for openings that works pretty well. Also, read up on the built-in variables that affect rendering resolution:

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#.24fa.2C_.24fs_and_.24fn
I didn't come up with the module below, it came from another user here on TRF, but unfortunately I can't find the original link. Instead of a fixed 'fudge factor', it modifies it based on the fn value you use to create the circle. I incorporated it into the code from above: (you can use radius and r= if that works better for you):

Code:
OD=34;//[10:0.1:100]
ID=24;//[10:0.1:100]
Thickness=2;//[0.1:0.1:50]
Fragments = 48;//[12:1:100]
clean_render = 1.01;// used on interior cylinder so it renders cleanly in draft mode

module cylinder_adjusted(diameter,height,fn){
   fudge = 1/cos(180/fn);
   cylinder(h=height,d=diameter*fudge,,center=true,$fn=fn);}

difference(){
cylinder_adjusted(OD,Thickness,Fragments);
cylinder_adjusted(ID,Thickness*clean_render,Fragments); }


I use the clean_render variable to increase the height of the inner cylinder to get nicer looking renders in draft mode, I usually just leave it at 1.01. If you play with the Fragments variable you can easily see how increasing the number of fragments creates more accurate cylinders but at the cost of slower rendering times.

I hope this helps,


Tony
 
I don't get what you're doing here. If you've set OD to 34 then what is being or may be adjusted in the specified range? Sure, you might want anything from 10 to 100 in 0.1 increments, but you've already picked 34. And if later you want 57 (or whatever) instead, you'd change the line to OD=57; so what is the rest doing for you?

The ranges are in comments that get picked up by the Customizer (in the OpenSCAD viewer or on Thingiverse) to present a simple UI for changing parameters without editing the code.

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Customizer#Customizer
screenshot_20210910-133817.png
 
Thanks. I'll have to read that. What I did back then was just fixed code for the particular thing I wanted, so there'd have been no point at that time.
Just FYI, the way OpenSCAD creates circles generally results in slightly undersized openings. You can write a simple function or module to correct this. I printed several sizes on my printer and measured them and came up with a 'fudge factor' for openings that works pretty well. Also, read up on the built-in variables that affect rendering resolution:

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#.24fa.2C_.24fs_and_.24fn
I didn't come up with the module below, it came from another user here on TRF, but unfortunately I can't find the original link. Instead of a fixed 'fudge factor', it modifies it based on the fn value you use to create the circle. I incorporated it into the code from above: (you can use radius and r= if that works better for you):

Code:
OD=34;//[10:0.1:100]
ID=24;//[10:0.1:100]
Thickness=2;//[0.1:0.1:50]
Fragments = 48;//[12:1:100]
clean_render = 1.01;// used on interior cylinder so it renders cleanly in draft mode

module cylinder_adjusted(diameter,height,fn){
   fudge = 1/cos(180/fn);
   cylinder(h=height,d=diameter*fudge,,center=true,$fn=fn);}

difference(){
cylinder_adjusted(OD,Thickness,Fragments);
cylinder_adjusted(ID,Thickness*clean_render,Fragments); }
Be careful with that. The way OpenSCAD renders circles is with a polygon inscribed on the ideal, desired circle, which does indeed make the shape a bit undersized, whether it's the ID (opening) or the OD. What this fudge does is make a polygon that's circumscribed on the desired circle, so it's a little oversized. Personally, I'd use cylinder_adjusted on the OD of a centering ring, so it can be sanded down to fit the body tube, but the standard cylinder for the ID so the opening can be sanded until it fits onto the MMT. (Yeah, I'm a rusty novice at OpenSCAD, but I still know my trig.)
 
Thanks. I'll have to read that. What I did back then was just fixed code for the particular thing I wanted, so there'd have been no point at that time.

Be careful with that. The way OpenSCAD renders circles is with a polygon inscribed on the ideal, desired circle, which does indeed make the shape a bit undersized, whether it's the ID (opening) or the OD. What this fudge does is make a polygon that's circumscribed on the desired circle, so it's a little oversized. Personally, I'd use cylinder_adjusted on the OD of a centering ring, so it can be sanded down to fit the body tube, but the standard cylinder for the ID so the opening can be sanded until it fits onto the MMT. (Yeah, I'm a rusty novice at OpenSCAD, but I still know my trig.)
Not in my experience. I use PETG for almost all of my printing, and I have found there is a small amount of shrinkage/undersize in all the openings I've printed. If you do the math, the amount of oversize created by the fudge factor is typically less than 1%, which still may not be enough for some uses. I've printed a lot of of openings created with OpenSCAD and very rarely are they oversized if I used the above technique. I would rather not spend a lot of time sanding so getting a good fit right out of the printer is important to me.

You mention you're rusty with OpenSCAD, so you may not have a lot of experience with using it to create 3D parts with openings. In my personal experience with the many parts I have created with OpenSCAD, the above technique works well - otherwise I would not have shared it.


Tony
 
Last edited:
Circles are polygons in any cad program. This is demonstrated if you alter the number of faces. If you make $fn=6 you get a hex drawn inside the diameter you specify. Great if you want a nut recess. The material you print with will have an effect ABS has a shrinkage of about 3% PLA 1%
This is why you have to calibrate your printer for the material you are printing. Also I print 0.45 walls out a 0.4 nozzle for ABS this squishes the new layer into the previous and really improves inter layer bonding for ABS. But gives a rougher surface finish which will make a bore slightly smaller.
When you’re designing and printing 3D parts you are going to have to compensate for the design process and the printing process. In general terms if you want something to go through the bore you printed you’re going to have to either file or sand it later or print a slightly larger hole. If you want the OD to fit in a bore you might have to make it slightly under.
In engineering drawings if you had 2 components that mated you would tolerance the dimensions for a clearance or interference fit depending on what you wanted. In practical terms I don’t see any difference here. If you require an engineering fit in 3D printing you have to understand the process and what you’ll get out from it.
With the developer version of SCAD you can create parametric versions of a design. The fin design program is fantastic. I’ve created Nike fins, Honest John fins, swept back/ forward in the same session just by playing with the sliders. If you break it and create something that just wouldn’t print you can just put the sliders back a bit rather than having to go back into the programming area and change the actual size. There is also a Tab at the top of that section to allow you to save all the settings and name them. Honest John fin can. For example.
For a simple centering ring it’s not a massive advantage. But you could create a BT60-BT50 file as a setting or 3inch post pack-29mm or all your favourites. Change the dimensions to whatever works on your prints.
We were all novices when we started. Happy to give you any assistance you require. Just ask. Regards
Norm
 
Thanks for the pointers. When it comes to implementing geometry in CAD, again, I'm a novice. When it comes to 3D printing, I'm nothing at all. I can only talk about the geometry that's in the design file, which is all I meant to talk about in the first place. But I inadvertently strayed into the CAM part of CAD/CAM by talking about loose or tight fits.
 
I'm a novice user, and rusty. That is to say, I've done a couple of rather simple things, and those were five to seven years ago. So...

I don't get what you're doing here. If you've set OD to 34 then what is being or may be adjusted in the specified range? Sure, you might want anything from 10 to 100 in 0.1 increments, but you've already picked 34. And if later you want 57 (or whatever) instead, you'd change the line to OD=57; so what is the rest doing for you?
When you create a parametric file it's useful if you set the initial values to something that works and looks pretty. In this case I set the defaults for the centering ring to what the requestor asked for. That was so they did not NEED to install the developer version to get a ring that worked.
Here's my SCAD nosecone design with starting presets enabled. To save a new preset for the current set of values you just click the + button next to save preset, name it and save preset. Job done. Also you can see that it's not required to have that BLACK background in the developer version. You can choose the classic colours.
1631308908209.png
Here it is with all the settings at the bottom of the range. You probably wouldn't use it if that was what was presented as a startup screen.
1631308771998.png
 

Attachments

  • Nosecone Power parametric complete.scad
    3.5 KB · Views: 5
When you create a parametric file it's useful if you set the initial values to something that works and looks pretty. In this case I set the defaults for the centering ring to what the requestor asked for. That was so they did not NEED to install the developer version to get a ring that worked.
Here's my SCAD nosecone design with starting presets enabled. To save a new preset for the current set of values you just click the + button next to save preset, name it and save preset. Job done. Also you can see that it's not required to have that BLACK background in the developer version. You can choose the classic colours.....
Thanks for posting your file, it's always good to see how other users do things. When you say the developer version, I'm not sure what you mean? You used to need the development snapshot to get the Customizer window but it's now a standard part of OpenSCAD. (I think the customizer was made standard back in 2019.) I opened your file in the standard version of OpenSCAD and the latest development snapshot and they were the same, other than the preferences for the text editor. For the standard version I'm using 2021.01 on both Mac and Windows, and for the development snapshot I tried version 2021.09.10 on the Mac.

If that's not it, can you explain what you mean by the developer version? I use OpenSCAD a lot and just want to make sure I'm not missing anything.

Thanks,


Tony
 
Didn't know it had been added to the STD version. I've been going to check if there was a newer DEVELOPER version. Ha Ha. Gotta laugh.
I think you're over complicating it by compensating in the design program for the polygon size of the circle but it does keep the number of facets down.
I've exceeded SCADs limit once. So it does happen. If I have a critical bore it's easy to just print a small sample and adjust the size in the final print for that. There are multiple other factors anyway so a real sample gives a realistic result for the corrections needed for your entire system. Cad polygons, slicer polygons, stepper motor driving your printer and printer mechanical factors. I always think of 3D printing as every print is completely successful, apart from the ones that just had one paper cut too many. Death by a thousand paper cuts. When the whole process works, it's magical.
Norm
 
Didn't know it had been added to the STD version. I've been going to check if there was a newer DEVELOPER version. Ha Ha. Gotta laugh.
I think you're over complicating it by compensating in the design program for the polygon size of the circle but it does keep the number of facets down.
I've exceeded SCADs limit once. So it does happen. If I have a critical bore it's easy to just print a small sample and adjust the size in the final print for that. There are multiple other factors anyway so a real sample gives a realistic result for the corrections needed for your entire system. Cad polygons, slicer polygons, stepper motor driving your printer and printer mechanical factors. I always think of 3D printing as every print is completely successful, apart from the ones that just had one paper cut too many. Death by a thousand paper cuts. When the whole process works, it's magical.
Norm
I agree completely that printing a sample is really the only way to get it dialed in. I use vase mode a lot for that which works well for most uses.

What I find interesting about using OpenSCAD is I’m not good with math yet I find myself having to use all kinds of formulas to do what I want. But I love the ability to put everything into variables and then use the Customizer window to play around with the design. Your nose cone generator is a perfect example.

Tony
 
Suggestion: Use Tinkercad. It is easy to use, has a relatively short learning curve. Centering rings are super easy to make. Then you can scale them easily. Dimensions work out just fine. Sometimes you need to tweak the design a little bit due to possibility of elephant foot, or horizontal expansion issues. I generally set the OD of the part to 0.010" smaller than the tube it fits into and the ID of the ring 0.010" larger than the tube it fits over. make the first one only 1mm, or .062" thick first to test fit, then adjust accordingly till fit is smooth. Then your file is good to go forever!

Tutorial:
 
Thanks for the pointers. When it comes to implementing geometry in CAD, again, I'm a novice. When it comes to 3D printing, I'm nothing at all. I can only talk about the geometry that's in the design file, which is all I meant to talk about in the first place. But I inadvertently strayed into the CAM part of CAD/CAM by talking about loose or tight fits.
Most of the normal maths functions are available in SCAD, but they might be named something slightly different. For example square root is available as SQRT. You can also do POW(value,0.5) cube root would be POW(value,0.333) POW(9,0.333) would deliver a result of 3. This was used in the nosecone design and as I didn't limit the value of the power led me to finding a power of 2+ producing a Thunderbird1 type nosecone with the Parabolic formula and an Honest John nosecone with the Haack at 2.0 If the K factor( as it's labeled in OpenRocket) were unlocked, you'd be able to produce more interesting nosecones. Would they sim ok? I don't know. Neil W may know. But now you can print them...... AND thanks to K'Tesh for the assist in creating my needlepoint nosecone. He truly is an OpenRocket NINJA.

In answer to the Why not use Tinkercad? It's a good program, but in general I'm not in favour of SAAS( Software as a Service where you never actually hold the program on your computer). The rules for their use can change at the whim of the supplier. Like the free hobbyist licences for Fusion 360. Oooh that's the same supplier. They'd never do that with Tinkercad....... ( There's a whole bunch of people who've bought CCTV systems using SAAS who later find they are BRICKED when the company changes hands/ the rates change.) So I like it, but honestly I'm not prepared to put the effort into learning it, even if it is easy. Also I found SCAD suited my brain better.
Norm
 
Last edited:
I naturally think in math and I have a good deal of (admittedly amateur) programming experience. I also have truly crappy hand-eye coordination. So CAD with a mouse is a nightmare for me, and CAD by programming shapes is really natural. The discovery of OpenSCAD was a revelation. Since posting in this thread I've been turned back on and on Saturday I designed a nose shape (really can't call it a nose cone) for two side-by-side tubes, where two cones are skewed toward each other so that their circular cross sections coincide part way up and there's a straight cone from there on up. Sure, I had to Google how to do the skewing (why isn't there a skew() transformation? I guess I'll write it.) but I found it (multmatrix) easily and then the design was simple. I plan to play with ratio of pre-merge to post-merge height, and maybe do that with customizer (which will be new to me) but to get something working in a couple of hours is a heck of a lot better than I could have done with anything else.
 
I've transitioned from using OpenSCAD only rarely, for designs that had to be parameterized, to using OpenSCAD as my only 3D design tool. I use it for everything now.
 
Centering ring program for SCAD. Change the .txt to .json This contains all the presets for basic starting points.

There is no explanation text. feel free to add it. W=width H=height T=thickness
Enjoy
Norm

1642665626888.png
 

Attachments

  • ParametricCenteringRing.scad
    1.2 KB · Views: 6
  • ParametricCenteringRing.txt
    7.7 KB · Views: 6
I naturally think in math and I have a good deal of (admittedly amateur) programming experience. I also have truly crappy hand-eye coordination. So CAD with a mouse is a nightmare for me, and CAD by programming shapes is really natural. The discovery of OpenSCAD was a revelation. Since posting in this thread I've been turned back on and on Saturday I designed a nose shape (really can't call it a nose cone) for two side-by-side tubes, where two cones are skewed toward each other so that their circular cross sections coincide part way up and there's a straight cone from there on up. Sure, I had to Google how to do the skewing (why isn't there a skew() transformation? I guess I'll write it.) but I found it (multmatrix) easily and then the design was simple. I plan to play with ratio of pre-merge to post-merge height, and maybe do that with customizer (which will be new to me) but to get something working in a couple of hours is a heck of a lot better than I could have done with anything else.
I'd use hull() for this. Create a sphere for top with xyz co-ords and extrude circle minimum thickness at base locn...
1642667080775.png
 

Attachments

  • nosecone offset.scad
    186 bytes · Views: 4
That's not quite the shape. You're right side seems to be vertical, so that the two cones would lie side-by-side all the way up. they could be printed and installed as two separate pieces.

Mine has the right side sloped to the left, and the left side sloped to the left more. The two skewed cones intersect (so it's really a single piece) getting deeper into one another as they go up. This stops at the point that the two skewed cones are exactly coincident, and then there is a regular, non-skewed cone on top of that, continuing the slop of the outer edges (the left edge above).

(I can't post a picture at the moment. StarLink is supposed to be coming to my house some time next month.)
 
That's not quite the shape. You're right side seems to be vertical, so that the two cones would lie side-by-side all the way up. they could be printed and installed as two separate pieces.

Mine has the right side sloped to the left, and the left side sloped to the left more. The two skewed cones intersect (so it's really a single piece) getting deeper into one another as they go up. This stops at the point that the two skewed cones are exactly coincident, and then there is a regular, non-skewed cone on top of that, continuing the slop of the outer edges (the left edge above).

(I can't post a picture at the moment. StarLink is supposed to be coming to my house some time next month.)

Try this. I think this does what you said (and a bit extra ) :) You could easily add in tube mating points BotD-2*Wall Over to you. Show us your math.
Norm


1642715999898.png
1642716180015.png
 

Attachments

  • nosecone offset2.scad
    1.4 KB · Views: 3
  • nosecone offset2.txt
    7.6 KB · Views: 3
Centering ring program for SCAD. Change the .txt to .json This contains all the presets for basic starting points.

There is no explanation text. feel free to add it. W=width H=height T=thickness
Enjoy
Norm
I've been using OpenSCAD for a while and find I learn best by looking at new code. I used to teach programming so I still write very verbose code with tons of comments, etc., so your code looked a little terse. But it was very informative in how you put it together - thanks for posting it. I tend to use cylinders and cubes, which I really need to quit doing - they really slow things down during renders. I liked the way you used extrude for everything, much faster.


Tony
 
Last edited:
Just FYI, the way OpenSCAD creates circles generally results in slightly undersized openings. You can write a simple function or module to correct this. I printed several sizes on my printer and measured them and came up with a 'fudge factor' for openings that works pretty well. Also, read up on the built-in variables that affect rendering resolution:

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#.24fa.2C_.24fs_and_.24fn
I didn't come up with the module below, it came from another user here on TRF, but unfortunately I can't find the original link. Instead of a fixed 'fudge factor', it modifies it based on the fn value you use to create the circle. I incorporated it into the code from above: (you can use radius and r= if that works better for you):

Code:
OD=34;//[10:0.1:100]
ID=24;//[10:0.1:100]
Thickness=2;//[0.1:0.1:50]
Fragments = 48;//[12:1:100]
clean_render = 1.01;// used on interior cylinder so it renders cleanly in draft mode

module cylinder_adjusted(diameter,height,fn){
   fudge = 1/cos(180/fn);
   cylinder(h=height,d=diameter*fudge,,center=true,$fn=fn);}

difference(){
cylinder_adjusted(OD,Thickness,Fragments);
cylinder_adjusted(ID,Thickness*clean_render,Fragments); }


I use the clean_render variable to increase the height of the inner cylinder to get nicer looking renders in draft mode, I usually just leave it at 1.01. If you play with the Fragments variable you can easily see how increasing the number of fragments creates more accurate cylinders but at the cost of slower rendering times.

I hope this helps,


Tony

1642728599938.png
This is Exactly the same definition of the cylinder just an increased number of facets (faces) on the bottom.
All CAD programs create circles as polygons so cylinder(h=2,d=10,$fn=6,center=true);
is a 2mm high hex nut, 1mm above 0 and 1mm below 0 on z axis, 10mm in daimeter. The corners are at the diameter specified and then it draws a straight line between those corners. In this case 6 of them. If this were a hole it would be undersize. You can use this to your advantage to make a nut recess. You'd need to calculate the correct diameter to give you the right AF (across Flats of the nut) size. But generally if you are going to fit something into the hole you're printing, just increase the $fn to 120 for biggish holes or 72 for smaller. You can do this just at the critical areas or the whole object. Also holes generally print slightly undersize due to the fact you're squishing out hot plastic. Even at high resolution. You should always bear that in mind if any bore is a critical diameter. Or make sure you can ream it with a drill bit or even a proper reamer.
Hope this helps you get a better understanding of how these things work. Also remember if you are printing both mating parts, the undersized bore will be partly compensated by the undersize shaft but you should still consider the clearance required if you need them to rotate together.
Norm
 
Last edited:
Back
Top