Vertec Python module “vtcmodel”

Use the built-in Python module “vtcmodel” to retrieve information about the Vertec data model behind the business objects.

The Vertec Python Module vtcmodel allows to query information about the data model behind the business objects. It is also available in Resctict Scripting mode and includes the method:

vtcmodel.gettypeinfo(object): Typeinfo

  • object: A single Vertec object or as of Vertec 6.8.0.12 also a class name as a string
    • Case insensitive
    • The English or German class name can be used regardless of the current Model Language  

Gets the information of the given Vertec object or class and returns a Typeinfo Python object.

The Typeinfo object has the following properties:

Member / Function Description
name
Returns the class name in the current Vertec model language
defaultname
Returns the default class name in the model
persistent
Specifies whether objects of this class are saved and stored in the database.
members
List of all members of this class
memberbyname(name: String): member
  • name: Name of the member as a string
    • Case insensitive
    • Regardless of the current Model Language, the English or German member name can be used.  

Returns the specified member as a Member Python object.  

The Member object has the following properties:

Members can be both attributes (normal fields) and associations (links to other objects). Depending on whether it is an attribute or an association, the Member object has slightly different properties. This is noted in the respective row.  

Characteristics Description Attribute Association
allownull
Specifies whether the member may be empty (NULL) x x
classinfo
The class to which the member belongs (Typeinfo as above) x x
column name
Column name of the member in the database (persistent members only) x x
defaultname
Default member name in model x x
derived
Indicates whether the attribute is a derived attribute. x  
isattribute
Indicates whether the member is an attribute. x x
isindirect
Specifies whether the association is part of a multilink (m:n), in which case there is a link object (linkclass).   x
ismultirole
Indicates whether the member is the multi-end of a link, so it can also be used as a list. x x
isrole
Specifies whether the member is a link role, i.e. the member is an association. x x
issinglerole
Indicates whether the member is the single end of a link. x x
length
Specifies the maximum allowed length of the attribute. This is relevant for strings. x  
linkclass
The name of the link class if it is a multilink (isindirect).   x
name
Name of the member in the current model language x x
ordered
Indicates whether it is a sorted association.   x
otherend
The other side of the association, also gives a Member Object back.       x
persistent
Specifies whether the member is saved in the database.     x x
valuetype

Data type of the attribute. Possible values are:

  • VtcString (String)
  • Boolean (true/false)
  • Date (date)
  • DateTime (date with time part)
  • integer (integer)
  • float (number with decimal places)
  • VtcCurrency (decimal number)
  • Blob (binary data, e.g. images)
  • TBALanguage (language)
x  

Some of these properties can also be seen in the Vertec Model Browser on the right hand side when you select a member in the list.    

Example script

The example script can be run on a project in the Vertec Script Editor.  

import vtcmodel

typeinfo = vtcmodel.gettypeinfo(argobject) # argobject is a project
print("Class name (actual model language): {}".format(typeinfo.name)) # Projekt/Project
print("Class name (model): {}".format(typeinfo.defaultname)) # Project
print("Stored in DB: {}".format(typeinfo.persistent)) # True

members = typeinfo.members # List of all "member" objects

member = typeinfo.memberbyname("Active") # Info about member "active"
print("Member name (actual model language): {}".format(member.name)) # aktiv/active
print("Member name (model): {}".format(member.defaultname)) # active
print("Value type: {}".format(member.valuetype)) # Boolean (string)
print("Stored in DB: {}".format(member.persistent)) # True
print("Derived: {}".format(member.derived)) # False
print("Null/Empty allowed: {}".format(member.allownull)) # False
print("Is attribute: {}".format(member.isattribute)) # True
print("Is Linkrole / Association: {}".format(member.isrole)) # False
print("Is single role: {}".format(member.issinglerole)) # False
print("Is multi role: {}".format(member.ismultirole)) # False
print("Column name in DB: {}".format(member.columnname)) # Active
print("Length: {}".format(member.length)) # 255, only relevant on Strings
print("Backlink on 'Project' ClassInfo: {}".format(member.classinfo.name)) # Projekt/Project

role_member = typeinfo.memberbyname("Customer") # Info about the association to the customer
# Attributes like above, except for "valuetype" and "derived", instead:
print("Link class: {}".format(role_member.linkclass)) # None
print("Ordered: {}".format(role_member.ordered)) # True
print("Name of the member on the other side: {}".format(role_member.otherend.name)) # projekte/projects

Netherlands

United Kingdom