maptek.vulcan.dgd

Interface for reading/editing Vulcan design databases.

Parameters

  • name: str - The name of the ```.dgd.isis``` file to open.

  • mode: str - The acccess mode for the database. Options are:

    • `r`/`read` for readonly mode (default)

    • `c`/`create` for create mode

    • `w`/`w+`/`write`/`a`/`a+`/`append` for write mode

Raises ValueError when the database does not end with .dgd.isis

with vulcan.dgd('pydemo.dgd.isis', 'w') as dgd:  # open in write mode
Note

Opening a currently active dgd in Vulcan with the vulcan.dgd class can cause issues with data syncing on screen. All edits to an open dgd should be done through the vulcan_gui module.

Edits to the dgd through vulcan.dgd will not be reflected in Vulcan GUI without closing and reopening the dgd, and edits in the GUI can overwrite changes to the dgd.


is_locked(dgd self) → bool

Checks if a dgd is locked.

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.

Note:  It is always better to use a with statement to open a database since it consolidates the process of working with the database object. Also, when the script exits the with statement, the database will be closed automatically, removing the need to specifically call the close() function.

# 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: 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)

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)