maptek.vulcan.triangulation

The following functions can be used to edit Vulcan triangulations and manipulate properties.

To download all the example scripts on this page, click Python Triangulation Example Scripts.


class faces(object):

Generator to move through each facet of a triangulation.

# Filename: tri_class_faces.py
# Purpose: A generator to move through each facet of a triangulation.
# Returns: A list of node indices for each facet.

from maptek import vulcan

input_tri = 'cube.00t'  # input tri

with vulcan.triangulation(input_tri) as tri:  # Open triangulation in read mode
    for face in tri.faces:
        print(face)

class nodes(object):

Generator to move through each node of a triangulation.

# Filename: tri_class_nodes.py
# Purpose: A generator to move through each node of a triangulation.
# Returns: A list of X, Y, Z coordinates for each node.

from maptek import vulcan

input_tri = 'headframe.00t'  # input tri

with vulcan.triangulation(input_tri) as tri:  # Open triangulation in read mode
    for node in tri.nodes:
        print(node)

add_face(triangulation self, int n1, int n2, int n3) -> int
add_node(triangulation self, double x, double y, double z) -> int

Add a facet / node to the triangulation, and returns the index number of that facet or node.

Note:  In the example below, a facet was added to an existing triangulation. Two of the nodes already existed as part of the triangulation. The third node index was created when add_node() was called, then pass to the variable called n.

# Filename: tri_add_face.py
# Purpose: Add a facet to a triangulation.
# Returns: Facet index as int.

from maptek import vulcan

existing_tri = 'headframe.00t'

with vulcan.triangulation(existing_tri, 'w') as tri:
    n = tri.add_node(77846.0, 4925.0, 103.5) # add node and get its index
    tri.add_face(0, 1, n)

append_faces(triangulation self, n0: int) -> void
append_vertices(triangulation self, n0: int) -> void

Appends a NumPy array of facets/nodes to a triangulation.

The append_faces method passes a 2D NumPy array with each element containing the three nodes used for each facet.

The append_vertices method passes a 2D NumPy array with each element containing the X,Y,Z coordinates of each vertex (node).

# Filename: tri_append_faces.py
# Purpose: Use NumPy array to create triangulation.
# Returns: None.

from maptek import vulcan
import numpy as np

new_tri = 'facet.00t'
with vulcan.triangulation(new_tri, 'w') as tri:
    # create NumPy arrays
    nodes = np.array([[77300.0, 4600.0, 0.0],
                      [77600.0, 4600.0, 0.0], 
                      [77300.0, 4600.0, 300.0]])
    faces = np.array([[0,1,2]])
    tri.append_vertices(nodes)
    tri.append_faces(faces)
    
vulcan_gui.load_triangulation(new_tri)

centroid(triangulation self) -> point

Gets the centroid of a triangulation.

# Filename: tri_centroid.py
# Purpose: Find the centroid of a triangulation.
# Returns: Point.

from maptek import vulcan

input_tri = 'topo.00t'  # input triangulation

with vulcan.triangulation(input_tri) as tri:  # open triangulation in read mode
    centroid = tri.centroid()  # get the centroid of the given triangulation
    
    # do something...
    print(f"{centroid}")

clean(triangulation self) -> void

Cleans a triangulation, trying to remove consistency and crossing errors.

# Filename: tri_clean.py
# Purpose: Attempt to clean triangulation consistency and crossing errors.
# Returns: None.

from maptek import vulcan

input_tri = 'topo.00t' # input tri
with vulcan.triangulation(input_tri, 'w') as tri:
    tri.clean()

clear(triangulation self) -> void

Clears all data from the triangulation, including all points, triangles, attributes, etc. This function is used to reset a triangulation by removing all the data.

Note:  This function clears triangles so a new triangulation surface can be created. Empty triangulations will not save.

# Filename: tri_clear.py
# Purpose: Clears all triangle data.
# Returns: None.

from maptek import vulcan

existing_tri = 'headframe.00t'

with vulcan.triangulation(existing_tri, 'w') as tri:
    tri.clear() # removes all triangle data from triangulation
    
    # Do something to make it a valid triangulation so that it can be saved.
    # In this case, a simple facet is added.
    n1 = tri.add_node(77700.0, 4625.0, 100.0) # add node and get its index
    n2 = tri.add_node(77846.0, 4750.0, 110.0) # add node and get its index
    n3 = tri.add_node(77920.0, 4875.0, 103.5) # add node and get its index
    tri.add_face(n1, n2, n3)
    tri.save()

clear_triangles(triangulation self) -> void

