maptek.vulcan.block_model

This class allows access to the block model structures within Vulcan.

To download all the example scripts, click here.


Block model template script

The follow script is a template showing the basic requirements needed to create a block model using Python. This script will serve as an example of several function calls.

# Filename: bm_blockmodel_template.py
# Purpose: Create a new regular block model.
# Returns: regular block model.

from maptek import vulcan

# Step 1: Create a block model object.
with vulcan.block_model() as bm:

    # Step 2: Define variables that will hold the model parameters.
    # These hold the model extents and number of blocks in the
    # x, y, and z directions.
    xbegin, ybegin, zbegin = 0, 0, 0
    xend, yend, zend = 50, 50, 50
    x_num_block, y_num_block, z_num_block = 5, 5, 5

    # Step 3: Create a block model.
    # At this stage, only the extents and number of blocks will be set. No
    # actual blocks are created yet. Note that this will clear any information
    # about the previous block model the object referred to.
    bm.create_regular('example.bmf',
                      xbegin, ybegin, zbegin,
                      xend, yend, zend,
                      x_num_block, y_num_block, z_num_block)

    # Step 4: Add variables to block model.
    # args : (name, type, default, description)
    bm.add_variable('class', 'integer', '-99', '1=measured, 2=indicated, 3=infered')
    bm.add_variable('cu', 'float', '-99', 'copper')
    bm.add_variable('lith', 'name', 'none', 'geology')

    # Step 5: Move the origin of the block model to the desired location.
    # When a block model is initially created, it is set at a location of
    # (0.0, 0.0, 0.0).
    bm.translate(77900.0, 4350.0, -320.0)  # enter xyz translation distances

    # Step 6: Set the rotation parameters.
    # For this example, we want a bearing of 62 degrees. To get that, we have
    # to subtract standard Vulcan 90 degrees. Using mod 360 constrains the
    # answer within 360 degrees.
    bearing = (62 - 90) % 360
    dip = 77
    plunge = 35
    bm.rotate(dip, plunge, bearing)

    # Step 7: Set the block length.
    xlen = int(xend/x_num_block)  # 50/5 = 10
    ylen = int(yend/y_num_block)  # 50/5 = 10
    zlen = int(zend/z_num_block)  # 50/5 = 10

    # # Step 8: Add blocks to the model.  Note that blocks are added in model
    # space NOT world space. Each block is defined from the lower left of the
    # 3D cube to the upper right of the 3D cube.
    for i in range(0, xend, xlen):
        for j in range(0, yend, ylen):
            for k in range(0, zend, zlen):
                # calc the min/max block
                xmin = i
                ymin = j
                zmin = k
                xmax = i + xlen
                ymax = j + ylen
                zmax = k + zlen

                # add block to block model
                bm.add_block(xmin, ymin, zmin, xmax, ymax, zmax)

    # Step 9: Index block model, then verify results.
    verify_index = bm.index_model()
    if verify_index == 0:
        print("Block model has been indexed.")
    else:
        print("Block model has not been indexed.")

Navigating through a block model

Python treats block models in a way similar to working with a database. Each block can be thought of as representing a record, and the variables found within that block represent a field within that record.

To create or edit a block model, you will need to iterate through the model in a manner that allows you access to each block. The following navigational functions are ways of moving through a block model:

rewind(self) -> int - 0 if successful, 1 otherwise.

Sets the position within the model to the beginning.

eof(self) -> bool

Sets the position to the end of the model.

next(self) -> int - 0 if successful, 1 otherwise.

Advances the position by one record (or block).

get_position(self) -> float - the current record position.
set_position(self, pos) -> int - 0 if successful, 1 otherwise.

These functions are used when you know the block and need to reference it again later. For example, using some sort of operation in which you need to review the entire model, then go back.

However, the navigational functions can be superseded by just iterating.

Example
for block in block_model:
    # Do something

Is the same as the older:

while not block_model.eof():
    # Do something
    block_model.next() # If this is forgotten or missed it will loop forever
add_block(self, x0, y0, z0, x1, y1, z1) -> int

Add a new block to the model.

Note:  The block location is not validated upon adding. The block should be sized equal to a parent or sub block size and should be inserted at a location that correctly aligns to those coordinates. This function should only be used where no blocks exist (such as deleted blocks). Also, note that a newly created block will overlap existing blocks if blocks already exists at the location, causing an error.

Parameters

Note:  This function uses block coordinates as the input arguments, not real-world coordinates.

  • The X,Y,Z coordinate of the lower extent of the block.

  • The X,Y,Z coordinate of the upper extent of the block.

Returns 0 if successful, 1 otherwise.

Example:  See Step 8 of the Block model template script above

add_variable(self, *args, **kwargs) -> int

Add a variable to a block model.

Parameters

  • Variable name

  • Variable type (name, byte, short, integer, float, double)

  • Default variable value

  • Variable description

Returns 0 if successful, Non-zero if otherwise.

Example:  See Step 4 of the Block model template script above

block_extent(self) -> list

Get the extent of the currently selected block.

Returns

  • For most models, this will be a list in which the values are the coordinates of the lower extent, and the values are the coordinates of the upper extent.

  • For HARP models, the corner offsets will also be shown.

# Filename: bm_block_extent.py
# Purpose: Get the extent of the currently selected block.
# Returns: List

from maptek import vulcan

blockmodel = 'example.bmf'  # input block model

with vulcan.block_model(blockmodel) as bm:  # open the block model
    assert bm.is_open(), 'f"{blockmodel} is not open."'

    # get single block extent
    bm.set_position(1)  # select block using index
    s_ext = bm.block_extent()  # get block extent
    print(s_ext)  # print results

    # iterate through block model to get all block extents
    for block in bm:
        index = bm.get_position()  # get block index
        ext = bm.block_extent()  # get block extent
        print(f'{index} : {ext}')  # print results

close(self) -> int

Close the block model file.

Returns

  • 0 if successful, 1 otherwise.

# Filename: bm_close.py
# Purpose: Close a block model.
# Returns: Integer

from maptek import vulcan

blockmodel = 'demo_vein.bmf'  # input block model
bm = vulcan.block_model(blockmodel)  # open the block model

if bm:
    print(f'{blockmodel} successfully opened.')

state = bm.close()  # close block model
print(state)  # print result of close: 0 if successful, 1 otherwise

create_irregular(self, name, x0, y0, z0, x1, y1, z1, nx, ny, nz, sub_nx, sub_ny, sub_nz) -> int

Create a new irregular block model, optionally with a sub schema.

Note:  This will clear any information about the previous block model to which the object is referring.

Parameters

  • The file path for the new block model.

  • The minimum X,Y,Z coordinate of the model extent.

  • The maximum X,Y,Z coordinate of the model extent.

  • The number of blocks in the X,Y,Z direction for the main schema.

  • The number of blocks in the X,Y,Z direction for the sub schema.

Returns

  • 0 if successful, 1 otherwise.

# Filename: bm_create_irregular.py
# Purpose: Create a new regular block model.
# Returns: Integer - 0 if successful, 1 otherwise.

from maptek import vulcan

# Step 1: Create a block model object.
name = 'example.bmf'
with vulcan.block_model(name) as bm:
    # Step 2: Define variables that will hold the model parameters.
    # These hold the model extents and number of blocks in the
    # x, y, and z directions.
    xbegin, ybegin, zbegin = 0, 0, 0  # minimum coordinate of model extent
    xend, yend, zend = 50, 50, 50  # maximum coordinate of model extent
    p_nx, p_ny, p_nz = 10, 10, 10  # number of blocks in the main schema
    sub_nx, sub_ny, sub_nz = 5, 5, 5  # number of blocks in the sub schema

    # Step 3: Create a block model.
    # At this stage, only the extents and number of blocks will be set. No
    # actual blocks are created yet. Note that this will clear any information
    # about the previous block model the object referred to.
    bm.create_irregular(name,
                        xbegin, ybegin, zbegin,
                        xend, yend, zend,
                        p_nx, p_ny, p_nz,
                        sub_nx, sub_ny, sub_nz)

    # Step 4: Add variables to block model.
    # args : (name, type, default, description)
    bm.add_variable('class', 'integer', '-99', '1, 2, or 3')
    bm.add_variable('cu', 'float', '-99.0', 'copper')
    bm.add_variable('au', 'double', '-99.0', 'gold')
    bm.add_variable('byte', 'byte', '0', 'byte')
    bm.add_variable('geocod', 'short', '-99', 'flag')
    bm.add_variable('lith', 'name', 'none', 'geology')

    # Step 5: Move the origin of the block model to the desired location.
    # When a block model is initially created, it is set at a location of
    # (0.0, 0.0, 0.0).
    bm.translate(77900.0, 4350.0, -320.0)  # enter xyz translation distances

    # Step 6: Set the rotation parameters.
    # For this example, we want a bearing of 62 degrees. To get that, we have
    # to subtract standard Vulcan 90 degrees. Using mod 360 constrains the
    # answer within 360 degrees.
    x = 62  # (62 - 90) % 360
    y = 25
    z = 0
    bm.rotate(x, y, z)

    # Step 7: Set the block length.
    xlen = int(xend / p_nx)  # 50/5 = 10
    ylen = int(yend / p_ny)  # 50/5 = 10
    zlen = int(zend / p_nz)  # 50/5 = 10

    # Step 8: Add blocks to the model.  Note that blocks are added in model
    # space NOT world space. Each block is defined from the lower left of the
    # 3D cube to the upper right of the 3D cube.
    for i in range(0, xend, xlen):
        for j in range(0, yend, ylen):
            for k in range(0, zend, zlen):
                # calc the min/max block
                xmin = i
                ymin = j
                zmin = k
                xmax = i + xlen
                ymax = j + ylen
                zmax = k + zlen

    # add block to block model
    bm.add_block(xmin, ymin, zmin, xmax, ymax, zmax)

    # Step 9: Index block model, then verify results.
    verify_index = bm.index_model()
    if verify_index == 0:
        print("Block model has been indexed.")
    else:
        print("Block model has not been indexed.")
create_regular(self, name, x0, y0, z0, x1, y1, z1, nx, ny, nz) -> int

Create a new regular block model.

Note:   This will clear any information about the previous block model to which the object is referring.

Parameters

  • The file path for the new block model.

  • The minimum X,Y,Z coordinate of the model extent.

  • The maximum X,Y,Z coordinate of the model extent.

  • The number of blocks in the X,Y,Z direction.

Returns:

  • 0 if successful, 1 otherwise.

  • Example:  See the Block model template script above

  • create_strat(self, name, x0, y0, z0, x1, y1, z1, nx, ny) -> int

    Create a new stratigraphic block model.

    Note:  This will clear any information about the previous block model to which the object is referring.

    Parameters

    • The name of the new block model.

    • The minimum X,Y,Z coordinate of the model extent.

    • The maximum X,Y,Z coordinate of the model extent.

    • The number of blocks in the X and Y direction.

    Returns:

    • 0 if successful, 1 otherwise.

    # Filename: bm_create_strat.py
    # Purpose: Create a stratigraphic block model.
    # Returns: Integer - 0 if successful, 1 if not.
    
    from maptek import vulcan
    
    # Step 1: Create a block model object.
    with vulcan.block_model() as bm:
    
        # Step 2: Define variables that will hold the model parameters.
        # These hold the model extents and number of blocks in the
        # x and y directions.
        x0, y0, z0 = 0, 0, 0
        x1, y1, z1 = 50, 50, 5
        nx, ny = 5, 5
    
        # Step 3: Create a stratigraphic block model.
        # At this stage, only the extents and number of blocks will be set. No
        # actual blocks are created yet. Note that this will clear any information
        # about the previous block model the object referred to.
        bm.create_strat('example_strat.bmf',
                        x0, y0, z0,
                        x1, y1, z1,
                        nx, ny)
    
        # Step 4: Add variables to block model.
        # args : (name, type, default, description)
        bm.add_variable('class', 'integer', '-99', '1=measured, 2=indicated, 3=infered')
        bm.add_variable('ore', 'float', '-99', 'coal')
        bm.add_variable('lith', 'name', 'none', 'geology')
    
        # Step 5: Move the origin of the block model to the desired location.
        # When a block model is initially created, it is set at a location of
        # (0.0, 0.0, 0.0).
        bm.translate(77900.0, 4350.0, -320.0)
    
        # Step 6: Set the rotation parameters.
        # For this example, we want a bearing of 62 degrees. To get that, we have
        # to subtract standard Vulcan 90 degrees. Using mod 360 constrains the
        # answer within 360 degrees.
        bearing = (62 - 90) % 360
        dip = 0
        plunge = 0
        bm.rotate(dip, plunge, bearing)
    
        # Step 7: Set the block length.
        xlen = int(x1/nx)  # 50/5 = 10
        ylen = int(y1/ny)  # 50/5 = 10
        zlen = 5
    
        # Step 8: Add blocks to the model.  Note that blocks are added in model
        # space NOT world space. Each block is defined from the lower left of the
        # 3D cube to the upper right of the 3D cube.
        for i in range(0, x1, xlen):
            for j in range(0, y1, ylen):
                for k in range(0, z1, zlen):
                    # calc the min/max block
                    xmin = i
                    ymin = j
                    zmin = k
                    xmax = i + xlen
                    ymax = j + ylen
                    zmax = k + zlen
    
                    # add block to block model
                    bm.add_block(xmin, ymin, zmin, xmax, ymax, zmax)
    
        # Step 9: Index block model, then verify results.
        verify_index = bm.index_model()
        if verify_index == 0:
            print("Block model has been indexed.")
        else:
            print("Block model has not been indexed.")
    
    
    creation_date(self) -> string

    Check when the block model was created.

    Returns the date of the block model creation.

    # Filename: bm_creation_date.py
    # Purpose: Get the block model creation date.
    # Returns: String
    
    from maptek import vulcan
    
    blockmodel = 'example.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        cr_date = bm.creation_date()  # get the creation date
        print(f"Creation date: {cr_date}")
    
    
    delete_variable(self, name) -> int

    Remove a variable from the block model.

    Parameters

    • The name of the variable to delete.

    Returns

    • 0 if successful, 1 otherwise.

    # Filename: bm_delete_variable.py
    # Purpose: Remove a variable from the block model.
    # Returns: Integer - 0 if successful, 1 if not.
    
    from maptek import vulcan
    
    blockmodel = 'example.bmf'  # input block model
    del_var = 'lith'  # variable to delete
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_field(del_var), f'Variable does not exist.'
    
        state = bm.delete_variable('lith')  # delete variable
    
        if state == 0:  # verify deletion
            print('Variable was deleted.')
        else:
            print('Variable was not deleted.')
    
    
    description(self) -> string

    Get the description of the block model.

    Note:  The description is set by using Block > Manipulation > Edit Description.

    Returns the description.

    # Filename: bm_description.py
    # Purpose: Get the description of the block model.
    # Returns: String - the description.
    
    from maptek import vulcan
    
    blockmodel = 'example.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        descript = bm.description()
        print(f'{descript}')
    
    
    field_default(self, name) -> float

    Get the default value of a numeric variable.

    Parameters

    • The variable name to get the default value for.

    Returns the default float value of the variable.

    # Filename: bm_field_default.py
    # Purpose: Get the default value of a numeric variable.
    # Returns: Float
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:
        # get list of all numeric variables
        vars = bm.field_list_numbers()
    
        # iterate through list of variables to get default values
        for var in vars:
            default_val = bm.field_default(var)  # get default value
            print(f"Variable: {var}  Default value: {default_val}")
    
    
    field_default_string(self, name) -> string

    Get the default value of a string variable.

    Parameters

    • The variable name to get the default value for.

    Returns the default string value of the variable.

    # Filename: bm_field_default_string.py
    # Purpose: Get the default value of a string variable.
    # Returns: String
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:
        # get list of all string variables
        vars = bm.field_list_strings()
    
        # iterate through list of variables to get default values
        for var in vars:
            default_val = bm.field_default_string(var)  # get default value
            print(f"Variable: {var}  Default value: {default_val}")
    
    
    field_description(self, name) -> string

    Get the description of a variable.

    Parameters

    • The variable name to get the description for.

    Returns the description of the variable.

    # Filename: bm_field_description.py
    # Purpose: Get the description of a block model variable.
    # Returns: String
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the blockmodel
        # get list of all numeric variables
        vars = bm.field_list()
    
        # iterate through variable list
        for var in vars:
            descript = bm.field_description(var)  # get variable description
            print(f"Variable: {var}  Description: {descript}")
    
    
    field_index(self, name) -> int

    Get the index of a given variable in the block model.

    Note:  This function is an older version of (shown below). It is kept in place to accommodate older scripts. However, newer scripts should use the function instead.

    Parameters

    • The variable to get the index for.

    Returns the index of the given variable.

    # Filename: bm_field_index.py
    # Purpose: Get the index of a block model variable.
    # Returns: Integer#
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the blockmodel
        vars = bm.field_list()  # get list of all variables
    
        # iterate through variable list
        for var in vars:
            field_ind = bm.field_index(var)  # get the index of the variable
            print(f"Index: {field_ind}   Variable: {var}")
    
    
    field_list(self) -> list

    Get the list of variables for the block model.

    Returns the list of variable names.

    # Filename: bm_field_list.py
    # Purpose: Create list of the variables from a block model.
    # Returns: List
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the blockmodel
        list_of_vars = bm.field_list()  # Get the list of variables
        for var in list_of_vars:
            print(var)
    
    
    field_list_numbers(self) -> list

    Get the list of numeric variables for the block model.

    Returns the list of numeric variable names.

    # Filename: bm_field_list_numbers.py
    # Purpose: Create list of all numeric variables from a block model.
    # Returns: List
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the blockmodel
        number_vars = bm.field_list_numbers()  # get the list of numeric variables
        for var in number_vars:
            print(var)
    
    
    field_list_strings(self) -> list

    Get the list of string variables for the block model.

    Returns the list of string variable names.

    # Filename: bm_field_list_numbers.py
    # Purpose: Create list of all string variables from a block model.
    # Returns: List
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the blockmodel
        string_vars = bm.field_list_strings()  # get the list of numeric variables
        for var in string_vars:
            print(var)
    
    field_predefined(self, name) -> int

    Check if a variable is a predefined field.

    Parameters

    • The variable to check.

    Returns 1 if the variable is predefined, 0 otherwise.

    # Filename: bm_field_predefined.py
    # Purpose: Check if a variable is a predefined field.
    # Returns: Integer - 1 if the variable is predefined, 0 otherwise.
    
    from maptek import vulcan
    
    blockmodel = 'example.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:
        # get list of all variables
        vars = bm.field_list()
    
        # iterate through list of variables
        for var in vars:
            val = bm.field_predefined(var)  # check if a variable is a predefined
            if val == 1:
                print(f"Variable: {var} - Predefined")
            elif val == 0:
                print(f"Variable: {var} - User defined")
    
    
    field_type(self, name) -> string

    Get the type of a field.

    Parameters

    • The variable to get the type of.

    Returns the type of the variable.

    # Filename: bm_field_type.py
    # Purpose: Get the variable type of input variable.
    # Returns: String
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the blockmodel
        list_of_vars = bm.field_list()  # Get the list of variables
    
        for var in list_of_vars:
            var_type = bm.field_type(var)  # get the variable type
            print(f'Variable: {var}  Type: {var_type}')
    
    
    find_world_xyz(self, x, y, z) -> int

    Find a block at given real world coordinates and set the record position.

    Parameters

    • The X,Y,Z coordinate to look for the block.

    Returns 0 if successful, 1 otherwise.

    # Filename: bm_find_world_xyz.py
    # Purpose: Find a block at given real world coordinates and set the record position.
    # Returns: Integer - 0 if successful, 1 otherwise.
    
    from maptek import vulcan
    
    blockmodel = 'example.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
        state = bm.find_world_xyz(78008.26952060146, 4477.048383112897, -300.0)  # locate block
        print(state)
    
    
    find_world_xyz_seam(self, p, seam) -> int

    find_world_xyz_seam(self, x, y, z, seam) -> int

    Find the seam at given real world coordinates.

    Parameters

    • The X coordinate to look for the seam.

    • The Y coordinate to look for the seam.

    • point.

    • The name of the seam.

    Returns 0 if successful, 1 otherwise.

    # Filename: bm_get_seam_xyz.py
    # Purpose: Find the seam at given real world coordinates.
    # Returns: Returns 0 if successful, 1 otherwise.
    
    from maptek import vulcan
    from maptek import vulcan_gui
    
    blockmodel = 'fitharp_sub.bmf'  # input block model
    
    # Select location interactively
    pick1 = vulcan_gui.pick_point()  # creates a point object
    pick1.set_single_point()  # set property to select only one point
    pt = pick1.pick('Select location.')  # prompt to select location
    
    # Open block model as object
    with vulcan.block_model(blockmodel) as bm:
    
        # Confirm that model has been opened.
        # Script ends with the following message if not.
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # Returns 0 if successful, 1 otherwise.
        state = bm.find_world_xyz_seam(pt[0].x, pt[0].y, pt[0].z, 'bd')
        print(state)
    
    find_xyz(self, x, y, z) -> int

    Find a block at given model coordinates and set the record position.

    Parameters

    • The X coordinate to look for the block.

    • The Y coordinate to look for the block.

    • The Z coordinate to look for the block.

    Returns 0 if successful, 1 otherwise.

    # Filename: bm_find_xyz.py
    # Purpose: Find a block at given real world coordinates and set the record position.
    # Returns: Integer - 0 if successful, 1 otherwise.
    
    from maptek import vulcan
    
    blockmodel = 'example.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
        state = bm.find_xyz(20.0, 20.0, 20.0)  # locate block
        print(state)
        b_ext = bm.to_world(20.0, 20.0, 20.0)
        print(b_ext)
    
    
    find_xy_seam(self, p, seam) -> int
    find_xy_seam(self, x, y, z, seam) -> int

    Find the seam at given model coordinates.

    Parameters

    • The X coordinate to look for the seam.

    • The Y coordinate to look for the seam.

    • point.

    • The name of the seam.

    Returns 0 if successful, 1 otherwise.

    # Filename: bm_find_xy_seam.py
    # Purpose: Find the seam at given model coordinates.
    # Returns: Returns 0 if successful, 1 otherwise.
    
    from maptek import vulcan
    from maptek import vulcan_gui
    
    blockmodel = 'fitharp_sub.bmf'  # input block model
    
    # Select location interactively
    pick1 = vulcan_gui.pick_point()  # creates a point object
    pick1.set_single_point()  # set property to select only one point
    pt = pick1.pick('Select location.')  # prompt to select location
    
    # Open block model as object
    with vulcan.block_model(blockmodel) as bm:
    
        # Confirm that model has been opened.
        # Script ends with the following message if not.
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # Returns 0 if successful, 1 otherwise.
        state = bm.find_xy_seam(pt[0].x, pt[0].y, 'bd')
        print(state)
    
    get(self, name) -> float
    get(self, k) -> float

    Get the numeric value of a variable, either by name or by index.

    Parameters

    • The name of the variable.

    • The index of the variable.

    Returns the value of the variable.

    # Filename: bm_get.py
    # Purpose: Get the value of a numeric block model variable.
    # Returns: Float
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    input_var = 'au_id'  # input variable
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # create lists to hold values
        value_by_name = []
        value_by_index = []
    
        # method 1: get values using variable name
        for block in bm:  # iterate through block model
            nval = bm.get(input_var)  # get value using name
            value_by_name.append(nval)  # add to list
    
        # method 2: get values using variable index
        for block in bm:  # iterate through block model
            index = bm.get_variable_index(input_var)  # get index of the variable
            ival = bm.get(index)  # get value using index
            value_by_index.append(ival)  # add to list
    
        # print values of each list side by side to show they are identical
        for i, (n_value, i_value) in enumerate(zip(value_by_name, value_by_index)):
            print(f'Index {i}: {i_value}   Name value: {n_value}')
    
    
    get_data( self, var, sel=None) -> numpy.array

    Gets the values of a set of blocks, or all blocks if no selection is provided.

    Parameters

    • Variable to get data from.

    • List of block indices to get from such as the return from.

    Returns a NumPy array of all values for the specified variable.

    Tip:  It can be helpful to use this function with the function get_matches().

    # Filename: bm_get_matches.py
    # Purpose: Get the blocks that match the given match arguments.
    # Returns: numpy.ndarray[Int64] - The indexes of the matched blocks.
    
    from maptek import vulcan
    
    blockmodel = 'example.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'blockmodel is not open.'
    
        matches = bm.get_matches('''-C "rocktype eqs 'oxide'"''')
        data = bm.get_data('au', matches)  # get variable information
    
        print(data)
    
    get_grid( self, var ) -> numpy.array

    Returns a 3D i/j/k grid of block model values for a regular block model.

    Parameters

    • Variable name.

    Returns 3D numpy array with block values in i/j/k or x/y/z order

    # Filename: bm_get_grid.py
    # Purpose: Get a 3D i/j/k grid of block model values for a regular block model.
    # Returns: Returns 3D numpy array with block values in i/j/k or x/y/z order.
    
    from maptek import vulcan
    
    blockmodel = 'vein_halo_reg.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        numpy_vals = bm.get_grid('class')  # get values using name
        print(numpy_vals)
    
    
    get_matches(self, match_string) -> numpy.ndarray[Int64]

    Get the blocks that match the given match arguments.

    Parameters

    • The selection criteria string.

    Option Description

    -v <variable> [value]

    Mask with variable.

    -t <triangulation>

    Bounding triangulation. Blocks with centroids inside the triangulation will be selected. The -X option may be applied to select based on block extents.

    -n <top surface>

    Top bounding surface triangulation.

    -u <lower surface>

    Lower bounding surface triangulation.

    -B <triangulation>

    Use single bounding surface

    -Z

    Project down Z axis. Requires -B.

    -O

    Select blocks outside the solid only.

    -bm <xl, xt, yl, yt, zl, zt>

    Define the bounding extents using block model coordinates. When using this switch, you will need to specify the minimum and maximum X, Y and Z coordinates. Blocks having extents that are inside, or intersect these extents are selected.

    -bw <xl, xt, yl, yt, zl, zt>

    Define the bounding extents using real world coordinates. When using this switch, you will need to specify the minimum and maximum X, Y and Z coordinates. Blocks having centroids that are inside the extents are selected. The -X option may be used to reproduce the extents intersection type selection of -bm.

    -s <mx, my, mz>

    Sub-block dimensions.

    -p <a, b, c, d>

    Include planed blocks.

    -C <condition>

    Use conditional expression.

    -r <offset>

    Provide a plane offset buffer.

    -X

    Use proportional volumes against solid. This modifies the block selection to include blocks that intersect the selecting volume.

    -T

    Use selection file with triangulations.

    -S

    Reverse block selection

    Returns the indexes of the matched blocks.

    # Filename: bm_get_matches.py
    # Purpose: Get the blocks that match the given match arguments.
    # Returns: numpy.ndarray[Int64] - The indexes of the matched blocks.
    
    from maptek import vulcan
    
    blockmodel = 'example.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'blockmodel is not open.'
    
        matches = bm.get_matches('''-C "rocktype eqs 'oxide'"''')
        data = bm.get_data('au', matches)  # get variable information
    
        print(data)
    
    get_matches_extent(self, match_string) -> tuple[numpy.ndarray]

    Get a list of NumPy arrays containing the block IDs and extents of each block selected in the match.

    Parameters

    • The selection criteria string.

    Option Description

    -v <variable> [value]

    Mask with variable.

    -t <triangulation>

    Bounding triangulation. Blocks with centroids inside the triangulation will be selected. The -X option may be applied to select based on block extents.

    -n <top surface>

    Top bounding surface triangulation.

    -u <lower surface>

    Lower bounding surface triangulation.

    -B <triangulation>

    Use single bounding surface

    -Z

    Project down Z axis. Requires -B.

    -O

    Select blocks outside the solid only.

    -bm <xl, xt, yl, yt, zl, zt>

    Define the bounding extents using block model coordinates. When using this switch, you will need to specify the minimum and maximum X, Y and Z coordinates. Blocks having extents that are inside, or intersect these extents are selected.

    -bw <xl, xt, yl, yt, zl, zt>

    Define the bounding extents using real world coordinates. When using this switch, you will need to specify the minimum and maximum X, Y and Z coordinates. Blocks having centroids that are inside the extents are selected. The -X option may be used to reproduce the extents intersection type selection of -bm.

    -s <mx, my, mz>

    Sub-block dimensions.

    -p <a, b, c, d>

    Include planed blocks.

    -C <condition>

    Use conditional expression.

    -r <offset>

    Provide a plane offset buffer.

    -X

    Use proportional volumes against solid. This modifies the block selection to include blocks that intersect the selecting volume.

    -T

    Use selection file with triangulations.

    -S

    Reverse block selection

    Returns

    The extents of the matched blocks, in the form a tuple of 7 NumPy arrays, where the first array is the list of IDs, the second is the list of minimum X values, etc.

    # Filename: bm_get_matches_extent.py
    # Purpose: Get a list of NumPy arrays containing the block IDs and extents
    #          of each block selected in the match.
    # Returns: tuple[numpy.ndarray]
    #          The extents of the matched blocks, in the form
    #          tuple[[id], [Xmin], [Xmax], [Ymin], [Ymax], [Zmin], [Zmax]].
    #          That is, a tuple of 7 NumPy arrays, where the first array is the
    #          list of IDs, the second is the list of minimum X values etc.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # Get list using variable: '-v <variable> [value]'
        numpy_vals = bm.get_matches_extent('-v ore_zone ore')
        print(numpy_vals)
    
    get_multiple(self, fields) -> list

    Get the values of a list of numeric variables.

    Parameters

    • List of numeric variables

    Returns a list of numeric variables.

    # Filename: bm_get_multiple.py
    # Purpose: Get the values of a list of numeric variables.
    # Returns: List.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    input_vars = ['au_id', 'au_ok', 'au_nn']  # input variables
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # iterate through block model
        for block in bm:
            vals = bm.get_multiple(input_vars)  # get value using name
            pos = bm.get_position()
            print(f'{pos}  {vals}')
    
    
    get_multiple_string(self, fields) -> list

    Get the values of a list of string variables.

    Parameters

    • List of string variables

    Returns a list of string variables.

    # Filename: bm_get_multiple_string.py
    # Purpose: Get the values of a list of string variables.
    # Returns: List.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    input_vars = ['geology', 'flag', 'ore_zone', 'class']  # input variables
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # iterate through block model
        for block in bm:
            vals = bm.get_multiple_string(input_vars)  # get value using name
            print(f'{vals}')
    
    
    get_pandas( self, vars=None, select=None ) -> pandas.DataFrame

    Gets block model data as a pandas.DataFrame.

    Parameters

    • Variable list to get from model. All variables if None

    • Selection string to use. Defaults to all blocks.

    # Filename: bm_get_pandas.py
    # Purpose: Gets block model data as a pandas.DataFrame
    # Returns: pandas.DataFrame
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        vals = bm.get_pandas()  # get values using default setting
        print(vals)
    
    get_pandas_extent( self, vars=None, select=None ) -> pandas.DataFrame

    Gets all matches within an extent.

    Parameters

    • Variable list to get from model. All variables if None

    • Selection string to use. Defaults to all blocks.

    Returns block model within the match extent.

    # Filename: bm_get_pandas_extent.py
    # Purpose: Gets all matches within an extent.
    # Returns: pandas.DataFrame
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        vals = bm.get_pandas_extent()  # get values using default setting
        print(vals)
    
    get_regular_indices(self) -> numpy.ndarray[Int64]

    Get the indices of a regular block model, in i/j/k order.

    Returns the indices of the blocks.

    # Filename: bm_get_regular_indices.py
    # Purpose: Get the indices of a regular block model, in i/j/k order.
    # Returns: The indices of the blocks as numpy array
    
    from maptek import vulcan
    
    blockmodel = 'vein_halo_reg.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        vals = bm.get_regular_indices()  # get values using default setting
        print(vals)
    
    get_string(self, name) -> string
    get_string(self, k) -> string

    Get the string value of a variable, either by name or by index.

    Parameters

    • The name of the variable.

    • The index of the variable.

    Returns the value of the variable.

    # Filename: bm_get_string.py
    # Purpose: Get the value of a string block model variable.
    # Returns: String.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    input_var = 'geology'  # input variable
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # create lists to hold values
        value_by_name = []
        value_by_index = []
    
        # method 1: get values using variable name
        for block in bm:  # iterate through block model
            nval = bm.get_string(input_var)  # get value using name
            value_by_name.append(nval)  # add to list
    
        # method 2: get values using variable index
        for block in bm:  # iterate through block model
            index = bm.get_variable_index(input_var)  # get index of the variable
            ival = bm.get_string(index)  # get value using index
            value_by_index.append(ival)  # add to list
    
        # print values of each list side by side to show they are identical
        for i, (n_value, i_value) in enumerate(zip(value_by_name, value_by_index)):
            print(f'Index {i}: {i_value}   Name value: {n_value}')
    
    
    get_translation_values(self, field_name) -> list

    Get the translation values for a field.

    This provides the mapping from the values as integers (indices) to string values. Using get_string() will translate the value for a single block to its corresponding string, where as this function allows bulk-translation of the underlying values.

    This is especially useful for large models, where calling get_data_string() may use large amounts of memory. By extracting the data as an integer rather than a string, much less memory is required.

    Parameters

    • The field to get the translation values for.

    Returns the translation values.

    # Filename: bm_get_translation_values.py
    # Purpose: Get the translation values for a field.
    # Returns: The translation values.
    
    from maptek import vulcan
    
    selection = bm.get_matches()
    var = 'region'
    numeric_values = bm.get_data_int64(var, selection)
    translation_values = bm.get_translation_values(var)
    print(numeric_values, translation_values)
    for value in numeric_values:
    	print(translation_values[value])
    
    get_variable_index(self, name) -> int

    Get the index of a variable.

    Parameters

    • The variable index.

    Returns the index of the variable.

    # Filename: bm_get_variable_index.py
    # Purpose: Get the index of a variable.
    # Returns: Integer.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    input_var = 'geology'  # input variable
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        value = bm.get_variable_index(input_var)  # get variable index number
        print(value)  # print results
    
    
    index_model(self) -> int

    Build the index for the block model.

    Returns 0 if successful, 1 otherwise.

    # Filename: bm_index_model.py
    # Purpose: Build the index for the block model..
    # Returns: Null.
    
    from maptek import vulcan
    
    # Open block model
    with vulcan.block_model() as bm:
        verify_index = bm.index_model()
    	if verify_index == 0:
    		print("Block model has been indexed.")
    	else:
    		print("Block model has not been indexed.")
    
    is_field(self, field) -> bool

    Check if the given variable exists on the block model.

    Parameters

    • The variable to check for existence.

    Returns true if the variable exists, False otherwise.

    # Filename: bm_is_field.py
    # Purpose: Verify that the input variabls exists.
    # Returns: Bool.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    input_var = 'geology'  # input variable
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # verify variable exists; True = yes, False = no
        value = bm.is_field(input_var)
        print(value)  # print results
    
    
    is_indexed(self) -> int

    Check whether the block model is indexed.

    Returns 1 if the model is indexed, 0 otherwise.

    # Filename: bm_is_indexed.py
    # Purpose: Check if the model is indexed.
    # Returns: '1' if yes, '0' if no.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        verify_index = bm.is_indexed()  # check if the block model is indexed
        print(f"{verify_index}")
    
    
    is_number(self, field) -> bool

    Check if the given variable exists as a numeric variable in the block model.

    Parameters

    • The variable to check exists and is numeric.

    Returns True if the variable exists and is numeric, False otherwise.

    # Filename: bm_is_number.py
    # Purpose: Check if variable type is numeric.
    # Returns: Bool.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    input_var = 'geology'  # input variable
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # check if variable type is numeric; True = yes, False = no
        value = bm.is_number(input_var)
        print(value)  # print results
    
    
    is_open(self) -> bool

    Check if given block model is open.

    Returns True if the variable exists and is numeric, False otherwise.

    # Filename: bm_is_open.py
    # Purpose: Check if a block model is open.
    # Returns: Bool.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # another way storing value in variable
        value = bm.is_open()
        print(value)  # print results
    
    
    is_regular(self) -> bool

    Check if the model is a regular model.

    Returns True if the model is a regular model, False if the model is irregular.

    # Filename: bm_is_regular.py
    # Purpose: Check if a block model is regularised.
    # Returns: Bool.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # Check if a block model is regularised. True = yes, False = no
        value = bm.is_regular()
        print(value)  # print results
    
    
    is_string(self, field) -> bool

    Check if the given variable exists as a string variable on the block model.

    Parameters

    • The variable to check if it exists as a string variable.

    Returns True if the field exists and is a string field, False otherwise.

    # Filename: bm_is_string.py
    # Purpose: Check if variable type is string.
    # Returns: Bool.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    input_var = 'geology'  # input variable
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # check if variable type is string; True = yes, False = no
        value = bm.is_string(input_var)
        print(value)  # print results
    
    
    is_tb_model(self) -> bool

    Check if the model is an extended format model.

    Note:  All new models are extended (TB) models.

    Returns True if the model is an extended (TB) model, False otherwise.

    # Filename: bm_is_tb_model.py
    # Purpose: Check if a block model is an extended model.
    # Returns: Bool.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # Check if a block model is an extended model. True = yes, False = no
        value = bm.is_tb_model()
        print(value)  # print results
    
    
    match_extent(self) -> list

    Get the extent of the current match selection.

    # Filename: bm_match_extent.py
    # Purpose: Get the block extent of the current position.
    # Returns: List.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # iterate through model
        for block in bm:
            bm_extents = bm.match_extent()  # get list of block extents
            print(bm_extents)  # print results
    
    
    match_volume(self) -> float

    Calculates the volume of the current match selection.

    Returns the calculated volume.

    # Filename: bm_match_volume.py
    # Purpose: Get the block volume of the current position.
    # Returns: List.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # iterate through model
        for block in bm:
            bm_extents = bm.match_volume()  # get list of block extents
            print(bm_extents)  # print results
    
    
    model_extent(self) -> list

    Returns list in the form [Xmin, Ymin, Zmin, Xmax, Ymax, Zmax] where the min values are the coordinates of the lower extent, and the max values are the coordinates of the upper extent.

    # Filename: bm_model_extent.py
    # Purpose: Get the extent of the model.
    # Returns: List.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        bm_extents = bm.model_extent()  # create list of model extents
        print(bm_extents)  # print results
    
    
    model_n_schemas(self) -> int

    Get the number of schemas associated with the model.

    Returns the number of schemas.

    # Filename: bm_model_n_schemas.py
    # Purpose: Get the number of schemas used in block model.
    # Returns: Integer.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        bm_num_schemas = bm.model_n_schemas()  # get number of schemas used
        print(bm_num_schemas)  # print results
    
    
    model_orientation(self) -> list

    Get the orientation of the model.

    Returns the amount of rotation (in degrees) for each axis, in the form [X, Y, Z]

    # Filename: bm_model_orientation.py
    # Purpose: Create list showing bearing, dip, and plunge of a block model.
    # Returns: List.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        orientation = bm.model_orientation()  # get the orientation
        print(f"bearing, dip, plunge = {orientation}")
    
    
    model_origin(self) -> list

    Get the origin of the model.

    Returns the origin coordinates, in the form [X, Y, Z]

    # Filename: bm_model_origin.py
    # Purpose: Create list of block model origin [x,y,z]
    # Returns: List.
    
    from maptek import vulcan
    
    blockmodel = 'irregular.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        origin = bm.model_origin()  # get the origin
        print(f"origin x, y, z = {origin}")
    
    
    model_schema_extent(self, k) -> list

    Get the extent of a schema within the model.

    Parameters

    • The index of the schema to get the extent of.

    Returns list in the form [Xmin, Ymin, Zmin, Xmax, Ymax, Zmax] where the min values are the coordinates of the lower extent, and the max values are the coordinates of the upper extent.

    # Filename: bm_model_schema_extent.py
    # Purpose: Create list of schema extents.
    # Returns: List.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        p_extent = bm.model_schema_extent(0)  # get the extent for parent blocks
        sub_extent = bm.model_schema_extent(1)  # get the extent for sub blocks
        print(f"parent block extent = {p_extent}")
        print(f"sub block extent = {sub_extent}")
    
    
    model_schema_dimensions(self, k) -> list

    Get the dimensions of a schema within the model.

    Parameters

    • The index of the schema to get the dimensions of.

    Returns the dimensions of the schema, in the form [X, Y, Z]

    # Filename: bm_model_schema_dimensions.py
    # Purpose: Get the dimensions of a schema within the model.
    # Returns: List.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        bm_schema_dim = bm.model_schema_dimensions(1)  # get dimensions of a schema
        print(bm_schema_dim)  # print results
    
    model_schema_size(self, k) -> list

    Get the size of a schema within the model.

    Parameters

    • The index of the schema to get the size of.

    Returns the size of the schema, in the form [x size, y size, z size, x max, y max, z max].

    # Filename: bm_model_schema_size.py
    # Purpose: Create list of schema size.
    # Returns: List.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model io stream
        pb_size = bm.model_schema_size(0)  # get the extent for parent blocks
        sub_size = bm.model_schema_size(1)  # get the extent for parent blocks
        print(f"list order:        [x size, y size, z size, x max, y max, z max]")
        print(f"parent block size: {pb_size}")
        print(f"sub block size:    {sub_size}")
    
    
    modified_date(self) -> string

    Check when the block model was last modified.

    Returns the date of the last modification.

    # Filename: bm_modified_date.py
    # Purpose: Get the most recent modification date of a block model.
    # Returns: String.
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model io stream
        last_modified = bm.modified_date()  # get the modification date
        print(f"{last_modified}")
    
    

    Returns 0 if successful, 1 otherwise.

    Raises PermissionError if the block model is open in read only mode.

    n_blocks(self) -> int

    Get the number of blocks in the model.

    Returns the number of blocks.

    # Filename: bm_n_blocks.py
    # Purpose: Get the number of blocks in a block model.
    # Returns: Integer.
    
    from maptek import vulcan
    
    blockmodel = 'example.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open the block model io stream
        num_blocks = bm.n_blocks()  # get the number of blocks
        print(f"{num_blocks}")
    
    
    pop_select(self) -> int

    Remove the most recent selection from the selection stack.

    Returns 0 if successful, 1 if there is nothing to remove.

    put(self, name: 'str', v: 'str | float | int')

    Set the value of a field, either by name or by index.

    Parameters

    • name (str) – The name of the field to set the value of.

    • k (int) – The index of the field to set the value of.

    • v (float or str) – The value to set.

    Raises PermissionError – If the block model is open in read only mode.

    put_data( self, var: str, data: numpy.ndarray, sel: list[int] = None)

    Stores the values of a numpy array into the block model.

    Parameters

    • variable (str) – Variable to get data from

    • data (numpy.array) – Data to be stored

    • sel (list[int]) – List of block indices to store to such as the return from block_model.get_matches()

    Example

    matches = bm.get_matches('''-C "rocktype eq 'oxide'"''')

    bm.put_data("au", data, matches)

    put_data_double(name: str, n1: numpy.ndarray[numpy.double], n0: list[numpy.int64]) -> int

    Store double data in the block model. It is recommended to use put_data() instead.

    Parameters

    • name (str) – The variable to put the data into.

    • data (numpy.ndarray[double]) – The data to store.

    • sel (list[Int64]) – The IDs of blocks to put data into. This could be the result of get_matches() or ‘numpy.arrange(bm.n_blocks())’ for all blocks

    • length. (Note that 'data' and 'sel' MUST have the same) –

    Returns 0 if successful, 1 otherwise.

    Raises NameError – If the variable doesn’t exist.

    put_data_float(name: str, n1: numpy.ndarray[float], n0: list[numpy.int64]) -> int

    Store float data in the block model. It is recommended to use put_data() instead.

    Parameters

    • name (str) – The variable to put the data into.

    • data (numpy.ndarray[float]) – The data to store.

    • sel (list[Int64]) – The IDs of blocks to put data into. This could be the result of get_matches() or ‘numpy.arrange(bm.n_blocks())’ for all blocks

    • length. (Note that 'data' and 'sel' MUST have the same) –

    Returns 0 if successful, 1 otherwise.

    Raises NameError – If the variable doesn’t exist.

    put_data_string(var: str, data: numpy.ndarray, sel: list[int] = None)

    Stores numpy string array to a block model string variable.

    Parameters

    • var (str) – Variable name to write to.

    • data (numpy.array) – NumPy array with string data

    • sel (list) – Selection of block indices to write to (from get_matches())

    put_data_string_list(self, name, data, n0) -> int

    Store string data in the block model.

    Parameters

    • name (str) – The variable to put the data into.

    • data (numpy.ndarray[str]) – The data to store.

    • sel (list[Int64]) – The IDs of blocks to put data into. This could be the result of get_matches() or ‘numpy.arrange(bm.n_blocks())’ for all blocks

    • length. (Note that 'data' and 'sel' MUST have the same) –

    Returns 0 if successful, 1 otherwise.

    Raises NameError – If the variable doesn’t exist.

    put_grid( self, var, data) put_grid(self, name, data)

    Stores a 3D i/j/k grid of values into a regular block model.

    Parameters

    • var (str) – Variable name to get data for.

    • data (numpy.array) – 3D numpy array of block model values for all blocks

    put_pandas( self, dataframe, vars=None )

    Puts a Pandas dataframe into the block model.

    Parameters

    • dataframe (pandas.DataFrame) – DataFrame with block model data

    • vars (list[str], optional) – Variables to update. DataFrame columns used when no var list is provided.

    put_string(self, *args)

    Set the value of a string field, either by name or by index.

    Parameters

    • name (str) – The name of the field to set the value of.

    • v (str) – The value to set.

    Raises PermissionError – If the block model is open in read only mode.

    rotate(self, x, y, z) -> int

    Rotate the block model about its origin.

    This operation is additive, i.e.

    block_model.rotate(0.0, 10.0, 0.0)
    block_model.rotate(5.0, 0.0, 0.0)

    is the same as

    block_model.rotate(5.0, 10.0, 0.0)

    Parameters

    • x (float) – The amount (in degrees) to rotate the model in the X axis.

    • y (float) – The amount (in degrees) to rotate the model in the Y axis.

    • z (float) – The amount (in degrees) to rotate the model in the Z axis.

    Raises PermissionError – If the block model is open in read only mode.

    scale(self, x, y, z) -> int

    Multiplicatively scale the block model size.

    Parameters

    • x (float) – The amount (in degrees) to rotate the model in the X axis.

    • y (float) – The amount (in degrees) to rotate the model in the Y axis.

    • z (float) – The amount (in degrees) to rotate the model in the Z axis.

    Raises PermissionError – If the block model is open in read only mode.

    select(self, selection) -> int

    Specify block selection criteria for a block model.

    Note:  Each instance of using this function will overwrite any previous selection on the same level.

    Parameters

    • The selection criteria string.

    Option Description

    -v <variable> [value]

    Mask with variable.

    -t <triangulation>

    Bounding triangulation. Blocks with centroids inside the triangulation will be selected. The -X option may be applied to select based on block extents.

    -n <top surface>

    Top bounding surface triangulation.

    -u <lower surface>

    Lower bounding surface triangulation.

    -B <triangulation>

    Use single bounding surface

    -Z

    Project down Z axis. Requires -B.

    -O

    Select blocks outside the solid only.

    -bm <xl, xt, yl, yt, zl, zt>

    Define the bounding extents using block model coordinates. When using this switch, you will need to specify the minimum and maximum X, Y and Z coordinates. Blocks having extents that are inside, or intersect these extents are selected.

    -bw <xl, xt, yl, yt, zl, zt>

    Define the bounding extents using real world coordinates. When using this switch, you will need to specify the minimum and maximum X, Y and Z coordinates. Blocks having centroids that are inside the extents are selected. The -X option may be used to reproduce the extents intersection type selection of -bm.

    -s <mx, my, mz>

    Sub-block dimensions.

    -p <a, b, c, d>

    Include planed blocks.

    -C <condition>

    Use conditional expression.

    -r <offset>

    Provide a plane offset buffer.

    -X

    Use proportional volumes against solid. This modifies the block selection to include blocks that intersect the selecting volume.

    -T

    Use selection file with triangulations.

    -S

    Reverse block selection

    Returns 0 if successful, 1 otherwise.

    # Filename: bm_select.py
    # Purpose: Specify block selection criteria for a block model.
    # Returns: Integer (0 if successful, 1 otherwise.)
    
    from maptek import vulcan
    
    blockmodel = 'demo_vein.bmf'  # input block model
    input_var = 'flag'  # use this variable
    
    # open the block model
    with vulcan.block_model(blockmodel) as bm:
        assert bm.is_open(), 'f"{blockmodel} is not open."'
    
        # select all blocks within vein solid
        bm.select('-t TQ1.00t')  # select initial solid
    
        for block in bm:  # iterate through selected blocks
            bm.put(input_var, 'ore')  # flag as ore
    
    
    select_xy_seam(x: float, y: float, seam: str) -> int

    Set the selection to match blocks with the given seam in an xy grid square.

    Parameters

    • x (float) – The X coordinate to find blocks to match.

    • y (float) – The Y coordinate to find blocks to match.

    • seam (str) – The seam to match blocks against.

    Returns 0 if successful, 1 otherwise.

    set_model_orientation(a1: float, a2: float, a3: float) -> int

    Set the orientation of the model.

    Parameters

    • a1 (float) – The amount of rotation (in degrees) in the Z direction.

    • a2 (float) – The amount of rotation (in degrees) in the X direction.

    • a3 (float) – The amount of rotation (in degrees) in the Y direction.

    Returns 0 if successful, 1 otherwise.

    Raises PermissionError – If the model is open in read only mode.

    set_model_origin(x0: float, y0: float, z0: float) -> int

    Set the origin of the model.

    Parameters

    • x0 (float) – The X coordinate to set.

    • y0 (float) – The Y coordinate to set.

    • z0 (float) – The Z coordinate to set.

    Returns 0 if successful, 1 otherwise.

    Raises PermissionError – If the model is open in read only mode.

    to_model(x: float, y: float, z: float) -> list[float]

    Convert a set of real world coordinates to model coordinates.

    Parameters

    • x (float) – The X coordinate to convert.

    • y (float) – The Y coordinate to convert.

    • z (float) – The Z coordinate to convert.

    Returns the converted coordinates, in the form [X, Y, Z].

    to_model(self, p) -> Point_type

    Convert a set of real world coordinates to model coordinates.

    Parameters

    • The X,Y,Z coordinate to convert as float.

    • point object.

    Returns the converted coordinates, in the form [X, Y, Z].

    # Filename: bm_to_model.py
    # Purpose: Convert a set of real world coordinates to model coordinates.
    # Returns: list[float] The converted coordinates in the form [X, Y, Z].
    
    from maptek import vulcan
    
    blockmodel = 'example.bmf'  # input block model
    
    with vulcan.block_model(blockmodel) as bm:  # open block model
        mod_coords = bm.to_model(77920.0, 4370.0, 0.0)  # get model coordinates
        print(mod_coords)
    
    
    to_world(x: float, y: float, z: float)→ list[float]

    Convert a set of model coordinates to real world coordinates.

    Parameters

    • x (float) – The X coordinate to convert.

    • y (float) – The Y coordinate to convert.

    • z (float) – The Z coordinate to convert.

    Returns the converted coordinates, in the form [X, Y, Z].

    translate(self, x, y, z) ->

    Translate a block model.

    Parameters

    • X,Y,Z translation distances.

    Returns Null.

    # Filename: bm_translate.py
    # Purpose: Translate a block model.
    # Returns: None.
    
    from maptek import vulcan
    
    blockmodel = 'example.bmf'  # input block model
    
    with vulcan.block_model(blockmodel, 'w') as bm:  # open model in write mode
        bm.translate(100.0, 0.0, 0.0)  # enter xyz translation distances
    
    
    write(self) -> int

    Write pending block changes to disk.