tataratat / splinepy

Library for prototyping spline geometries of arbitrary dimensions and degrees, and IGA
https://tataratat.github.io/splinepy
Other
47 stars 13 forks source link

Import/Export Issue with IGES #272

Closed mkofler96 closed 11 months ago

mkofler96 commented 1 year ago

I tried to export a microstructure to .IGS files format and could not open it in any other software, so I tried to reimport it into splinepy and got the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[c:\Users\mkofler\OneDrive](file:///C:/Users/mkofler/OneDrive) - TU Wien\Documents\05_Lattice Structure Facade\minimum_working_example.ipynb Cell 1 line 1
     [15](vscode-notebook-cell:/c%3A/Users/mkofler/OneDrive%20-%20TU%20Wien/Documents/05_Lattice%20Structure%20Facade/minimum_working_example.ipynb#W0sZmlsZQ%3D%3D?line=14) microstructure.tiling = [8, 4, 1]
     [17](vscode-notebook-cell:/c%3A/Users/mkofler/OneDrive%20-%20TU%20Wien/Documents/05_Lattice%20Structure%20Facade/minimum_working_example.ipynb#W0sZmlsZQ%3D%3D?line=16) sp.io.iges.export("test.igs",microstructure.create().patches)
---> [18](vscode-notebook-cell:/c%3A/Users/mkofler/OneDrive%20-%20TU%20Wien/Documents/05_Lattice%20Structure%20Facade/minimum_working_example.ipynb#W0sZmlsZQ%3D%3D?line=17) ig = sp.io.iges.load("test.igs")

File [c:\Users\mkofler\miniconda3\envs\splinepy\Lib\site-packages\splinepy\io\iges.py:21](file:///C:/Users/mkofler/miniconda3/envs/splinepy/Lib/site-packages/splinepy/io/iges.py:21), in load(fname)
      8 def load(fname):
      9     """
     10     Read spline in `.iges` form.
     11 
   (...)
     19       Spline Type defined in NAME_TO_TYPE
     20     """
---> 21     return ioutils.dict_to_spline(splinepy_core.read_iges(fname))
ValueError: invalid stoi argument

Minimum working example:

import splinepy as sp
microstructure = sp.microstructure.Microstructure()

base2D = sp.Bezier(
    degrees=[1, 1],
    control_points=[[ 0.,    0.,    0.  ],
                    [ 2.,    0.,    0.  ],
                    [ 0.,    1.5,   0 ],
                    [ 2.,    1.5,   0 ]],
)

microstructure.deformation_function = base2D.create.extruded(extrusion_vector=[0, 0, 1])

microstructure.microtile = getattr(sp.microstructure.tiles, "NutTile3D")().create_tile()[0]
microstructure.tiling = [8, 4, 1]

sp.io.iges.export("test.igs",microstructure.create().patches)
ig = sp.io.iges.load("test.igs")
j042 commented 1 year ago

iges is a format for BRep and it seems that this splines are "Solids". This should however raise Error in during export. @mkofler96 feel free to create a PR.

In your case, you could do

...

ms = microstructure.create()
ms_brep = ms.boundary_multipatch()

sp.io.iges.export("test.igs", ms_brep.patches)
ig = sp.Multipatch(sp.io.iges.load("test.igs"))  # this loads lists

ig.show(control_points=False)
mkofler96 commented 1 year ago

That worked, thanks!

jzwar commented 1 year ago

Should remain open as long as no meaningful Exception is raised

j042 commented 11 months ago

273