-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Functions for creating and accessing object-like lists in OpenSCAD
This library was made to address a set number of issues within OpenSCAD:
-
passing around collections of arguments to other modules and functions. As it turns out, some models I'm working with really like to build around other models: a wheel that has an axle will want to know how big an opening to carve for that axle; rather than extract the value and provide it to that wheel module, just give the wheel module the axle object and let it figure out what it needs.
openscad_objects
lets you group common sets of variables together into an easy-to-reference and easy-to-pass-as-an-argument set of data. -
validating data types for use. Because after the first time I referenced a string value thinking it was an integer, I felt there was enough ambiguity to reliably avoid.
openscad_objects
provides functionality to compare data values with data types when storing them together into an object, so that you know you're not accidentally storing a string when you need an integer. - making spec'ing arguments for modules easier. I stopped wanting to care about endless module arguments about the time I got to 4, and really annoyed after about 6. Passing arguments into modules via a list made a lot of sense, especially when the models were getting reused again and again. By collapsing a common, related group of variables into a single grouped object, writing modules that needed all of those variables becomes easier.
- making ordering of arguments a non-issue. honestly once you get to about 5 arguments to a module, ordering is a pain. OpenSCAD has named arguments you can specify in any order, but again, if you're looking at lots and lots of arguments to a module, that's still a lot of typing. Setting the arguments that describe a particular shape once, and then reusing those arguments, is a game-saver.
-
providing default values when none are set. When you've got a wide variety of arguments grouped together for model reuse, you sometimes (often?) get an attribute that changes occasionally, but not always.
openscad_objects
provides a default value facility for attributes within an object, giving you the flexibility when you need it, but reducing repetitive value declaration when you don't.
See HOWTO for a quick, high-level guide on implementing Objects into your OpenSCAD module
All of the object functions are documented within objects.scad, with indexing at AlphaIndex & TOC.
As limitations are documented, you'll find them under Caveats & Limitations.
- Download the most recent release of
openscad_objects
from https://github.com/jon-gilbert/openscad_objects/releases/latest - unpack the zipfile or tarball. Inside will be a directory, named
openscad_objects-0.8
(where0.8
is the version of the release). Extract that folder to your OpenSCAD library directory - Rename that release directory from
openscad_objects-0.8
to justopenscad_objects
You'll need the BOSL2 framework to get this working; see https://github.com/BelfrySCAD/BOSL2/ for instructions on how to download and incorporate it.
A lot of this project might be generously considered "works for me", and I'm entirely not sure what'll happen when you use it for you. That's ok! If something doesn't seem to work right, a GitHub issue is perhaps the best way to let me know.
This library is copyright 2022-2024 Jonathan Gilbert jong@jong.org, and released for use under the MIT License.