Clears all triangle data, leaving attributes intact. This function could be used to copy an existing triangulation, clear out the points, make a new shape, then update the required attributes while leaving the rest intact. For example, building numerous stope solids, you could copy a base set of attributes such as level, mining area, etc., then input each stope's new points/vertices.

Note:  This function clears triangles and all attributes so a new triangulation surface can be created. Empty triangulations will not save.

# Filename: tri_clear_triangles.py
# Purpose: Clears all triangle data, leaving attributes intact.
# Returns: None.

from maptek import vulcan

input_tri = 'headframe.00t'

with vulcan.triangulation(input_tri, 'w') as tri:
    tri.clear_triangles() # removes all triangle data from triangulation
    
    # Do something to make it a valid triangulation so that it can be saved.
    # In this case, a simple facet is added.
    n1 = tri.add_node(77700.0, 4625.0, 100.0) # add node and get its index
    n2 = tri.add_node(77846.0, 4750.0, 110.0) # add node and get its index
    n3 = tri.add_node(77920.0, 4875.0, 103.5) # add node and get its index
    tri.add_face(n1, n2, n3)
    tri.save()

close(triangulation self) -> bool

Attempts to close a solid triangulation. This is the same operation as right-clicking on a triangulation and selecting Close Solid.

# Filename: tri_close.py
# Purpose: Attempts to close an open triangulation.
# Returns: Bool.

from maptek import vulcan

input_tris = ['TQ1.00t', 'TQ2.00t','TQ3.00t','headframe.00t']

for solid in input_tris:
    with vulcan.triangulation(solid,'w') as tri:
        # check closure state    
        if tri.is_closed():
            print(f"{solid}: 'Closed'")
        else:
            print(f"{solid}: 'Not closed, attempting to close.'")
            tri.close()
            if tri.is_closed():
                print(f"{solid}: 'Closed'")
            else:
                print(f"{solid}: 'Could not close solid'")

contour(triangulation self, double z) -> obj_list

Gets the contours of a triangulation at a specified Z elevation.

# Filename: tri_contours.py
# Purpose: Gets the contours of a triangulation at a specified Z elevation.
# Returns: Object list.

from maptek import vulcan

input_tri = 'topo.00t'
dgd_file = "pydemo.dgd.isis"  # design database
layer_name = "CONTOUR_150"  # layer to access

# read in triangulation and get contours at z-value.
with vulcan.triangulation(input_tri) as tri: 
    contour_list = tri.contour(150.0) # z-value or elevation

# create layer using contours
with vulcan.dgd(dgd_file, "w") as dgd:
    assert not dgd.is_layer(layer_name), "Error: Layer already exists."
    layer = vulcan.layer(layer_name)
    for obj in contour_list:
        layer.append(obj)  # add line into the layer
    dgd.save_layer(layer)

delete_face(triangulation self, facet index number, bool purge_points=False) -> void

Deletes a facet from the triangulation. (Optional) Purges points no longer used.

# Filename: tri_delete_face.py
# Purpose: Delete facet of a triangulation and purge nodes no longer used.
# Returns: None.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation
face_index = 0 # index of facet to delete

with vulcan.triangulation(input_tri, 'w') as tri: # Open triangulation in write mode.
    tri.delete_face(face_index, True) # Delete facet and nodes no longer used.
    # To keep the nodes, change True -> False.

delete_node(triangulation self, node index number) -> void

Deletes a node from the triangulation.

# Filename: tri_delete_node.py
# Purpose: Delete node of a triangulation.
# Returns: None.

from maptek import vulcan

input_tri = 'headframe.00t' # input tri
node_index = 0

with vulcan.triangulation(input_tri, 'w') as tri: # Open tri in write mode to change tri
    tri.delete_node(node_index) # delete node
    tri.save()

extent(triangulation self) -> 2D list

Get the triangulation extent as a list. This will return a list of the coordinates for the lower left and upper right corners of the extent perimeter.

Example:  [[x.y.z], [x,y,z]]

# Filename: tri_extent.py
# Purpose: Get the triangulation extent as a list.
# Returns: 2D list.

from maptek import vulcan

input_tri = 'topo.00t' # input tri

with vulcan.triangulation(input_tri) as tri: # Open tri to get information
    extent_list = tri.extent() # Get extent list

    # do something with list...
    print(extent_list)

extent_pts(triangulation self) -> point_list

Gets the triangulation extent as points. This will return a list of point information for the lower left and upper right corners of the extent perimeter.

Example:  (point(x,y,z,w,t,name), point(x,y,z,w,t,name))

# Filename: tri_extent_pts.py
# Purpose: Get triangulation extent as a list of points.
# Returns: Point list.

from maptek import vulcan

input_tri = 'topo.00t' # input tri

with vulcan.triangulation(input_tri) as tri: # Open tri to get information
    extent_list = tri.extent_pts() # Get extent list

    # do something with list...
    print(extent_list)

face_direction(triangulation self, facet index number) -> point

Gets the facet direction and returns a point as a unit vector.

# Filename: tri_face_direction.py
# Purose: Find the direction of a given face.
# Returns: Point as a unit vector.

from maptek import vulcan

input_tri = 'headframe.00t' # input tri

with vulcan.triangulation(input_tri) as tri: # Open triangulation in read mode
    face_dir = tri.face_direction(0) # pass facet index 0

    # do something with results...
    print(face_dir)

    # iterate through to find the directions of all facets
    for i, face in enumerate(tri.faces):
        face_dir = tri.face_direction(i) # pass facet index

        # do something with results...
        print(f"Facet index: {i}  {face_dir}")

face_neighborhood(triangulation self, facet index number) -> int_list

Get indices of neighbouring facets.

# Filename: tri_face_neighborhood.py
# Purpose: Get indices of neighbouring facets.
# Returns: List of integers.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri: # Open triangulation in read mode
    neighbour_facets = tri.face_neighborhood(10) # pass facet index

    # do something with list...
    print(neighbour_facets)

get_colour_index(triangulation self) -> int

Gets the triangulation colour (index).

# Filename: tri_get_colour_index.py
# Purpose: Get the colour index of a triangulation.
# Returns: Integer.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri: # open triangulation in read mode
    if tri.is_rgb(): # check if triangulation uses rgb or colour index
        print(f"error: triangulation uses RGB") # error if tri is rgb
    else:
        icolour = tri.get_colour_index() # get triangulation colour index

        # do something...
        print(icolour)

get_elevation(triangulation self, double x, double y) -> double

Gets the elevation of an x,y location.

# Filename: tri_get_elevation.py
# Purpose: Get the elevation of an x,y location.
# Returns: Double.

from maptek import vulcan

input_tri = 'headframe.00t' # input tri

with vulcan.triangulation(input_tri) as tri: # Open tri in read mode
    z = tri.get_elevations(77868, 4941) # pass X,Y coordinates

    # do something with results...
    print(f"Elevation: {z}")

get_elevations(triangulation self, double x, double y) -> double_list

Gets any intersection elevations of an x,y location.

# Filename: tri_get_elevations.py
# Purpose: Get the elevation of an x,y location.
# Returns: Elevation as list.

from maptek import vulcan

input_tri = 'headframe.00t' # input tri

with vulcan.triangulation(input_tri) as tri: # Open tri in read mode
    z_list = tri.get_elevations(77868, 4941) # pass X,Y coordinates

    # do something with list...
    print(f"Elevation: {z_list}")

get_face(triangulation self, facet index number) -> int_list

Gets a facet and its point indices by index.

# Filename: tri_get_face.py
# Purpose: Gets a facet and its point indices by index.
# Returns: The indices of facet points as a list.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri:
    node_indices = tri.get_face(0) # Get node indices of face.
    
    # do something with list of node indices...
    for node in node_indices:
        pt = tri.get_node(node) # The X, Y, Z coordinates of a node.
        print(pt)

get_faces(triangulation self) -> 2D array

Gets the facets of a triangulation as a NumPy array.

# Filename: tri_get_faces.py
# Purpose: Get faces of a triangulation.
# Returns: 2D NumPy array.

from maptek import vulcan

input_tri = 'headframe.00t'

with vulcan.triangulation(input_tri, 'w') as tri:
    faces = tri.get_faces()

    # do something with array...
    print(faces)

get_node(triangulation self, node index number) -> double_list

Creates list of x,y,z coordinates for the node of a triangulation.

# Filename: tri_get_node.py
# Purpose: Creates list of x,y,z coordinates for the node of a triangulation.
# Returns: List of node coordinates as doubles.

from maptek import vulcan

input_tri = 'cube.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri:
    node = tri.get_node(0) # pass node index

    # do something with list of node coordinates...
    print(node)

get_properties(triangulation self) -> dictionary

Create a dictionary of triangulation properties.

# Filename: tri_get_properties.py
# Purpose: Get the properties of a triangulation.
# Returns: Dictionary.

from maptek import vulcan

input_tri = 'cube.00t' # input tri

with vulcan.triangulation(input_tri) as tri: # Open tri to get information
    properties = tri.get_properties() # Get properties
    
    # do something with dictionary...
    for key, value in properties.items():
        print(str(key), ':', str(value))

get_rgb(triangulation self) -> int_list

Gets the triangulation colour (RGB).

# Filename: tri_get_rbg.py
# Purpose: Get the rgb value from a triangulation.
# Returns: List of integers.

from maptek import vulcan

tri = 'cube.00t' # input tri

with vulcan.triangulation(tri) as tri: # open tri as read
    assert tri.is_rgb(), 'Error: Triangulation is not rgb.'
    rgb = tri.get_rgb() # get rgb colour

    # do something with results...
    print(rgb)

get_translucency(triangulation self) -> double

Gets the triangulation translucency.

# Filename: tri_get_translucency.py
# Purpose: Get the translucency value from a triangulation.
# Returns: Double.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri: # open triangulation as read
    translucency = tri.get_translucency() # get translucency value

    # do something with results...
    print(translucency)

get_vertices(triangulation self) -> 2D array

Gets the node (vertex) coordinates of a triangulation as a NumPy array.

# Filename: tri-get_vertices.py
# Purpose: Get the vertices of a triangulation as NumPy array.
# Returns: 2D NumPy array.

from maptek import vulcan

input_tri = 'headframe.00t'

with vulcan.triangulation(input_tri) as tri: 
    vertices = tri.get_vertices()

    # do something with list...
    print(vertices)

is_closed(triangulation self) -> bool

Reports the triangulation closure state of a solid triangulation.

# Filename: tri_is_closed.py
# Purpose: Reports the closure state of a triangulation solid.
# Returns: Bool.

from maptek import vulcan

input_tri = 'cube.00t'

with vulcan.triangulation(input_tri,'r') as tri:
    state = tri.is_closed()

    # do something with results...
    print(state)

is_consistent(triangulation self) -> bool

Reports the existence of inconsistent triangles. Returns True if passed, False if it does not pass.

# Filename: tri_is_consistent.py
# Purpose: Returns true if there are inconsistent triangles.
# Returns: Bool.

from maptek import vulcan

input_tri = 'topo.00t' # input tri

with vulcan.triangulation(input_tri, 'r') as tri: # Open tri in read mode
    state = tri.is_consistent()    # Check for inconsistent triangles

    # do something with results...
    print(state)

is_crossing(triangulation self) -> bool

Runs check for crossing triangles. Returns True if triangles are crossing, False if no crossing.

# Filename: tri_is_crossing.py
# Purpose: Returns True if triangles are crossing.
# Returns: Bool.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation 

with vulcan.triangulation(input_tri) as tri: # Open triangulation in read mode
    state = tri.is_crossing() # Check for crossing

    # do something with results...
    print(state)

is_ok(triangulation self) -> bool

Reports the triangulation load status (true if new). This can be placed at the beginning of an operation to check that a triangulation was properly loaded.

# Filename: tri_is_ok.py
# Purpose: Check the load status of a triangulation.
# Returns: Bool.

from maptek import vulcan

input_tri = 'cube.00t'

with vulcan.triangulation(input_tri, 'w') as tri:
    if not tri.is_ok():
        raise ValueError("Triangulation open failed.")
        
    # continue if no error raised...

is_rgb(triangulation self) -> bool

Returns True if the triangulation color is RGB.

# Filename: tri_is_rgb.py
# Purpose: Return true if triagulation colour is rgb.
# Returns: Bool.

from maptek import vulcan

input_tri = 'cube.00t' # input tri

with vulcan.triangulation(input_tri) as tri: # open tri as read
    rgb = tri.is_rgb() # check if triangulation colour is rgb

    # do something with result...
    print(rgb)

load_grid(triangulation self, grid) -> void

Loads a grid into a triangulation.

Important:  If you use an existing triangulation it will be overwritten.

# Filename: tri_load_grid.py
# Purpose: Create a triangulation from an existing grid.
# Returns: None.

from maptek import vulcan

input_tri = 'topo_from_grid.00t' # name for resulting triangulation
input_grid = 'thortopo.00g'

grid = vulcan.grid(input_grid)
assert(grid.ok), 'Error: Grid did not load.'

with vulcan.triangulation(input_tri, 'w') as tri:
    tri.load_grid(input_grid)
    tri.save()

n_faces(triangulation self) -> int

Returns the number of facets in the triangulation.

# Filename: tri_n_faces.py
# Purpose: Get the number of facets in a triangulation.
# Returns: Integer.

from maptek import vulcan

input_tri = 'cube.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri:
    num_face = tri.n_faces() # get number of facets

    # do something...
    print(num_face)

n_nodes(triangulation self) -> int

Returns the number of nodes in the triangulation.

