-
Notifications
You must be signed in to change notification settings - Fork 25
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
Escaped OpenSCAD identifiers don't get exposed (because a single _ makes them private) #10
Comments
SolidPython/solid2/core/builtin_primitives.py Line 656 in 07f5636
but we just discovered a bug, becaused it's (still) called I need to think about it -- the renaming -- a little, because the _foobar policy does not work properly in this situation (_foobar -> private class) |
So, I can't come up with a solution for the naming issue right now. The issue is the following: OpenSCAD identifiers -- which get imported into SolidPython -- might be illegal python identifiers (keywords like For now you should use the Even though this is not the ideal solution, I guess it makes your proposal obsolete, right? I would leave this ticket open (and rename it) because of the escape identifier issue. |
In other words, we need a different escaping mechanism or a "python hack" to expose private classes / functions. Any ideas and suggestions are welcome! cf. SolidPython/solid2/core/utils.py Line 13 in 07f5636
|
|
For the sake of brainstorming, a more radical idea that came to mind is a function look up table or factory, aka |
I'd be happy to contribute an example for using |
Yeah, I'd be happy to merge it. Add an example as I'm wondering what you're actually doing (considering your other ticket). If you manipulate a imported stl with BOSL2 (e.g. attaching stuff to a stl using BOSL2?) I think that would be a really cool example. (Don't know whether it's possible at all....) |
here's an example of what I'm doing with import: ```python
def traffic_cone():
cone_file = 'traffic-cone.stl'
cone_center = [44.5/2, 44.5/2]
return import_(cone_file).translate([-v for v in cone_center]) No BOSL2 here but it is possible to attach stuff to a stl with BOSL2 just like anything else, you just have to do the work of making it attachable, which requires you know the size / shape of the stl. Given that we are working in Python and not subject to the OpenSCAD paradigm of not knowing the size of anything, I've begun to fall out of love with attaching objects using the BOSL2 attachable solution, though I absolutely love it for orienting geometries. I still feel like I have a lot to learn in how to enable attachments with non-cube geometries. It is definitely powerful in the OpenSCAD paradigm where modules do not carry any additional information beside the base geometry. However, we have to know the size to make a shape attachable, and once we've made it attachable it's not easy to access the size parameter again. I find myself tempted to add a Here's an example of that approach: def bottom_cone_band(hole=False, _fn=FN_VIEW, anchor=aCENTER, spin=0, orient=UP):
top_height = CONE_HEIGHT - TOP_BAND_SPACING - TOP_BAND_WIDTH - BOTTOM_BAND_SPACING
obj, size = _cone_band_and_size(BOTTOM_BAND_WIDTH, top_height, hole=hole, _fn=_fn)
return attachable(anchor, spin, orient, size=size) (obj)
def _cone_band_and_size(width, top_height, _fn):
shape_width = EXTRUDE_WIDTH+epsilon
base_height = top_height - width
top_od = CONE_BOTTOM_OD - 2*top_height/tan(CONE_TAPER_ANGLE_RAD)
bottom_od = CONE_BOTTOM_OD - 2*base_height/tan(CONE_TAPER_ANGLE_RAD)
obj = tube(h=width, od1=bottom_od+2*epsilon, od2=top_od+2*epsilon, wall=shape_width, _fn=_fn, anchor=aCENTER)
size = [bottom_od, bottom_od, width]
return obj.up(dz), size |
I extracted the current essence of this issue into #17 and gonna close this issue. |
A part of my workflow is to import stls into my openscad project. I couldn't figure out a way to do this in solid2 so I created a new class that extends
OpenSCADObject
, shown below. Would there be any interest in adding this to solid2 somewhere?The text was updated successfully, but these errors were encountered: