Class based objects for easier introspection, and reconciling that with libfive's functional approach #449
traverseda
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In my opinion one of the major flaws in openscad was the lack of introspection when extending other people's code/libraries. For example there was no good way to tell how big an existing object was. It was also hard to override just part of a library object, leading to things like wheel libraries with dozens of different options for the spoke design.
So it would be really nice to have an object that you can modify and introspect at runtime. For example a gear object that can generate compatible gears and tell you how far away you need to place them.
The trick is that libfive is not object oriented. If you had a
g=Gear(d=60)
object and then you tried something likeg.d=40
you would not expect the diameter of the gear to change.This gets even trickier if you want your class-based object to still be able to have "magic methods" performed on them, things like adding or subtracting, or even basics like translation.
It looks like you can inherit from
libfive.shape.Shape
, so I'll look into the best way for doing that.Beta Was this translation helpful? Give feedback.
All reactions