# Filename: tri_n_nodes.py
# Purpose: Get the number of nodes in a triangulation.
# Returns: Integer.

from maptek import vulcan

input_tri = 'cube.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri:
    num_nodes = tri.n_nodes() # get number of nodes

    # do something...
    print(num_nodes)

neighbors(triangulation self, facet index number) -> int_list

Gets the triangle neighbours. Pass the index of the facet of interest and returns a list of neighbouring facet indices.

# Filename: tri_neighbors.py
# Purpose: Get facet indices of neighbouring of triangles.
# Returns: List of integers.

from maptek import vulcan

tri = 'cube.00t' # input tri

with vulcan.triangulation(tri) as tri: # open tri as read
    neighbouring_facets = tri.neighbours(1) # pass index of facet of interest

    # do something...
    print(neighbouring_facets)

node_neighborhood(triangulation self, node index number) -> int_list

Gets the node neighbours. Pass the index of the node of interest and returns a list of neighbouring node indices.

# Filename: tri_node_neighborhood.py
# Purpose: Get node indices of neighbouring of nodes.
# Returns: List of integers.

from maptek import vulcan

tri = 'cube.00t' # input tri

with vulcan.triangulation(tri) as tri: # open tri as read
    neighbouring_nodes = tri.node_neighborhood(1) # pass index of node of interest

    # do something...
    print(neighbouring_nodes)

normalise(triangulation self) -> void

Normalizes the triangulation faces so that they all face the same direction (out). Generally, there is no reason to call this method since any method that needs it will call it on its own.

# Filename: tri_normalise.py
# Purpose: Set facet directions to all face outward.
# Returns: None.

from maptek import vulcan

input_tri = 'cube.00t'  # input triangulation

with vulcan.triangulation(input_tri, "w") as tri:  # open in write mode
    tri.normalise()  # set facet directions

point_inside(triangulation self, double x, double y, double z) -> bool

Checks if a point is inside a closed triangulation.

# Filename: tri_point_inside.py
# Purpose: Check if point is inside triangulation.
# Returns: Bool.

from maptek import vulcan

input_tri = 'halo.00t'

with vulcan.triangulation(input_tri, 'r') as tri: # open tri in read mode
    is_in = tri.point_inside(78100.0, 4650.0, 100.0) # pass point x,y,z

    # do something with result...
    print(is_in)

put_faces(triangulation self, facet index number) -> void
put_vertices(triangulation self, int n0) -> void

put_faces() stores a NumPy array of facets in a triangulation.

put_vertices() stores a NumPy array of nodes in a triangulation.

Important

There are two functions that can be used to add facets and vertices to a triangulation:

  • append_faces()/ append_vertices() - These will add facets and vertices to a triangulation without altering the existing facets or vertices.

  • put_faces()/ put_vertices() - These will replace the existing faces and vertices of a triangulation, overwriting all existing facets vertices.

# Filename: tri_put_faces.py
# Purpose: Put a NumPy array of facets in a triangulation.
# Returns: None.

from maptek import vulcan
from maptek import vulcan_gui
import numpy as np

new_tri = 'new2.00t'

with vulcan.triangulation(new_tri, 'w') as tri:
    # create coordinate arrays for each node
    n0 = [77888.0, 4739.0, 100.0]
    n1 = [78160.0, 4208.0, 100.0]
    n2 = [78177.0, 4759.0, 50.0]
    n3 = [78353.0, 4399.0, 50.0]
    n4 = [78462.0, 5039.0, 100.0]
    
    f0 = [0,1,2]
    f1 = [1,2,3]
    f2 = [0,2,4]
    
    # create NumPy arrays
    nodes = np.array([n0, n1, n2, n3])
    faces = np.array([f0, f1])
    
    tri.put_vertices(nodes)
    tri.put_faces(faces)

vulcan_gui.load_triangulation(new_tri)

save(triangulation self, std::string const name="") -> bool

Saves the triangulation.

Note

This function can be used with or without any arguments.

If used without any arguments (tri.save()), then it will work as a normal Save command, saving the existing triangulation.

If used with arguments (tri.save("new_shape.00t")), then it will works as a Save As command, saving a copy of the triangulation under a new name.

Note:  The save() function only needs to be called if the WITH statement is not being used. WITH will save the results automatically when the script exits the function.

# Filename: tri_save.py
# Purpose: Save a triangulation.
# Returns: None.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

tri = vulcan.triangulation(input_tri,'w') # open triangulation in write mode
tri.set_colour(10) # make some change
tri.save()

scale(triangulation self, point xyz_scale, point xyz_reference) -> bool

