(scad_file_or_dir: PathStr)
Recursively look in current directory & OpenSCAD library directories for
        OpenSCAD files. Create Python mappings for all OpenSCAD modules & functions
    Return a namespace or raise ValueError if no scad files found
Recursively look in current directory & OpenSCAD library directories for
        OpenSCAD files. Create Python mappings for all OpenSCAD modules & functions
    Return a namespace or raise ValueError if no scad files found
Recursively look in current directory & OpenSCAD library directories for OpenSCAD files . Create Python mappings for all OpenSCAD modules & functions Return a namespace or raise ValueError if no scad files found
def import_scad(scad_file_or_dir: PathStr) -> SimpleNamespace:
    '''
    Recursively look in current directory & OpenSCAD library directories for
        OpenSCAD files. Create Python mappings for all OpenSCAD modules & functions
    Return a namespace or raise ValueError if no scad files found
    '''
    global IMPORTED_SCAD_MODULES
    
    scad = Path(scad_file_or_dir)
    candidates: List[Path] = [scad]

    ns = IMPORTED_SCAD_MODULES.get(scad)
    if ns:
        return ns
    else:
        if not scad.is_absolute():
            candidates = [d/scad for d in _openscad_library_paths()]

        for candidate_path in candidates:
            namespace = _import_scad(candidate_path)
            if namespace is not None:
                IMPORTED_SCAD_MODULES[scad] = namespace
                return namespace
    raise ValueError(f'Could not find .scad files at or under {scad}. \nLocations searched were: {candidates}')
def import_scad ( scad_file_or_dir : PathStr ) -> SimpleNamespace : global IMPORTED_SCAD_MODULES scad = Path ( scad_file_or_dir ) candidates : List [ Path ] = [ scad ] ns = IMPORTED_SCAD_MODULES . get ( scad ) if ns : return ns else : if not scad . is_absolute ( ) : candidates = [ d / scad for d in _openscad_library_paths ( ) ] for candidate_path in candidates : namespace = _import_scad ( candidate_path ) if namespace is not None : IMPORTED_SCAD_MODULES [ scad ] = namespace return namespace raise ValueError ( f'Could not find .scad files at or under {scad}. \nLocations searched were: {candidates}' )