Example #1
0
def decompose(path, temp_file_name):
    """
    Decomposes a STEP file into several STEP files (one per unique assembly/part)

    :param path: Path of a file **.stp**
    :param temp_file_name: path of a  :class:`.tempfile` **.arb** that contains the data required
          to generate a :class:`.Product` relative to the arborescense of a **.stp** file
    """
    output = open(temp_file_name.encode(), "r")
    old_product = Product.from_list(json.loads(output.read()))
    step_importer = StepImporter(path)
    shape_tool = step_importer.shape_tool
    product = step_importer.generate_product_arbre()
    decompose_children(product, old_product, shape_tool)
    write_step(product, old_product, shape_tool)
Example #2
0
def decompose(path, temp_file_name):
    """
    Decomposes a STEP file into several STEP files (one per unique assembly/part)

    :param path: Path of a file **.stp**
    :param temp_file_name: path of a  :class:`.tempfile` **.arb** that contains the data required
          to generate a :class:`.Product` relative to the arborescense of a **.stp** file
    """
    output = open(temp_file_name.encode(),"r")
    old_product = Product.from_list(json.loads(output.read()))
    step_importer = StepImporter(path)
    shape_tool = step_importer.shape_tool
    product = step_importer.generate_product_arbre()
    decompose_children(product, old_product, shape_tool)
    write_step(product, old_product, shape_tool)
Example #3
0
def convert_step_file(doc_file_path, doc_file_id, location, thumb_path):
    """


    :param doc_file_path: Path of a file **.stp**
    :param doc_file_id: id that is applied for the generation of the tree **.arb** and the geometries **.geo**
    :param location: Path where to store the files **.geo** and **.arb** generated


    For a file STEP determined by its path (**doc_file_path**),  it generates its file **.arb** and its files **.geo** having count an **id** determined by **doc_file_id**
    and returns in stdout the list of paths of files generated

    """
    logging.getLogger("GarbageCollector").setLevel(logging.ERROR)
    step_importer = StepImporter(doc_file_path, doc_file_id)
    product = step_importer.generate_product_arbre()
    pov_dir = tempfile.mkdtemp(suffix="openplm_pov")
    geo = step_importer.compute_geometries(location, pov_dir)
    print geo
    print write_arbrefile(product, step_importer.fileName, location)
    if step_importer.thumbnail_valid and product:
        create_thumbnail(product, step_importer, pov_dir, thumb_path)
    shutil.rmtree(pov_dir, True)
Example #4
0
def convert_step_file(doc_file_path, doc_file_id, location, thumb_path):
    """


    :param doc_file_path: Path of a file **.stp**
    :param doc_file_id: id that is applied for the generation of the tree **.arb** and the geometries **.geo**
    :param location: Path where to store the files **.geo** and **.arb** generated


    For a file STEP determined by its path (**doc_file_path**),  it generates its file **.arb** and its files **.geo** having count an **id** determined by **doc_file_id**
    and returns in stdout the list of paths of files generated

    """
    logging.getLogger("GarbageCollector").setLevel(logging.ERROR)
    step_importer = StepImporter(doc_file_path, doc_file_id)
    product = step_importer.generate_product_arbre()
    pov_dir = tempfile.mkdtemp(suffix="openplm_pov")
    geo = step_importer.compute_geometries(location, pov_dir)
    print geo
    print write_arbrefile(product, step_importer.fileName, location)
    if step_importer.thumbnail_valid and product:
        create_thumbnail(product, step_importer, pov_dir, thumb_path)
    shutil.rmtree(pov_dir, True)