Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import/Export Issue with IGES #272

Closed
mkofler96 opened this issue Oct 6, 2023 · 4 comments
Closed

Import/Export Issue with IGES #272

mkofler96 opened this issue Oct 6, 2023 · 4 comments

Comments

@mkofler96
Copy link
Contributor

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
Copy link
Member

j042 commented Oct 6, 2023

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
Copy link
Contributor Author

That worked, thanks!

@jzwar
Copy link
Collaborator

jzwar commented Oct 6, 2023

Should remain open as long as no meaningful Exception is raised

@j042
Copy link
Member

j042 commented Nov 7, 2023

#273

@j042 j042 closed this as completed Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants