maptek.vulcan.dgd

Interface for Vulcan design databases.


is_locked(dgd self) → bool

Returns dgd lock status by checking for lock files.

Returns True if lock file is present, False otherwise.

# Filename: dgd_is_locked.py
# Purpose: Check if a dgd is locked
# Returns: True if lock file is present, False otherwise.

from maptek import vulcan

with vulcan.dgd("pydemo.dgd.isis", "r") as dgd:  # open dgd file in read mode
    locked = dgd.is_locked()
    print(f"dgd is locked: {locked}")

close(dgd self)

Closes the dgd.

# Filename: dgd_close.py
# Purpose: Closes the dgd.
# Returns: null

from maptek import vulcan

dgd = vulcan.dgd('pydemo.dgd.isis', 'w')  # open dgd file in read mode
state = dgd.is_open()
print(state)
state = dgd.close()
print(state)

is_layer(dgd self, std::string const & name) → bool

Check if a layer exists in the dgd.

Parameters

  • name (str) – The name of the layer to check for existence.

Returns True if the layer exists, False otherwise.

# Filename: dgd_is_layer.py
# Purpose: Check if a layer exists in the dgd.
# Returns: True if the layer exists, False otherwise.

from maptek import vulcan

# open dgd file in write mode or read mode depending on what you want to do
with vulcan.dgd("pydemo.dgd.isis", "w") as dgd:
    layer_exists = dgd.is_layer("OBJECTS")  # check if the layer is in the dgd
    assert layer_exists, "Layer does not exist"

    # do something...
    dgd.delete_layer("OBJECTS")  # delete layer

get_layer(dgd self, std::string const name) → layer

Gets a layer from the database. If edited in in write mode, changes must be saved back by using save_layer() or save_layer_as()

Parameters

  • name (str) – The name of the layer to get.

Returns the requested layer.

# Filename: dgd_get_layer.py
# Purpose: Gets a layer from the database. If edited in write mode, changes
#          must be saved back by using save_layer() or save_layer_as().
# Returns:
# open dgd in write mode and add a line

from maptek import vulcan

with vulcan.dgd('pydemo.dgd.isis', 'w') as dgd:  # open in write mode
    layer = dgd.get_layer('BOUNDARY')  # get the BOUNDARY layer

    # do something...
    # ...for this example, create a diagonal line
    obj = vulcan.polyline([[78000, 4600, 5], [78500, 4650, 10]])
    obj.name = 'LINE'
    obj.set_colour(3)
    obj.set_connected()  # set the line as connected

    # add the line to the layer then save
    layer.append(obj)
    dgd.save_layer(layer)

is_open(dgd self) → bool

Checks if the database is open.

Returns True if the layer exists, False otherwise.

# Filename: dgd_is_open.py
# Purpose: Checks if the database is open.
# Returns: True if the database is open, False otherwise.

from maptek import vulcan

with vulcan.dgd('pydemo.dgd.isis', 'r') as dgd:  # open dgd file in read mode
    state = dgd.is_open()
    print(state)

num_layers(dgd self) → int

Get the number of layers in the database.

# Filename: dgd_num_layers.py
# Purpose: Get the number of layers in the database.
# Returns: int

from maptek import vulcan

with vulcan.dgd('pydemo.dgd.isis', 'r') as dgd:  # open dgd file in read mode
    number_of_layers = dgd.num_layers()
    print(number_of_layers)

list_layers(dgd self) → string_list

Lists the names of the layers in the database.

# Filename: dgd_list_layers.py
# Purpose: Lists the names of the layers in the dgd database.
# Returns: List of layer names

from maptek import vulcan

dgd_file_name = 'pydemo.dgd.isis'  # name of database we want to use

with vulcan.dgd(dgd_file_name, "r") as dgd:  # open the dgd in read mode
    layers = dgd.list_layers()  # get the list of layers
    print(f"{layers}")

delete_layer(dgd self, std::string const & layer) → bool

Deletes a layer in the database.

Parameters

  • layer (str) – The name of the layer to delete.

Returns true if the layer was successfully deleted, False otherwise.

# Filename: dgd_delete_layer.py
# Purpose: Delete a layer from a dgd
# Returns: True if the layer was successfully deleted, False otherwise.

from maptek import vulcan

with vulcan.dgd("pydemo.dgd.isis", "w") as dgd:  # open dgd file in write mode
    layer_exists = dgd.is_layer("OBJECTS")  # check if the layer is in the dgd
    assert layer_exists, "Layer does not exist"

    dgd.delete_layer("OBJECTS")  # delete layer

save_layer(dgd self, layer layerInstance) → bool

Saves a layer to the database.

# Filename: arrow_set_head_length.py
# Purpose: Sets the arrow head length.
# Returns: null

from maptek import vulcan

dgd_file = "pydemo.dgd.isis"  # design database we want to access
layer_name = "ARROWS"  # name of layer we want to use

with vulcan.dgd(dgd_file, 'w') as dgd:  # open up the database in write mode
    assert dgd.is_layer(layer_name), 'error: layer does not exist'
    layer = dgd.get_layer(layer_name)  # get layer

    # iterate through mutliple arrow objects
    for i in range(len(layer)):
        arrow_object = layer.get_object(i)  # get the arrow object

        # Percentage of the arrow's length to use as the head.
        arrow_object.set_head_length(5.0)
        layer.set_object(i, arrow_object)  # updated arrow
        dgd.save_layer(layer)  # save layer at the end of each iteration

save_layer_as(dgd self, std::string const name, layer layerInstance) → bool

Saves a layer to the database.

Parameters

  • layerInstance (layer) – The layer to save to the database.

Returns true if successful, False otherwise.

# Filename: dgd_save_layer_as.py
# Purpose: Saves a layer to the database with a new name.
# Returns: True if successful, False otherwise.

from maptek import vulcan

with vulcan.dgd('pydemo.dgd.isis', 'w') as dgd:  # open in write mode
    layer = vulcan.layer('DEMO')  # create a new layer called DEMO

    # create a diagonal line
    obj = vulcan.polyline([[78000, 4600, 5], [78500, 4650, 10]])
    obj.name = 'LINE'
    obj.set_colour(3)
    obj.set_connected()  # set the line as connected

    # add the line to the layer then save
    layer.append(obj)
    status = dgd.save_layer_as('NEW_LAYER', layer)
    print(status)

append(dgd self, layer layerInstance) → bool

Adds a new layer to the database. (Raises error on duplicates.)

  • layers - List of layers in database

  • locked - Database work lock status.

  • open - Database open status.

# Filename: dgd_save_layer_as.py
# Purpose: Saves a layer to the database with a new name.
# Returns: True if successful, False otherwise.

from maptek import vulcan

with vulcan.dgd('pydemo.dgd.isis', 'w') as dgd:  # open in write mode
    layer = vulcan.layer('DEMO')  # create a new layer called DEMO

    # create a diagonal line
    obj = vulcan.polyline([[78000, 4600, 5], [78500, 4650, 10]])
    obj.name = 'LINE'
    obj.set_colour(3)
    obj.set_connected()  # set the line as connected

    # add the line to the layer then save
    layer.append(obj)
    status = dgd.save_layer_as('NEW_LAYER', layer)
    print(status)