Scales a triangulation by a factor in the x/y/z directions based on a reference point.

# Filename: tri_scale.py
# Purpose: Scale a triangulation from a reference point by an x/y/z factor.
# Returns: Bool.

from maptek import vulcan

input_tri = 'cube.00t'  # input triangulation
scale_factor = [2.0, 2.0, 2.0] # x,y,z scale factor

with vulcan.triangulation(input_tri, 'w') as tri:  # open triangulation in write mode
    reference_point = tri.centroid()  # reference point
    tri.scale(scale_factor, reference_point)

segment_intersections(triangulation self, double x0, double y0, double z0, double x1, double y1, double z1) -> double_double_list

Gets the intersections of a line segment as a list.

Example of return results: [[78085.919, 3957.883, 150.0]]

# Filename: tri_segment_intersections.py
# Purpose: Gets the intersections of a line segment as points.
# Returns: Points.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation
dgd_file = "pydemo.dgd.isis" # database to access
layer_name = "CONTOUR_150" # layer to access

with vulcan.dgd(dgd_file, "r") as dgd: # open up the database in read mode
    layer = dgd.get_layer(layer_name) # choose the correct layer
    line = layer.get_object(0) # get object in layer
    coordinates = line.get_coordinates() # Get coordinates of polyline
    line_start = coordinates[0] # get first element in list
    line_end = coordinates[-1] # get last element in list

with vulcan.triangulation(input_tri, 'r') as tri: # Open triangulation
    intersection_points = tri.segment_intersections(*line_start,*line_end)

    # do something with points...
    print(intersection_points)

segment_intersections_pt(triangulation self, point a, point b) -> point_list

Gets the intersections of a line segment as points.

Example of return result: (point(78085.919,3957.883,150.0,0.0,0,''))

# Filename: tri_segment_intersections_pt.py
# Purpose: Gets the intersections of a line segment as points.
# Returns: Points.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation
dgd_file = "pydemo.dgd.isis" # database to access
layer_name = "CONTOUR_150" # layer to access

with vulcan.dgd(dgd_file, "r") as dgd: # open up the database in read mode
    layer = dgd.get_layer(layer_name) # choose the correct layer
    line = layer.get_object(0) # get object in layer
    coordinates = line.get_coordinates() # Get coordinates of polyline
    line_start = coordinates[0] # get first element in list
    line_end = coordinates[-1] # get last element in list

with vulcan.triangulation(input_tri, 'r') as tri: # Open triangulation
    intersection_points = tri.segment_intersections_pt(line_start,line_end)

    # do something with points...
    print(intersection_points)

set_colour(val)

Sets the colour of the triangulation to RGB(list) or colour index(int).

# Filename: tri_set_colour.py
# Purpose: Sets the colour of triangulation to RGB(list) or colour index(int).
# Returns: None.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation
			
with vulcan.triangulation(input_tri, 'w') as tri:
    tri.set_colour(50) # using colour index integer
				
with vulcan.triangulation(input_tri, 'w') as tri:
    tri.set_colour([255, 160, 0]) # using rgb list	

set_colour_index(triangulation self, int colour) -> void

Sets the triangulation colour (index).

# Filename: tri_set_colour_index.py
# Purpose: Sets the colour of triangulation using colour index(int).
# Returns: None.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation
			
with vulcan.triangulation(input_tri, 'w') as tri:
    tri.set_colour(50) # using colour index integer

set_face(triangulation self, facet index, node 1, node 2, node 3) -> void

Add a facet using existing nodes as reference points.

# Filename: tri_set_face.py
# Purpose: Add a facet using existing nodes as reference points.
# Returns: Void.

from maptek import vulcan

input_tri = 'slope_polys.00t'
facet_index = 18
node1 = 0
node2 = 1
node3 = 2
			
with vulcan.triangulation(input_tri, 'w') as tri:
    tri.set_face(facet_index, node1, node2, node3)

set_node(triangulation self, int k, double x, double y, double z) -> void

Sets a triangulation vertex by coordinates.

# Filename: tri_set_node.py
# Purpose: Sets a triangulation vertex by coordinates.
# Returns: Void.

from maptek import vulcan

input_tri = 'slope_polys.00t'
node_index = 18
x = 77731.69
y = 4370.95
z = 100.0

with vulcan.triangulation(input_tri, 'w') as tri:
    tri.set_node(node_index, x, y, z)

set_properties(triangulation self, dictionary of props)

Note:  There are many properties that can be set by using this method. When writing a script, remember that some properties cannot be used with others. For example, you cannot set a triangulation to appear as a solid shade and a wireframe at the same time. It's either one or the other.

