Skip to content

Commit f4b3604

Browse files
Merge pull request #197 from robbievanleeuwen/move_rhino_and_dxf_imports
Moved imports for rhino libraries into rhino methods
2 parents 553b70e + cc1abe0 commit f4b3604

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

sectionproperties/pre/geometry.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import sectionproperties.pre.pre as pre
2323
import sectionproperties.pre.bisect_section as bisect
2424
import sectionproperties.post.post as post
25-
import sectionproperties.pre.rhino as rhino_importer
2625

2726

2827
class Geometry:
@@ -262,6 +261,16 @@ def from_3dm(cls, filepath: Union[str, pathlib.Path], **kwargs) -> Geometry:
262261
If true, all non parallel surfaces are filtered out.
263262
Default is False.
264263
"""
264+
try:
265+
import sectionproperties.pre.rhino as rhino_importer # type: ignore
266+
except ImportError as e:
267+
print(e)
268+
print(
269+
"There is something wrong with your rhino library installation. "
270+
"Please report this error at https://github.com/robbievanleeuwen/section-properties/issues"
271+
)
272+
return
273+
265274
geom = None
266275
list_poly = rhino_importer.load_3dm(filepath, **kwargs)
267276
if len(list_poly) == 1:
@@ -313,6 +322,15 @@ def from_rhino_encoding(cls, r3dm_brep: str, **kwargs) -> Geometry:
313322
If true, all non parallel surfaces are filtered out.
314323
Default is False.
315324
"""
325+
try:
326+
import sectionproperties.pre.rhino as rhino_importer # type: ignore
327+
except ImportError as e:
328+
print(e)
329+
print(
330+
"There is something wrong with your rhino library installation. "
331+
"Please report this error at https://github.com/robbievanleeuwen/section-properties/issues"
332+
)
333+
return
316334
return cls(geom=rhino_importer.load_brep_encoding(r3dm_brep, **kwargs)[0])
317335

318336
def create_facets_and_control_points(self):
@@ -1320,6 +1338,15 @@ def from_3dm(cls, filepath: Union[str, pathlib.Path], **kwargs) -> CompoundGeome
13201338
If true, all non parallel surfaces are filtered out.
13211339
Default is False.
13221340
"""
1341+
try:
1342+
import sectionproperties.pre.rhino as rhino_importer # type: ignore
1343+
except ImportError as e:
1344+
print(e)
1345+
print(
1346+
"There is something wrong with your rhino library installation. "
1347+
"Please report this error at https://github.com/robbievanleeuwen/section-properties/issues"
1348+
)
1349+
return
13231350
list_poly = rhino_importer.load_3dm(filepath, **kwargs)
13241351
return cls(geoms=MultiPolygon(list_poly))
13251352

0 commit comments

Comments
 (0)