maptek.vulcan.text

Interface for Vulcan design text(2D).


num_lines(text self) → int

Returns the number of text lines.

# Filename: text_num_lines.py
# Purpose: Returns the number of text lines.
# Returns: int

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_num_lines = txt_obj.num_lines()  # get the number of lines
    print(txt_num_lines)

get_line(text self, int line_num) → std::string

Gets a line of text by index.

# Filename: text_get_line.py
# Purpose: Gets a line of text by index.
# Returns: string

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_line = txt_obj.get_line(1)  # get second line of text
    print(txt_line)

append(text self, std::string const & line)

Appends a line of text.

# Filename: text_append.py
# Purpose: Appends a line of text.
# Returns: null

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_obj.append('add another line')  # append new line of text
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save the layer

set_line(text self, int line_num, std::string const & line)

Sets a line of text by index.

# Filename: text_set_line.py
# Purpose: Sets a line of text by index.
# Returns: null

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_obj.set_line(1, 'replace line two')  # edit second line of text
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save the layer

delete_line(text self, int line_num)

Deletes a line of text by index.

# Filename: text_delete_line.py
# Purpose: Deletes a line of text by index.
# Returns: null

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_obj.delete_line(1)  # delete second line of text (index 1)
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save the layer

delete_all_lines(text self)

Deletes all lines of text.

# Filename: text_delete_all_lines.py
# Purpose: Deletes all lines of text.
# Returns: null

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_obj.delete_all_lines()  # delete all lines
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save the layer

get_origin(text self) → point

Gets the text origin point.

# Filename: text_get_origin.py
# Purpose: Get the origin of text.
# Returns: point

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_origin = txt_obj.get_origin()  # get the number of lines
    print(txt_origin)

set_origin(text self, point pt)

Sets the text origin point.

# Filename: text_set_origin.py
# Purpose: Get the origin of text.
# Returns: point

from maptek import vulcan

dgd_file = "pydemo.dgd.isis"  # design database we want to access
layer_name = "TEXT"  # 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

    txt_obj = layer.get_object(0)  # get the text object
    txt_obj.set_origin([78500.0, 5500.0, 0.0])
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save the layer

get_angle(text self) → double

Gets the text angle. This reports the angle in radians.

# Filename: text_get_angle.py
# Purpose: Gets the text angle.
# Returns: Float

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_angle = txt_obj.get_angle()  # get the angle
    print(f"angle = {txt_angle}")

set_angle(text self, double angle)

Sets the text angle. Input needs to be in radians.

Note:  A non-transformable font (Small, Normal, Medium, Large) will show no change on the screen. The change will only be reflected when plotted. Transformable fonts display on the screen at the specified angle.

Note:  No angle will be applied to a framed text.

# Filename: text_set_angle.py
# Purpose: Sets the text angle.
# Returns: null

from maptek import vulcan
import math

dgd_file = 'pydemo.dgd.isis'  # design database we want to access
layer_name = 'TEXT'  # 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

    txt_obj = layer.get_object(0)  # get the text object
    txt_obj.set_angle(math.radians(30.0))  # set text angle (deg to rad)
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save the layer

get_scale(text self) → std::string

Gets the text scale.

# Filename: text_get_scale.py
# Purpose: Gets the text scale.
# Returns: string

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_scale = txt_obj.get_scale()  # get second line of text
    print(txt_scale)

set_scale(text self, std::string const & scale)

Sets the text scale.

# Filename: text_set_scale.py
# Purpose: Sets the text scale.
# Returns: null

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_obj.set_scale('1:16500')  # set the scale
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save the layer

get_height(text self) → double

Gets the text height.

# Filename: text_get_height.py
# Purpose: Gets the text height.
# Returns: float

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_ht = txt_obj.get_height()  # get second line of text
    print(txt_ht)

set_height(text self, double height)

Sets the text height.

# Filename: text_set_height.py
# Purpose: Sets the text height.
# Returns: null

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_obj.set_height(0.1)  # set the text height in plotter units
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save the layer

get_width(text self) → double

Gets the text width.