set_properties() - Axis colouring
# Filename: tri_set_properties_crange.py
# Purpose: Set the properties of a triangulation to colour by range.
# Returns: Void.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

# property list
# USE_CRANGE: use colour range: True = 1; False = 0
# MIN_CRANGE: min colour index: int
# MAX_CRANGE: max colour index: int
# VARY_CRANGE: axis to colour by: X/Y/Z
# EQUALISE_RANGE: True = 1; False = 0

with vulcan.triangulation(input_tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    props["SHADED"] = 1
    props["WIREFRAME"] = 0
    props['USE_CRANGE'] = 1
    props['MIN_CRANGE'] = 0
    props['MAX_CRANGE'] = 100
    props['VARY_CRANGE'] = 'Z'
    props["EQUALISE_RANGE"] = 1
    tri.set_properties(props)

set_properties() - Solid shading verses wireframe
# Filename: tri_set_properties_shading.py
# Purpose: Set the shading properties of a triangulation.
# Returns: Void.

from maptek import vulcan

tri = 'topo.00t' # input triangulation

# property list
# SHADED: True = 1; False = 0
# WIREFRAME: True = 1; False = 0
# LINES: Shading with or without lines. True = 1; False = 0

with vulcan.triangulation(tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    props['SHADED'] = 0 
    props['WIREFRAME'] = 1
    props['LINES'] = 0    
    tri.set_properties(props)

set_properties() - Setting colour index
# Filename: tri_set_properties_colour.py
# Purpose: Set the colour properties of a triangulation.
# Returns: Void.

from maptek import vulcan

tri = 'topo.00t' # input triangulation

# property list
# USE_RGB: True = 1; False = 0
# USE_ICOLOUR: True = 1; False = 0
# ICOLOUR: Range = 0-255

with vulcan.triangulation(tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    props["USE_RGB"] = 0
    props["USE_ICOLOUR"] = 1
    props["ICOLOUR"] = 123
    tri.set_properties(props)

set_properties() - Add contour lines
# Filename: tri_set_properties_contour.py
# Purpose: Add contour lines to a triangulation.
# Returns: Void.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

# property list
# SHADED: True = 1; False = 0
# WIREFRAME: True = 1; False = 0
# USE_CONTOUR: True = 1; False = 0
# CONTOUR: Distance interval
# PATTERN: 1 = solid fill with contour lines; 0 = just contour lines

with vulcan.triangulation(input_tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    props["SHADED"] = 0
    props["WIREFRAME"] = 1
    props["USE_CONTOUR"] = 1
    props["CONTOUR"] = 10
    props["PATTERN"] = 1
    tri.set_properties(props)

set_properties() - Set the fill pattern
# Filename: tri_set_properties_pattern.py
# Set the shading pattern of a triangulation.
# Returns: Void.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

# property list
# SHADED: True = 1; False = 0
# WIREFRAME: True = 1; False = 0
# PATTERN: Pattern index, range: 0 - 47
# FILL: True = 1; False = 0

with vulcan.triangulation(input_tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    props["SHADED"] = 0
    props["WIREFRAME"] = 1
    props["PATTERN"] = 10
    props["FILL"] = 1
    tri.set_properties(props)

set_properties() - Set smoothing for a triangulation
# Filename: tri_set_properties_smooth.py
# Purpose: Set smoothing for a triangulation.
# Returns: Void.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

# property list
# SHADED: True = 1; False = 0
# WIREFRAME: True = 1; False = 0
# USE_SMOOTH: True = 1; False = 0   
# SMOOTH: Range = 1-180   

with vulcan.triangulation(input_tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    props["SHADED"] = 1
    props["WIREFRAME"] = 0
    props["USE_SMOOTH"] = 1
    props["SMOOTH"] = 180
    tri.set_properties(props)

set_properties() - Set translucency for a triangulation
# Filename: tri_set_properties_translucency.py
# Purpose: Set translucency for a triangulation.
# Returns: Void.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

# property list
# SHADED: True = 1; False = 0
# WIREFRAME: True = 1; False = 0
# USE_TRANSLUCENT: True = 1; False = 0   
# TRANSLUCENT: range = 0.0 - 100.0   

with vulcan.triangulation(input_tri,'w') as tri: # Open triangulation in write mode
    props = tri.get_properties()
    props["SHADED"] = 1
    props["WIREFRAME"] = 0
    props["USE_TRANSLUCENT"] = 1
    props["TRANSLUCENT"] = 80.0
    tri.set_properties(props)

set_rgb(triangulation self, int_list const & rgb) -> Void
# Filename: tri_set_rgb.py
# Purpose: Set the RGB colour value of a triangulation.
# Returns: Void.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation
rgb_list = [18,186,24] # RGB values

with vulcan.triangulation(input_tri, "w") as tri: # open triangulation in write mode
    tri.set_rgb(rgb_list)

set_translucency(triangulation self, double const value) -> Void
# Filename: tri_set_translucency.py
# Purpose: Set the translucency value of a triangulation.
# Returns: Void.

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation
translucency_value = 80 # percent translucency 

with vulcan.triangulation(input_tri,"w") as tri: # open triangulation in write mode
    tri.set_translucency(translucency_value)

shortest_path(triangulation self, point start, point end) -> VulcanObj

Creates a polyline object denoting the shortest path between two points.

# Filename: tri_shortest_path.py
# Purpose: Find the shortest path between two points.
# Returns: Vulcan object.

from maptek import vulcan
from maptek import vulcan_gui

input_tri = 'topo.00t' # input triangulation
pt1 = vulcan.point(77495.53, 4410.50, 173.37, 0.0, 0, '')
pt2 = vulcan.point(78399.41, 4539.64, 188.24, 0.0, 0, '')

with vulcan.triangulation(input_tri) as tri: # Open triangulation in read mode
    path = tri.shortest_path(pt1, pt2)

vulcan_gui.temp_object(path) # display the line

solid_from_polygon(triangulation self, double width, int poly_position) -> Void

Creates a solid from points of a polygon, projecting them vertically.

# Filename: tri_solid_from_polygon.py
# Purpose: Create solid from polygon.
# Returns: Void.

from maptek import vulcan
from maptek import vulcan_gui

dgd_file = "pydemo.dgd.isis" # design database to access
new_tri = 'solid_from_poly.00t' # name of new triangulation

# select layer from the screen
sel = vulcan_gui.selection("Select Polygon")
sel.criteria = ["LINE", "POLYGON"]
sel.single_object = True
for obj in sel:
    layer_name = obj.layer

# open layer and extract points
with vulcan.dgd(dgd_file, "r") as dgd:
    if dgd.is_layer(layer_name): # check if layer exists
        layer = dgd.get_layer(layer_name) # open layer
    else:
        print("Layer does not exist")
        exit() # if layer does not exist, exit script
    
    for pt in layer:
        points = pt.get_coordinates() # read coordinates of each point

with vulcan.triangulation(new_tri, 'w') as tri:
    [tri.add_node(*pt) for pt in points]
    width = 30 # the height of the new solid
    poly_position = 1 # 0 = top, 1 = middle, 2 = bottom
    tri.solid_from_polygon(width, poly_position)

surface_area(triangulation self) -> double

Get the surface area of a triangulation.

# Filename: tri_surface_area.py
# Purpose: Get the surface area of a triangulation.
# Returns: Double

from maptek import vulcan

input_tri = 'topo.00t' # input triangulation

with vulcan.triangulation(input_tri) as tri: # Open triangulation in read mode
    area = tri.surface_area() # Get surface area

    # do something with result...
    print(f"Surface area of {input_tri}: {area}")

translate(triangulation self, point translation) -> bool

Translate a triangulation by an x/y/z shift.

# Filename: tri_translate.py
# Purpose: Translate a triangulation by an x/y/z shift.
# Returns: Bool.

from maptek import vulcan

input_tri = 'bench.00t' # input triangulation

# set how much you want to move the triangulation
x_shift = 10.0
y_shift = 5.0
z_shift = -10.0

shift = vulcan.point(x_shift, y_shift, z_shift) # create point

with vulcan.triangulation(input_tri, 'w') as tri: # open in write mode
    tri.translate(shift)
update_grid(triangulation self, VGD_grid_t grid) -> void

Updates a grid with the current triangulation.

# Filename: tri_update_grid.py
# Purpose: Update a grid from a triangulation.
# Returns: Void.

from maptek import vulcan

input_tri = 'image_topo.00t'
input_grid = 'thortopo.00g'

# check grid
grid = vulcan.grid(input_grid)
assert(grid.ok)

with vulcan.triangulation(input_tri, 'w') as tri:
    tri.update_grid(grid)
    grid.save()

volume(triangulation self) -> double

Returns the volume of a closed triangulation.

# Filename: tri_volume.py
# Purpose: Get the volume of a closed solid.
# Returns: Double.

from maptek import vulcan

input_solid = 'bench_01.00t'

with vulcan.triangulation(input_solid) as tri:
    vol = tri.volume()
			
    # do something with result...
    print(f"Volume of {input_solid} is {vol}")