From 0e35e02bc79881ede2b663a6e6a9470658110760 Mon Sep 17 00:00:00 2001 From: Roman Kuzmenko Date: Sun, 3 Nov 2024 16:32:18 -0800 Subject: [PATCH] Troubleshooting --- .github/workflows/python-test.yml | 4 +- examples/produce_assembly_assy/logo.svg | 94 +++++++++---------- .../produce_assembly_assy/logo_embedded.svg | 58 ++++++------ partcad/src/partcad/wrappers/wrapper_step.py | 23 ++++- 4 files changed, 97 insertions(+), 82 deletions(-) diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 13b02659..73e5e751 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -33,8 +33,8 @@ jobs: run: | python -m pip install --upgrade pip pip install -U pytest - pip install -r partcad/requirements.txt && \ - pip install svglib rlPyCairo renderlab # Install a subset of CLI dependencies, that are required for tests + # Install all core and a subset of CLI dependencies, that are required for tests + pip install -r partcad/requirements.txt && pip install svglib rlPyCairo renderlab - name: Install OS-specific dependencies (Linux) if: runner.os == 'Linux' run: | diff --git a/examples/produce_assembly_assy/logo.svg b/examples/produce_assembly_assy/logo.svg index 450f1292..e6cf49f8 100644 --- a/examples/produce_assembly_assy/logo.svg +++ b/examples/produce_assembly_assy/logo.svg @@ -2,13 +2,13 @@ - - - - - - - + + + + + + + @@ -59,7 +59,7 @@ - + @@ -152,6 +152,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -174,45 +213,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/produce_assembly_assy/logo_embedded.svg b/examples/produce_assembly_assy/logo_embedded.svg index 061e2455..839d90bc 100644 --- a/examples/produce_assembly_assy/logo_embedded.svg +++ b/examples/produce_assembly_assy/logo_embedded.svg @@ -152,6 +152,25 @@ + + + + + + + + + + + + + + + + + + + @@ -172,25 +191,16 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + @@ -203,16 +213,6 @@ - - - - - - - - - - diff --git a/partcad/src/partcad/wrappers/wrapper_step.py b/partcad/src/partcad/wrappers/wrapper_step.py index 39bb4da3..99d48da0 100644 --- a/partcad/src/partcad/wrappers/wrapper_step.py +++ b/partcad/src/partcad/wrappers/wrapper_step.py @@ -13,25 +13,40 @@ import os import sys -import cadquery as cq +from OCP.STEPControl import STEPControl_Reader +import OCP.IFSelect +from OCP.TopoDS import Shape sys.path.append(os.path.dirname(__file__)) import wrapper_common def process(path, request): - shape = cq.importers.importStep(path).val().wrapped + reader = STEPControl_Reader() + readStatus = reader.ReadFile(path) + if readStatus != OCP.IFSelect.IFSelect_RetDone: + raise ValueError("STEP File could not be loaded") + for i in range(reader.NbRootsForTransfer()): + reader.TransferRoot(i + 1) + + occ_shapes = [] + for i in range(reader.NbShapes()): + occ_shapes.append(reader.Shape(i + 1)) + + # Make sure that we extract all the solids + solids = [] + for shape in occ_shapes: + solids.append(Shape.cast(shape)) return { "success": True, "exception": None, - "shape": shape, + "shape": solids, } path, request = wrapper_common.handle_input() -# Call CadQuery model = process(path, request) wrapper_common.handle_output(model)