# Filename: text_get_width.py
# Purpose: Gets the text width.
# Returns: float

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_width = txt_obj.get_width()  # get second line of text
    print(txt_width)

set_width(text self, double width)

Sets the text width.

# Filename: text_set_width.py
# Purpose: Sets the text width.
# Returns: null

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_obj.set_width(0.1)  # set the text height in plotter units
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save the layer

get_font(text self) → std::string

Gets the text font.

# Filename: text_get_font.py
# Purpose: Gets the text font.
# Returns: string

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_font = txt_obj.get_font()  # get text font
    print(txt_font)

set_font(text self, std::string const & font)

Sets the text font.

# Filename: text_set_font.py
# Purpose: Sets the text font.
# Returns: null

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object
    txt_obj.set_font('Courier New')  # set the text height in plotter units
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save the layer

is_framed(text self) → bool

Text frame status(bool)

# Filename: text_is_framed.py
# Purpose: Check if the text is framed.
# Returns: Bool: True if the text is framed, False otherwise.

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get text
    txt_is_framed = txt_obj.is_framed()  # check if the text is framed
    print(txt_is_framed)

set_framed(text self, bool frame=True)

Sets/Removes text frame.

Note:  A frame can only be applied when using fixed fonts (Small, Normal, Medium, Large).

Note:  No angle will be applied to a framed text.

# Filename: text_set_framed.py
# Purpose: Set the framed state of the text.
#          True sets the text as framed, False sets the text as not framed.
# Returns: null

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get text
    txt_obj.set_framed()  # frame the text
    layer.set_object(0, txt_obj)  # update the text
    dgd.save_layer(layer)  # save the layer

property origin → point

Text origin

# Filename: text_property_origin.py
# Purpose: Get or set text origin using property method.

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object

    # get origin using property method
    txt_origin = txt_obj.origin
    print(txt_origin)

    # set origin using property method
    txt_obj.origin = [78100, 5100, 0]  # enter xyz coords as list
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save layer

property angle → double

Text angle

# Filename: text_property_angle.py
# Purpose: Get or set text angle using property method.

from maptek import vulcan
import math

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

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

    txt_obj = layer.get_object(0)  # get the text object

    # get angle using property method
    txt_angle = txt_obj.angle  # get angle in radians
    print(txt_angle)

    # set angle using property method
    txt_obj.angle = math.radians(45.0)  # set text angle (deg to rad)
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save layer

property scale: std → string

Text scale

# Filename: text_property_scale.py
# Purpose: Get or set text scale using property method.

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object

    # get scale using property method
    txt_scale = txt_obj.scale  # get scale
    print(txt_scale)

    # set scale using property method
    txt_obj.scale = '1:12500'  # input scale as ratio
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save layer

property height → double

Text height

# Filename: text_property_height.py
# Purpose: Get or set text height using property method.

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object

    # get height using property method
    txt_height = txt_obj.height  # get height
    print(txt_height)

    # set height using property method
    txt_obj.height = 0.2  # set text height
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save layer

property width: double

Text width

# Filename: text_property_width.py
# Purpose: Get or set text width using property method.

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object

    # get height using property method
    txt_width = txt_obj.width  # get width
    print(txt_width)

    # set height using property method
    txt_obj.width = 0.2  # set text width
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save layer

property font: std → string

Text font

# Filename: text_property_font.py
# Purpose: Get or set text font using property method.

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object

    # get height using property method
    txt_font = txt_obj.font  # get font
    print(txt_font)

    # set height using property method
    txt_obj.font = 'NORMAL'  # set text font
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save layer

property framed → bool

Is text framed

Note:  A frame can only be applied when using fixed fonts (Small, Normal, Medium, Large).

Note:  No angle will be applied to a framed text.

# Filename: text_property_framed.py
# Purpose: Get state or set text frame using property method.

from maptek import vulcan

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

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

    txt_obj = layer.get_object(0)  # get the text object

    # get height using property method
    txt_framed = txt_obj.framed  # get framed state
    print(txt_framed)

    # set height using property method
    txt_obj.framed = False  # set text frame state (False = no frame)
    layer.set_object(0, txt_obj)  # replace the old text
    dgd.save_layer(layer)  # save layer