-
Notifications
You must be signed in to change notification settings - Fork 182
import_scad('MCAD') fails with the last version of OpenSCAD and solidpython on march 2021 #166
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
Comments
Thanks for reporting this. I think this is all working as it's 'supposed' to; there is quite a lot of OpenSCAD code in MCAD that the current parser won't handle correctly, and the import is reporting on all of that. That said, the correct thing to do would be for us to parse all OpenSCAD code correctly, rather than just complaining about stuff we didn't handle before. I'll take a pass at this and see if I can make our OpenSCAD parser more capable. |
I just took a look at this. I'm intending to improve the parse so that we can safely import any valid OpenSCAD code. Until then, it's worth noting that MCAD contains hundreds of nested modules & functions so when you do, for instance: from solid import import_scad
# This import will print a list of OpenSCAD functions/modules that weren't imported
MCAD = import_scad('MCAD')
# However, there's a LOT here that does get imported successfully you can look through the MCAD code,
# or look at the namespace to find, for example `MCAD.lego_compatibility.post()`
print(MCAD.__dict__.keys())
|
I had the same issue and spent some time on it. These are actually two separate issues:
Both branches seem to work (tested with MCAD, BOSL, agentscad, scad-utils) but are for now only tested in a very small development environment. Feel free to use those branches, I might request a pull request after some more usage. |
Btw: the parse_scad_callables function seems to have another issue: When trying to import the BOSL Library (The Belfry OpenScad Library https://github.com/revarbat/BOSL) SolidPython freezes. But this is an issue on master. |
Oh man, this sounds like great work! I’m away from a computer for a couple days, but I’m really excited about having a valid parser as opposed to the kludgy regex hack that we use now. I’ll follow up on this when I’m back home.
… On May 16, 2021, at 12:09 PM, jeff-dh ***@***.***> wrote:
Btw: the parse_scad_callables function has another issue:
When trying to import the BOSL Library (The Belfry OpenScad Library https://github.com/revarbat/BOSL) SolidPython freezes.
I tracked it down into the parse_scad_callables function and to the BOSL/transforms.scad file. When I was printf-debugging it I couldn't get a handle on it (and decided to try out ply ;).
But this is an issue on master.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
There are (at least ;) two more things to mention about that branch:
|
Hey @jeff-dh, would you be willing to open a pull request with the I took a quick look at your branch. What version of In my copy of your branch, I was able to add Ply to SolidPython's dependencies with |
just a quick reply for now:
ply.__version__ -> 3.11
|
I never tried it ;) I'll have a look at it soon |
the parameter of the parse_scad_callables changed it used to be |
That’s exactly the reason! There was also a complaint about an unclosed file handle that could be fixed with a |
On Tue, 18 May 2021 19:01:34 -0700 Evan Jones ***@***.***> wrote:
That’s exactly the reason! There was also a complaint about an
unclosed file handle that could be fixed with a `with path.open() as
f:` context handler.
If you don't want to wait for a patch:
py_scadparser/scad_parser.py : 249
;)
|
The error occurs on every omport_scad attempt on any library folder I try.
The error with the wiki sample code trace the error:
Unable to import SCAD module:
12ptStar
fromshapes.scad
, with error: invalid syntax (, line 2)Unable to import SCAD module:
bearing
fromhardware.scad
, with error: invalid syntax (, line 3)Unable to import SCAD module:
nut
fromhardware.scad
, with error: invalid syntax (, line 3)Unable to import SCAD module:
washer
fromhardware.scad
, with error: invalid syntax (, line 3)Unable to import SCAD module:
rodnut
fromhardware.scad
, with error: invalid syntax (, line 3)Unable to import SCAD module:
rodwasher
fromhardware.scad
, with error: invalid syntax (, line 3)Unable to import SCAD module:
duplicate
frommultiply.scad
, with error: duplicate argument 'no' in function definition (, line 3)Unable to import SCAD module:
8bit_str
fromletter_necklace.scad
, with error: invalid syntax (, line 2)Unable to import SCAD module:
8bit_char
frombitmap.scad
, with error: invalid syntax (, line 2)Unable to import SCAD module:
8bit_str
frombitmap.scad
, with error: invalid syntax (, line 2)Unable to import SCAD module:
8bit_polyfont
fromfonts.scad
, with error: invalid syntax (, line 2)Unable to import SCAD module:
3dtri_sides2coord
from3d_triangle.scad
, with error: invalid syntax (, line 2)Unable to import SCAD module:
3dtri_centerOfGravityCoord
from3d_triangle.scad
, with error: invalid syntax (, line 2)Unable to import SCAD module:
3dtri_centerOfcircumcircle
from3d_triangle.scad
, with error: invalid syntax (, line 2)Unable to import SCAD module:
3dtri_radiusOfcircumcircle
from3d_triangle.scad
, with error: invalid syntax (, line 2)Unable to import SCAD module:
3dtri_radiusOfIn_circle
from3d_triangle.scad
, with error: invalid syntax (, line 2)Unable to import SCAD module:
3dtri_centerOfIn_circle
from3d_triangle.scad
, with error: invalid syntax (, line 2)Unable to import SCAD module:
3dtri_draw
from3d_triangle.scad
, with error: invalid syntax (, line 2)Unable to import SCAD module:
3dtri_rnd_draw
from3d_triangle.scad
, with error: invalid syntax (, line 2)Found OpenSCAD code that's not compatible with Python.
Imported OpenSCAD code using
from
can be accessed with
from_
in SolidPython['2Dshapes', '3d_triangle', 'class', 'delattr', 'dict', 'dir', 'doc', 'eq', 'format', 'ge', 'getattribute', 'gt', 'hash', 'init', 'init_subclass', 'le', 'lt', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'str', 'subclasshook', 'bearing', 'bitmap', 'boxes', 'constants', 'curves', 'fonts', 'gears', 'gridbeam', 'hardware', 'involute_gears', 'layouts', 'lego_compatibility', 'libtriangles', 'materials', 'math', 'metric_fastners', 'motors', 'multiply', 'nuts_and_bolts', 'polyholes', 'regular_shapes', 'screw', 'servos', 'shapes', 'stepper', 'teardrop', 'transformations', 'triangles', 'trochoids', 'units', 'unregular_shapes', 'utilities']
The text was updated successfully, but these errors were encountered: