SolidCode / SolidPython

A python frontend for solid modelling that compiles to OpenSCAD
1.11k stars 173 forks source link

importing scad modules issue/question #96

Closed joecabezas closed 5 years ago

joecabezas commented 5 years ago

Hello!, I am trying to import an external module into my python file:

#! /usr/bin/env python
# -*- coding: UTF-8 -*-
from __future__ import division
import os
import sys
import re

# Assumes SolidPython is in site-packages or elsewhwere in sys.path
from solid import *
from solid.utils import *

SEGMENTS = 48

def assembly():
    skin()

if __name__ == '__main__':
    use('./list-comprehension-demos/sweep.scad')

    a = assembly()
    scad_render_to_file(
        a,
        'out.scad',
        file_header='$fn = %s;' % SEGMENTS,
        include_orig_code=True
    )

but when running, it says:

$ python test.py
Traceback (most recent call last):
  File "test.py", line 20, in <module>
    a = assembly()
  File "test.py", line 15, in assembly
    skin()
NameError: name 'skin' is not defined

this is the file I am trying to import which I added it as a submodule https://github.com/openscad/list-comprehension-demos/blob/master/sweep.scad

What is what I am not understanding here?, thanks

etjones commented 5 years ago

So you're doing everything right, assuming you've got all your files and dependencies laid out as the relative paths here require.

I sweated this for a little while, and then... realized that the string skin doesn't show up anyplace in https://github.com/openscad/list-comprehension-demos/blob/master/sweep.scad.

Are you looking for sweep(shape, path_transforms, closed=false) maybe?

joecabezas commented 5 years ago

oh, my bad then, I am new to this lib, thanks for your time and good work!, I will let you now again and reopen if something does not work, right now I can not check

thanks again