By Bob

I was working on a way to convert parameter values into text and decided to make a protractor just for fun, there is a bunch of work left to do but after just a few minutes I had it working, eventually I will be able to calculate values for any shape and use the formulas in other modules.

here is the unfinished code:

``````
/*[Protractor]*/
Show_Protractor = true;
Protractor_diameter = 10;//[.1:.1:200]
Rotate_Protractor_X = 0; // [0:.01:360]
Rotate_angle = 0; // [-360:.01:360]
Rotate_Protractor_Z = 0; // [0:.01:360]
Move_Protractor_X = 0; // [-400:.01:400]
Move_Protractor_Y = 0; // [-400:.01:400]
Move_Protractor_Z = 0; // [-400:.01:400]

Degrees = Rotate_angle;
length = len(str(Degrees));
Arc = str(Arc_length);

module Protractor(){
if(Show_Protractor){
rotate([Rotate_Protractor_X,Rotate_angle,Rotate_Protractor_Z])
translate([Move_Protractor_X,Move_Protractor_Y,Move_Protractor_Z])
rotate([90,0,0])
cube([.1,Protractor_diameter,.1],center = true);

difference(){
rotate([Rotate_Protractor_X,Rotate_angle,Rotate_Protractor_Z])
translate([Move_Protractor_X,Move_Protractor_Y,Move_Protractor_Z])
rotate([90,0,0])
circle(Protractor_diameter/2,\$fn=200);
rotate([Rotate_Protractor_X,Rotate_angle,Rotate_Protractor_Z])
translate([Move_Protractor_X,Move_Protractor_Y,Move_Protractor_Z])
rotate([90,0,0])
circle((Protractor_diameter-.1)/2,\$fn=200);
}

rotate([Rotate_Protractor_X,Rotate_angle,Rotate_Protractor_Z])
translate([Move_Protractor_X,Move_Protractor_Y,Move_Protractor_Z])
rotate([90,0,0])
translate([-length/2+1,Protractor_diameter/2+.5,0])
color("Black")
linear_extrude(.1)
text(str(Degrees),.75);
rotate([Rotate_Protractor_X,0,Rotate_Protractor_Z])
translate([Move_Protractor_X,Move_Protractor_Y,Move_Protractor_Z])
rotate([90,0,0])
translate([Protractor_diameter/2+2,0,0])
color("Black")
linear_extrude(.1)
text("d=",.5);
rotate([Rotate_Protractor_X,0,Rotate_Protractor_Z])
translate([Move_Protractor_X,Move_Protractor_Y,Move_Protractor_Z])
rotate([90,0,0])
translate([Protractor_diameter/2+3,0,0])
color("Black")
linear_extrude(.1)
text(str(Protractor_diameter),.5);
rotate([Rotate_Protractor_X,0,Rotate_Protractor_Z])
translate([Move_Protractor_X,Move_Protractor_Y,Move_Protractor_Z])
rotate([90,0,0])
translate([Protractor_diameter/2+3,-.75,0])
color("Black")
linear_extrude(.1)
text(str(Protractor_diameter/2),.5);
rotate([Rotate_Protractor_X,0,Rotate_Protractor_Z])
translate([Move_Protractor_X,Move_Protractor_Y,Move_Protractor_Z])
rotate([90,0,0])
translate([Protractor_diameter/2+2.1,-.75,0])
color("Black")
linear_extrude(.1)
text("r=",.5);
rotate([Rotate_Protractor_X,0,Rotate_Protractor_Z])
translate([Move_Protractor_X,Move_Protractor_Y,Move_Protractor_Z])
rotate([90,0,0])
translate([Protractor_diameter/2+2.1,-1.5,0])
color("Black")
linear_extrude(.1)
text("Arc length=",.5);
rotate([Rotate_Protractor_X,0,Rotate_Protractor_Z])
translate([Move_Protractor_X,Move_Protractor_Y,Move_Protractor_Z])
rotate([90,0,0])
translate([Protractor_diameter/2+5.75,-1.5,0])
color("Black")
linear_extrude(.1)
text(str(Arc_length),.5);
rotate([Rotate_Protractor_X,0,Rotate_Protractor_Z])
translate([Move_Protractor_X,Move_Protractor_Y,  Move_Protractor_Z])
rotate([90,0,0])
translate([Protractor_diameter/2+2.1,-2.2,0])
color("Black")
linear_extrude(.1)
text("Area=",.5);
rotate([Rotate_Protractor_X,0,       Rotate_Protractor_Z])
translate([Move_Protractor_X,Move_Protractor_Y,Move_Protractor_Z])
rotate([90,0,0])
translate([Protractor_diameter/2+4,-2.2,0])
color("Black")
linear_extrude(.1)
text(str(Area),.5);
}}
//

echo(Area);

Protractor();``````

Now with the basics laid out it will be pretty easy to adapt the code for a cylinder, sphere or cube and add volume or any other value, I will also clean the code up a bit since i have quite a few redundant lines that can be consolidated.

Follow