Free Ruby Library to Read & Write AutoCAD DWG Drawings
Open Source Ruby CAD Library that enables Software Developers to Create, Edit and Manipulate AutoCAD 3D Files. It Allows to Write Cleaner, More Modular and Reusable Code.
What is SolidRuby?
SolidRuby is a very powerful open source Ruby library that bridges the gap between software development and CAD (Computer-Aided Design) modeling. By providing a Ruby-based domain-specific language (DSL) for creating 3D models, it enables software developers to create applications that work seamlessly with various types of CAD diagrams. If you’re willing to create tools for parametric design, 3D printing processes, or personalized CAD programs, SolidRuby provides a robust base for your work. Moreover, developers can integrate the library to enables advanced features like dynamic 3D model generation, interactive CAD editing tools, automated design systems, custom 3D printing pipelines and so on.
SolidRuby is built on OpenSCAD, a popular scripting-based CAD tool. While OpenSCAD uses its own scripting language, it brings the power of Ruby's syntax to CAD modeling. By using SolidRuby, software developers can write modular, reusable, and maintainable code to define 3D models and transformations. It outputs files in OpenSCAD format, which can be converted to STL files for 3D printing or further processing. The library provides a robust dependency injection system that allows users to easily manage dependencies between objects. This makes it easier to test, maintain, and scale your applications. SolidRuby’s parametric capabilities make it ideal for applications that require dynamic model generation. With its expressive Ruby DSL and handy features like parametric modeling, boolean operations, and smooth OpenSCAD integration, this tool is pretty versatile and can be useful for various tasks.
Getting Started with SolidRuby
The recommend way to install SolidRuby is using GitHub. To work with. Run the following command to add the Aspose.CAD Cloud SDK for Ruby to your project.
Install SolidRuby via GitHub
git clone https://github.com/MC-Squared/SolidRuby.git
You can also install it manually; download the latest release files directly from GitHub repository.
Dynamic 3D Model Generation via Ruby
The open source SolidRuby library enables the creation of parametric models that can adapt dynamically based on user inputs or application logic. Ruby Developers can build applications where users specify dimensions, materials, or other parameters, and the app generates corresponding CAD files in real-time inside Ruby applications. The following example demonstrates how an e-commerce platform selling customizable boxes can use SolidRuby to generate designs dynamically using Ruby code.
How to Generate a Hollow Box with Adjustable Dimensions inside Ruby Apps?
require 'solidruby'
def generate_box(length, width, height, thickness)
difference do
cube([length, width, height])
translate([thickness, thickness, thickness]) do
cube([length - 2 * thickness, width - 2 * thickness, height - 2 * thickness])
end
end
end
box_model = generate_box(30, 20, 10, 2)
File.write("box_model.scad", box_model.to_s)
Custom 3D Printing Pipelines
The SolidRuby library can be a core part of a 3D printing workflow, where it generates models based on specific requirements. Software Developers can integrate it into pipelines for preparing, optimizing, and exporting CAD files. The following example demonstrates how developers can make sure that models are aligned or scaled for specific printers before exporting them.
How to Optimize a Model for Printing inside Ruby Apps?
require 'solidruby'
# Define the model
model = union do
cube([20, 20, 20])
translate([10, 10, 10]) { sphere(15) }
end
# Apply a small transformation for printer alignment
optimized_model = translate([0, 0, 2]) { model }
File.write("optimized_model.scad", optimized_model.to_s)
3D Diagram Transformations via Ruby
The open source SolidRuby library makes it easy for software developers to transform 3D diagrams with just a couple of lines of code inside Ruby applications. It supports transformations like translations, rotations, and scaling, enabling precise placement and orientation of models. The following example shows how software developers can programmatically apply transformation to diagrams using Ruby commands.
How to Apply Transformations to 3D Diagrams inside Ruby Apps?
translate([10, 0, 0]) do
sphere(5)
end
rotate([0, 0, 45]) do
cube([10, 10, 5])
end