mapteksdk.data.objectid module

ObjectID class - An ObjectID uniquely references an object in the Project.

Note that an ObjectID is only unique within one Project - an ObjectID of an object in one project may be the ID of a different object in a different project. Attempting to use an ObjectID once the project has been closed will raise an exception.

class mapteksdk.data.objectid.ObjectID(handle=None)

Bases: object

ObjectID used to identify and represent an object.

storage_type

alias of mapteksdk.capi.types.T_ObjectHandle

classmethod convert_from(storage_value)

Convert from the underlying value (of storage type) to this type.

This is used by the communication system.

classmethod convert_to(value)

Convert to the underlying value.

This is used by the communication system.

classmethod from_path(object_path)

Constructs an ObjectID instance from a valid object path string.

This method relies on a valid object existing in the Project at the path passed into this method.

Parameters

object_path (str) – Path to the object to get the ID of.

Returns

An ObjectID instance if the string was valid.

Return type

ObjectID

Raises
  • TypeError – If the object_path parameter is not a string.

  • ValueError – If object_path failed to convert to an ObjectID.

property handle

T_ObjectHandle representation of the Object ID.

Returns

T_ObjectHandle representation of the Object ID. None returned if the class has not been initialised properly.

Return type

T_ObjectHandle

property native_handle

Native Integer (uint64) representation of the Object ID.

Returns

uint64 representation of the Object ID. None returned if the class has not been initialised properly.

Return type

int

property icon_name

The name of the icon that represents the object.

Returns

Icon name for the object type.

Return type

str

Raises

TypeError – If the ObjectID handle is None.

property type_name

The type name of this object.

This name is for diagnostics purposes only. Do not use it to alter the behaviour of your code. If you wish to check if an object is of a given type, use is_a() instead.

Returns

The name of the type of the given object.

Return type

str

Raises

TypeError – If the ObjectID handle is None.

See also

is_a

Check if the type of an object is the expected type.

property exists

Returns true if the object associated with this object id exists. This can be used to check if a previously existing object has been deleted or if the parameters used to create the ObjectID instance are valid and refer to an existing object.

Returns

True if it exists; False if it no longer exists. False is also returned if ObjectID never existed.

Return type

bool

property name

The name of the object (if one exists).

If the object is not inside a container then it won’t have a name. The name comes from its parent. If the object is inside more than one container (has multiple paths) then this is the name in the primary container. Each container that this object is in can assign it a different name.

Returns

The name of the object.

Return type

str

Raises

TypeError – If the ObjectID handle is None.

property path

The path to the object (if one exists) in the project. If an object has multiple paths, the primary path will be returned.

Returns

Path to the object if one exists (e.g. ‘/cad/my_object’).

Return type

str

Raises

TypeError – If the ObjectID handle is None.

property hidden

If the object is a hidden object.

Returns

True if hidden, False if not hidden.

Return type

bool

Raises

TypeError – If the ObjectID handle is None.

property parent

The ObjectID of the primary parent of this object.

Returns

ObjectID instance representing the parent of this object.

Return type

ObjectID

Raises

TypeError – If the ObjectID handle is None.

Notes

If this object is already the root, the same object will be returned. If this object has multiple parents, the primary parent will be returned.

property is_orphan

Check if object is an orphan (no parents, or all of its ancestors are either orphans or are descendants of objects that are themselves orphans).

Returns

True if the object is an orphan or False if it is not.

Return type

bool

Raises

TypeError – If the ObjectID handle is None.

is_a(object_type)

Return true if type of the object in the project is of the type object_type.

This takes into account inheritance - a polygon is both polygon and a topology.

Parameters

object_type – The Python class that represents a type of object in the project. This is the type to compare the type of the object referenced by this object ID to.

Returns

True if the object referenced by this object ID is of the type object_type otherwise False.

Return type

bool

Raises

TypeError – If the argument is not a type of object or a tuple of object types.