This module contains code to interface with other geometry file formats. At present this is limited to .obj files, though we hope to include other formats in the future.

Submodules module

Module for export of .obj files

The OBJ file format developed by Wavefront Technologies is used in programs like Blender to represent 3D models.

Geomeppy is able to output simple .obj files, and accompanying .mtl files to represent materials. This module contains the source code for this operation. It should be treated as developers’ reference only. As a user, if you want to create a .obj file it is best to use the IDF.to_obj() function.

The generated files can be viewed online at Drag the .obj file and the .mtl file into the browser and you will be able to interact with a zoomable, rotatable model of your IDF.

OBJ file specifications

MTL file specifications

Example polygon:

# vertices
v 0.0 0.0 0.0
v 1.0 0.0 0.0
v 1.0 0.0 1.0
v 0.0 0.0 1.0

# face
f 1// 2// 3// 4//

Bases: object

Container class holding the data needed to generate the .obj file.

add_face(coords, mtl, test=True)
build_surface_with_subsurface(surface, subsurface)

Work around the perimeter of the outer surface, triangulating the surface.

faces = []
from_surfaces(surfaces, subsurfaces, shading_surfaces)
prepare_surfaces(surfaces, subsurfaces)
v_set = {}
vertices = []
write(fname, mtllib)

Write the .obj file.

  • fname – A filename for the .obj file.
  • mtllib – The name of a .mtl file to be referenced from the .obj file., fname=None, mtllib=None)

Export an OBJ file representation of the IDF.

This can be used for viewing in tools which support the .obj format.

  • idf – An IDF to export.
  • fname – A filename for the .obj file. If None we try to base it on IDF.idfname and change the filetype.
  • mtllib – The name of a .mtl file to be referenced from the .obj file. If None, we use default.mtl.