-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intended usage as library #157
Comments
I saw your gridfinity rugged box and am impressed. I will give that a go when I'm done with my backlog of creating bins.
|
In my work on the BOSL2 library we have functions that are designated as the API and we have "hidden" functions with are prefixed by '_' and not intended for direct user access. They aren't hidden by the language, but they are designed as hidden and not documented. Functions the users are supposed to use are documented. If you really want to hide stuff it's possible by "use"ing the stuff you want hidden from a separate file, but we found "use" to have serious performance issues so we use "include" instead, despite the namespace clutter that results. There is a place for $ variables, but I don't think "general parameter" is that place. Interesting things can be achieved by using them to pass information between modules, but when something is a direct parameter, it should just be an argument to the function or module. The role of $ variables, by the way, is when a module computes a value from its arguments and needs to make it available to its children. In BOSL2 $ variables are used to pass geometry information from a parent object to a child object so that the child object can position itself relative to the parent. But direct passing of parameters should be through direct parameters. It might be appropriate for gridfinity to make properties of the object available to children. While OpenSCAD has many limitations, I do not understand how it presents a particular challenge for doing things the "right way" in this case, with parameters as arguments rather than globals. What do you see as the problem here? There is a simple answer to supporting the GUI and code: allow both. Check if the user gave a string and if so, change it to the number using a search() call. |
Actually supporting strings should probably be primary (easier to read the code) and a numerical value converted to a string by an array index. Basically you can start the code with something like:
Note that it looks like a reassignment of parm, but actually the parm on the RHS is the module parameter and the one on the LHS is a different variable in a new scope. |
Another thought about the GUI/Customizer vs library: I think the right way to do this is to completely separate the customizer code from the library. The customizer code is a separate file from the library that loads the library and calls it. If something needs to happen in the customizer code (like translating arguments) it can be an extra layer there, rather than having the customizer force bad library design. |
My rugged box model is implemented in basically the same way @adrianVmariano describes. I wrote that model with usage as a library being a toplevel use case.
In my model, all of the "public" modules are named Python is similar -- there are no such things as private variables/methods. Python convention is to name private class methods/etc. beginning with an underscore. (I've spent most of my professional career in Python so it is a familiar pattern.)
Agreed, this is how I use
This is a good idea, if we want to preserve compatibility for existing consumers who use the integer constants. The string constant used for an option doesn't have to match its display value either. For example, the
This is where I landed too. My rugged box model's toplevel file ( The upside is that gridfinity-rebuilt-openscad already follows most of this convention. We could support string constants for the enum values to make things friendlier and update module names to indicate which modules are "public." I think most importantly it's just good to confirm what the intended approach is to ensure consistency as the project moves forward. |
Hi, I'm continuing to find this project super useful!
In using gridfinity-rebuilt-openscad in some of my own projects, I've submitted #155 and had/found a few thoughts about using this project as a library. I've collected those here.
Comments from other issues
From #125:
@adrianVmariano says:
@Ruudjhuu says:
From #114:
@kennetek says:
Path forward
IMO exposing toplevel functions, which is largely what gridfinity-rebuilt-openscad already does, is the right way to go. I've been exposing components from my own OpenSCAD projects this way, such as in my modular hose, rugged box, and Gridfinity rugged box which uses gridfinity-rebuilt-openscad.
Questions:
rbox
andrbox_size_adjustments
). We could set up the Gridfinity standard values in the same way and allow them to be overridden using a module.style_tab
currently has possible values of0
, through5
. This could be changed to use the string constantsfull
,auto
,left
,center
,right
, andnone
.The text was updated successfully, but these errors were encountered: