Geometry from CAD#
This example demonstrates loading Geometry
and CompoundGeometry
objects from .dxf
and .3dm
(rhino) files.
Import Modules#
We start by importing the necessary modules.
[1]:
from sectionproperties.analysis import Section
from sectionproperties.pre import CompoundGeometry, Geometry
Load from .dxf
#
Geometry
object#
We can load a single region from a .dxf
file by using the Geometry.from_dxf() method.
[2]:
geom = Geometry.from_dxf(dxf_filepath="../../_static/cad_files/box_section.dxf")
To display the section, we mesh the geometry and plot the mesh.
[3]:
geom.create_mesh(mesh_sizes=[0.5])
Section(geometry=geom).plot_mesh(materials=False)
[3]:
<Axes: title={'center': 'Finite Element Mesh'}>
Note that loading multiple regions from a .dxf
file is not currently supported. A possible work around could involve saving each region as a separate .dxf
file, importing each region individually using Geometry.from_dxf()
, then combining the regions using the +
operator.
Load from .3dm
#
Geometry
object#
We can load a single region from a .3dm
file by using the Geometry.from_3dm() method.
[4]:
geom = Geometry.from_3dm(filepath="../../_static/cad_files/rhino.3dm")
geom = geom.rotate_section(angle=90) # rotate for viewability
To display the section, we mesh the geometry and plot the mesh.
[5]:
geom.create_mesh(mesh_sizes=[0.005])
Section(geometry=geom).plot_mesh(materials=False)
[5]:
<Axes: title={'center': 'Finite Element Mesh'}>
CompoundGeometry
object#
We can load multiple regions from a .3dm
file by using the CompoundGeometry.from_3dm() method.
[6]:
geom = CompoundGeometry.from_3dm(filepath="../../_static/cad_files/rhino_compound.3dm")
geom = geom.rotate_section(angle=90) # rotate for viewability
To display the section, we mesh the geometry and plot the mesh.
[7]:
geom.create_mesh(mesh_sizes=[0.005])
Section(geometry=geom).plot_mesh(materials=False)
[7]:
<Axes: title={'center': 'Finite Element Mesh'}>