maptek.vulcan.attributes

Class for accessing object attribute data.


template_list(self) -> list[str]

List of templates defined for the object.

# Filename: attribute_template_list.py
# Purpose: List of templates defined for the object.
# Returns: list[str]

from maptek import vulcan

dgd_file_name = "SHAWEXPRESSIONS.dgd.isis"
layer_name = "STOPE_EXPRESSIONS"

with vulcan.dgd(dgd_file_name, "r") as dgd:
    assert dgd.is_layer(layer_name), f"error: layer does not exist: {layer_name}"

    my_layer = dgd.get_layer(layer_name)
    obj = my_layer[0]  # get a layer object
    attr = obj.attributes  # get attribute data
    temp_list = attr.template_list()  # list of templates
    print(temp_list)
attribute_list(self, templateName: str, templateVariant: dict = dict()) -> list[str]

List of attributes in a given template.

# Filename: attribute_attribute_list.py
# Purpose: List of attributes in a given template.
#          Ordered by the second argument template
# Returns: list[str]

from maptek import vulcan

dgd_file_name = "SHAWEXPRESSIONS.dgd.isis"
layer_name = "STOPE_EXPRESSIONS"
template_name = "Stope"

with vulcan.dgd(dgd_file_name, "r") as dgd:
    assert dgd.is_layer(layer_name), f"error: layer does not exist: {layer_name}"

    my_layer = dgd.get_layer(layer_name)
    obj = my_layer[0]  # get a layer object
    attr = obj.attributes  # get attribute data
    attr_list = attr.attribute_list(template_name)  # list of attributes
    print(attr_list)
				
get_template(self, temp: str) -> dict

Gets the dictionary for a given template.

# Filename: attribute_get_template.py
# Purpose: Gets the dictionary for a given template.
# Returns: dict

from maptek import vulcan

dgd_file_name = "SHAWEXPRESSIONS.dgd.isis"
layer_name = "STOPE_EXPRESSIONS"
template_name = "Stope"

with vulcan.dgd(dgd_file_name, "r") as dgd:
    assert dgd.is_layer(layer_name), f"error: layer does not exist: {layer_name}"
	
    my_layer = dgd.get_layer(layer_name)
    obj = my_layer[0]  # get a layer object
    attr = obj.attributes  # get attribute data
    attr_temp = attr.get_template(template_name)  # gets dictionary for the template
    print(attr_temp)
				
set_template(self, temp: str, data: dict)

Sets the attributes of a template from a dictionary.

# Filename: attribute_set_template.py
# Purpose: Sets the attributes of a template from a dictionary.
# Returns: Null

					from maptek import vulcan

					dgd_file_name = "SHAWEXPRESSIONS.dgd.isis"
					layer_name = "STOPE_EXPRESSIONS"
					template_name = "Stope"
					attr_name = "Name"

					with vulcan.dgd(dgd_file_name, "w") as dgd:
					assert dgd.is_layer(layer_name), f"error: layer does not exist: {layer_name}"

					my_layer = dgd.get_layer(layer_name)  # open layer
					for i, obj in enumerate(my_layer):  # loop through each object in layer
					stope_name = 'ST_' + str(i)  # define name value based on layer object
					attr = obj.attributes  # get attribute data
					attr.set_template(template_name, attr_name)  # assign new attribute to template
					attr.set_attribute(template_name, attr_name, stope_name)  # populate attribute value
					my_layer[i] = obj  # assign modified object to layer
					dgd.save_layer(my_layer)  # save layer
get_attribute(self, temp: str, attribute: str) -> value of attribute

Gets a single attribute.

# Filename: attribute_get_attribute.py
# Purpose: Gets a single attribute.
# Returns: Value of attribute

from maptek import vulcan

dgd_file_name = "SHAWEXPRESSIONS.dgd.isis"
layer_name = "STOPE_EXPRESSIONS"
template_name = "Stope"
attr_name = "Grade"

with vulcan.dgd(dgd_file_name, "r") as dgd:
    assert dgd.is_layer(layer_name), f"error: layer does not exist: {layer_name}"

    my_layer = dgd.get_layer(layer_name)
    for i in range(len(my_layer)):
        obj = my_layer[i]  # get each layer object
        attr = obj.attributes  # get attribute data
        attr_value = attr.get_attribute(template_name, attr_name)  # value of single attribute
        print(f'Grade:  {attr_value}')
