OpenSCAD User Manual/First Steps/Creating a simple model
// Rim Cover Design in OpenSCAD
// Set the number of facets for smooth circles
$fn = 100;
// Convert inches to millimeters (1 inch = 25.4 mm)
inch = 25.4;
// Dimensions
rim_diameter = 18 * inch; // 18 inches in mm
cover_diameter = rim_diameter + (1 * inch); // Add overlap
thickness = 0.3 * inch; // Thickness of the cover
center_bore_diameter = 70; // Center hub diameter in mm
bolt_circle_diameter = 114.3; // Common 5-lug pattern (4.5 inches in mm)
bolt_hole_diameter = 16.5; // Bolt hole diameter in mm
// Main Rim Cover
module rim_cover() {
difference() {
// Outer disc
cylinder(d = cover_diameter, h = thickness, center = true);
// Center bore hole
translate([0, 0, 0])
cylinder(d = center_bore_diameter, h = thickness + 2, center = true);
// Bolt holes
for (i = [0 : 72 : 288]) {
rotate([0, 0, i])
translate([bolt_circle_diameter / 2, 0, 0])
cylinder(d = bolt_hole_diameter, h = thickness + 2, center = true);
}
}
}
// Decorative Pattern (Optional)
module decorative_pattern() {
// Example: Raised curved blades between bolt holes
for (i = [0 : 72 : 288]) {
rotate([0, 0, i])
translate([bolt_circle_diameter / 2 + 30, 0, thickness / 2])
rotate([90, 0, 0])
cylinder(d1 = 0, d2 = 40, h = 20, center = true);
}
}
// Combine Rim Cover and Decorative Pattern
union() {
rim_cover();
decorative_pattern(); // Comment this line out if you don't want the pattern
}
color("blue") rim_cover();
color("gold") decorative_pattern();
translate([0, 0, thickness + 1])
linear_extrude(height=2)
text("Your Text Here", size=20, halign="center", valign="center");
Usage example 1 - simple cuboid: | |
cube([8,8,8]);
| |
Compiling and rendering our first model
[edit | edit source]The cuboid can now be compiled and rendered by pressing F5 or F6 Function key on your keyboard while the OpenSCAD editor has focus. You should now see your object in the preview window as shown above.
See also
[edit | edit source]Next: Positioning an object