Free Ruby Library to Read & Write AutoCAD DWG Drawings
Open Source Ruby CAD Library that enables Software Developers to Create, Edit, Transform and Manipulate AutoCAD 3D Files. It Allows to Write Cleaner, More Modular and Reusable Code.
What is SolidRuby?
SolidRuby serves as a potent open source Ruby library that links software development with CAD (Computer-Aided Design) modeling. It offers a specialized language (DSL) in Ruby for crafting 3D models, empowering software developers to build applications that smoothly integrate with a range of CAD diagrams. If you aim to develop tools for parametric design, 3D printing procedures, or customized CAD software, SolidRuby offers a sturdy foundation for your projects. Furthermore, you have the option to incorporate the library into your projects to unlock enhanced functionalities such as creating dynamic 3D models, using interactive CAD editing tools, setting up automated design systems, or designing custom 3D printing pipelines.
SolidRuby is developed based on OpenSCAD, a well-known CAD tool that relies on scripts. While OpenSCAD has its scripting language, it benefits from the simplicity and flexibility of Ruby’s syntax for CAD modeling. With SolidRuby, developers can craft structured, reusable, and easy-to-manage code to describe 3D models and make transformations. The tool generates files in OpenSCAD format. You can convert these to STL files for 3D printing or other tasks. The software includes a strong dependency injection system, which helps you handle dependencies among objects smoothly. This feature simplifies testing, upkeep, and scaling of your apps. SolidRuby’s parametric functions are great for tasks needing dynamic model creation. 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