Built-In Input/Output

The Maptek Python SDK includes built-in input/output functionality for importing Maptek object files (.maptekobj), Vulcan triangulation files (.00t), and Vulcan block model files (.bmf and .bdf).

Note:  To run the example scripts provided on this page, first download and extract Maptek_PythonSDK_Sample_IO_Files_20200108.zip to a folder on your system. The example scripts reference the folder location F:\Python SDK Help\data\. You will need to update this location in the scripts to match the folder where you extracted the files.

The import functionality allows you to import data into the project but does not automatically assign it a path. Once the data is successfully imported, it will be represented as an object accessible via its ObjectID. To assign this object to a specific path in the project, use the Project.add_object() method.

Vulcan triangulation files (.00t)

Surfaces (also called triangulations) can be imported from and exported to Vulcan triangulation files (.00t).

Importing a .00t file

Use import_00t() to import a .00t file as a surface object, as demonstrated in the following script:

from mapteksdk.project import Project
from mapteksdk.data import io
from mapteksdk.data.units import DistanceUnit

project = Project() # Connect to default project

# The file path you have exported the sample data to:
file_path = "F:\Python SDK Help\data\phase_1_topo.00t"
# Import the 00t:
imported_surface = io.import_00t(file_path, DistanceUnit.meter)

if imported_surface:
    # Successful imported, now assign a path
    # After add_object, set imported_surface as the new ObjectID:
    imported_surface = project.add_object(
        full_path="import/phase_1_topo",
        new_object=imported_surface,
        overwrite=True)
else:
    print("{} failed to import.".format(file_path))

Important:  This function assumes import data is in metres.

Exporting to a .00t file

Use export_00t() to export a surface to a .00t file. The following script demonstrates re-exporting the surface imported from the previous example as a .00t:

from mapteksdk.project import Project
from mapteksdk.data import io
from mapteksdk.data.units import DistanceUnit

project = Project() # Connect to default project

# The file path to export the surface to:
save_path = "F:\Python SDK Help\data\exported.00t"
# Locate ObjectID of surface to export
surface_to_export = project.find_object("import/phase_1_topo")
if surface_to_export:
    # Export to 00t:
    export_success = io.export_00t(surface_to_export, save_path, DistanceUnit.meter)
    if not export_success:
        print("Export failed")
else:
    print("Could not find surface to export in project")

Vulcan block model files (.bmf)

Block models can be imported from and exported to Vulcan block model files (.bmf).

Importing a .bmf file

Use import_bmf() to import a .bmf file as a block model, as demonstrated in the following script:

from mapteksdk.project import Project
from mapteksdk.data import io
from mapteksdk.data.units import DistanceUnit

project = Project() # Connect to default project

# The file path you have exported the sample data to:
file_path = "F:\Python SDK Help\data\shawmodel_reg.bmf"
# Import the bmf:
imported_blockmodel = io.import_bmf(file_path, DistanceUnit.meter)

if imported_blockmodel:
    # Successful imported, now assign a path
    # After add_object, set imported_surface as the new ObjectID:
    imported_blockmodel = project.add_object(
        "import/shawmodel",
        imported_blockmodel,
        overwrite=True)
else:
    print("{} failed to import.".format(file_path))

Important:  This function assumes import data is in metres.

Exporting to a .bmf file

Use export_bmf() to export a block model to a .bmf file. The following script demonstrates re-exporting the block model imported from the previous example as a .bmf:

from mapteksdk.project import Project
from mapteksdk.data import io
from mapteksdk.data.units import DistanceUnit

project = Project() # Connect to default project

# The file path to export the block model to:
save_path = "F:\Python SDK Help\data\exported.bmf"
# Locate ObjectID of block model to export
blockmodel_to_export = project.find_object("import/shawmodel")
if blockmodel_to_export:
    # Export to bmf:
    export_success = io.export_bmf(blockmodel_to_export, save_path, DistanceUnit.meter)
    if not export_success:
        print("Export failed")
else:
    print("Could not find block model to export in project")

Maptek object files (.maptekobj)

A Maptek object file (.maptekobj) is a binary file capable of storing a variety of project objects. In certain Maptek applications, such as GeologyCore or PointStudio, you can open the Maptek object file as a secondary project. This functionality provides an explorer view where you can browse the contents of the object file, which may contain multiple objects within containers.

Maptek object files are used for archiving or backing up project data and for sharing data between projects. They can include block models, markers, edge chains, edge loops, scans, and more. Essentially, any project data that can be stored can be exported to a Maptek object file.

However, be aware that objects relying on external storage or data systems (outside of the project) may encounter issues. While the receiving application might import the data, it might not be able to fully interpret it, particularly across different versions.

Importing a .maptekobj file

The following example imports several .maptekobj files.

import os
from mapteksdk.project import Project
from mapteksdk.data import io
project = Project() # Connect to default project
# Use the folder you have stored example maptekobj files in:
maptekobj_path = "F:\\Python SDK Help\\data"
maptekobj_files = ["single_object.maptekobj", "multiple_objects.maptekobj", "objects_in_container.maptekobj"]

def assign_path(object_id, object_path):
    # Use the rename_object function to move it from nowhere into a path
    saved = project.rename_object(object_id, object_path, overwrite=True)
    print("Stored: {}".format(object_path)) if saved else print("Failed to store: {}".format(object_path))
    return object_path

def store_maptekobj_objects(maptekobj_id, parent_path = "scrapbook"):
    if "\\" in maptekobj_id.name:
        # multiple objects were exported, but not stored within a VisualContainer
        for item in project.get_children(maptekobj_id).ids():
            assign_path(item, "{}/{}".format(parent_path, item.name))
    else:
        # Single object exported, or VisualContainer with multiple objects
        assign_path(maptekobj_id, "{}/{}".format(parent_path, maptekobj_id.name))

if __name__ == "__main__":

    for file_name in maptekobj_files:
        file_name = os.path.join(maptekobj_path, file_name)
        # Import the maptekobj, providing an ObjectID as a result
        imported_data = io.import_maptekobj(file_name)
        if imported_data:
            store_maptekobj_objects(imported_data)
        else:
            print("Failed to import {}".format(file_name))

# Expected output:
# >> Stored: scrapbook/single_object
# >> Stored: scrapbook/multiple_objects(1st)
# >> Stored: scrapbook/multiple_objects(2nd)
# >> Stored: scrapbook/maptekobj_example

Exporting to a .maptekobj file

Exporting data to a .maptekobj is similar to exporting a triangulation to a .00t file. However, if you need to export multiple objects into a single file, do this by first placing them in a VisualContainer.

The following script exports the contents of the scrapbook container to a single .maptekobj file.

from mapteksdk.project import Project
from mapteksdk.data import io
project = Project() # Connect to default project

save_path = "F:\\Python SDK Help\\data\\export.maptekobj"

if __name__ == "__main__":
    scrapbook = project.find_object("scrapbook")
    # Export the scrapbook container and any children within it
    export_success = io.export_maptekobj(scrapbook, save_path)
    if export_success:
        print("Exported {} to {}".format(scrapbook.path, save_path))
    else:
        print("Failed to export {} to {}".format(scrapbook.path, save_path))