I/O#
GeoGeometry can read several geometry files formats.
Read Files#
To read a geometry file with GeoGeometry is simple:
>>> model = geogeometry.read(filepath="test.dxf")
>>> print(model)
GeometryModel(name=master, triangulations=0, polylines=0, points=0, children=2)
GeoGeometry yields a “master” GeometryModel object after reading, which acts as a host “layer”. A GeometryModel object is analogous to what is commonly known as a layer in CAD softwares, meaning it can host any type of geometry object(even other GeometryModel, as the case of master):
>>> for m in model:
>>> print(m)
GeometryModel(name=DESIGN, triangulations=1, polylines=0, points=0, children=0)
GeometryModel(name=CMS, triangulations=1, polylines=0, points=0, children=0)
A GeometryModel object is analogous to what is commonly known as a layer, meaning it can host any type of geometry object (even other GeometryModel).
Format |
Description |
|---|---|
dxf |
AutoCAD Drawing Exchange Format. Supports 2D and 3D entities such as lines, polylines, arcs, and meshes. |
3dm |
Rhino 3D native file format. Supports NURBS curves, surfaces, polysurfaces, and mesh geometries. |
stl |
Stereolithography mesh format. Contains triangulated surface geometry only (no curves or parametric data). |
csv |
Text-based comma-separated values format. Interpreted as a collection of 3D points. |
Write Files#
GeoGeometry can also write geometry files easily.
When writing geometry files using GeoGeometry the difference between methods save and export should be clear. In GeoGeometry, save is used to write a pickle file of the calling object:
model.save(savepath="test.pkl.gz")
Saved files can have any of the following extensions:
Format |
Description |
|---|---|
pkl |
Standard pickle serialization without compression. |
pkl.gz |
Pickle serialization with gzip compression (~3× smaller than .pkl). |
pkl.xz |
Pickle serialization with lzma compression (30–50% smaller than .pkl.gz, significantly slower to write and read). |
When calling export instead, GeoGeometry identifies the file format by the savepath extension and write a geometry files using the corresponding format rules:
model.exports(savepath="test.dxf")