get_date_attribute(self, temp: str, attribute: str) -> datetime.datetime

Gets a date attribute as a Python datetime object.

# Filename: attribute_get_date_attribute.py
# Purpose: Gets a date attribute as a Python datetime object.
# Returns: datetime.datetime

from maptek import vulcan

dgd_file_name = "SHAWEXPRESSIONS.dgd.isis"
layer_name = "STOPE_EXPRESSIONS"
template_name = "Stope"
attr_name = "Grade"

with vulcan.dgd(dgd_file_name, "r") as dgd:
    assert dgd.is_layer(layer_name), f"error: layer does not exist: {layer_name}"

    my_layer = dgd.get_layer(layer_name)  # open layer
    for i in range(len(my_layer)):  # loop through each object in layer
        obj = my_layer[i]  # get each layer object
        attr = obj.attributes  # get attribute data
        attr_date = attr.get_date_attribute(template_name, attr_name)  # get date attribute
        print(attr_date)
set_attribute(self, temp: str, attribute: str, value: dict)

Sets a single attribute.

# Filename: attribute_set_attribute.py
# Purpose: Sets a single attribute.
# Returns: Null

from maptek import vulcan

dgd_file_name = "SHAWEXPRESSIONS.dgd.isis"
layer_name = "STOPE_EXPRESSIONS"
template_name = "Stope"
attr_grade = "Grade"
attr_tonnage = "Tonnage"
attr_totalgold = "Total Gold"

with vulcan.dgd(dgd_file_name, "w") as dgd:
    assert dgd.is_layer(layer_name), f"error: layer does not exist: {layer_name}"

    my_layer = dgd.get_layer(layer_name)  # open layer
    for i, obj in enumerate(my_layer):  # loop through each object in layer
        attr = obj.attributes  # get attribute data
        tonnage = attr.get_attribute(template_name, attr_tonnage)  # get value of tonnage
        totalgold = attr.get_attribute(template_name, attr_totalgold)  # get value of total gold
        au_grade = totalgold / tonnage  # calculation for average au grade
        au_grade_rounded = round(au_grade, 2)  # round calculation results to 2 decimal places
        attr.set_attribute(template_name, attr_grade, au_grade_rounded)  # assign value to attribute
        my_layer[i] = obj  # assign modified object to layer
        dgd.save_layer(my_layer)  # save layer
as_dict(self) -> dict

Gets the attribute data as a dictionary.

# Filename: attribute_as_dict.py
# Purpose: Gets the attribute data as a dictionary.
# Returns: MVariant

from maptek import vulcan

dgd_file_name = 'SHAWEXPRESSIONS.dgd.isis'

with vulcan.dgd(dgd_file_name, "r") as dgd:
    layer_name = "STOPE_EXPRESSIONS"  # Find the layer
    assert dgd.is_layer(layer_name), 'error: layer does not exist'

    my_layer = dgd.get_layer(layer_name)  # open layer
    for i in range(len(layer_name)):
        obj = my_layer[i]  # get each layer object
        attr = obj.attributes  # get attribute data
        print(attr)
from_dict(self, data: dict)

Sets the attribute data from a dictionary.

# Filename: attribute_from_dict.py
# Purpose: Sets the attribute data from a dictionary.
# Returns: Null

from maptek import vulcan

dgd_file_name = "SHAWEXPRESSIONS.dgd.isis"
layer_from = "PLANE"
layer_to = "SECTION_LINE"

with vulcan.dgd(dgd_file_name, "w") as dgd:
    assert dgd.is_layer(layer_from), f"error: layer does not exist: {layer_from}"
    my_layer = dgd.get_layer(layer_from)  # open layer

    # get attributes from layer one
    obj = my_layer[0]  # get each layer object
    attr = obj.attributes  # get attribute data
    dict = attr.as_dict()

    # apply attributes to layer two
    assert dgd.is_layer(layer_to), f"error: layer does not exist: {layer_to}"
    layer = dgd.get_layer(layer_to)  # open layer
    obj = layer[0]  # get layer object
    attr.from_dict(dict)
    obj.attributes = attr
    dgd.save_layer(layer)  # save layer