Vertec Python module "vtcmodel"

Use the built-in Python module "vtcmodel" to retrieve information about the data model behind the Vertec 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 is not case sensitive
    • 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 enters Typeinfo Python object back.

The Typeinfo Object has the following properties:

Member / feature description
name
Returns the class name in the current Vertec model language
defaultname
Returns the default class name in the model (from Vertec 6.8 always English, before 6.8 always German).
description
As of Vertec 6.8.0.15. Return the description of the class, if any.  
hidden
As of Vertec 6.8.0.15. Specifies whether this class is displayed in the Vertec Model Browser. Classes shown that are not displayed in the Model Browser shown should not be used or should only be used with caution, as these are classes that should not normally be addressed via Python code.  
persistent
Specifies whether objects of this class are saved and stored in the database.
isabstract
As of Vertec 6.8.0.15. Specifies whether this class is an abstract class. This means that no objects can be created directly from this class, for example, because it is a base class.
parent

The class from which this class inherits. Specifies  Typeinfo Object of the parent class (superclass) back.

members
List of all members of this class
memberbyname(name: String): member
  • name: Name of the member as a string
    • Case is not case sensitive
    • Regardless of the current Model Language, the English or German member name can be used.  

Returns the specified member as Member Python object back.  

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 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
Standard member name in model (from Vertec 6.8 always English) x x
derived
Indicates whether the attribute is a derived attribute. x  
description
As of Vertec 6.8.0.15. Return the explanatory description of this description member, if any.     x x
hidden
As of Vertec 6.8.0.15. Specifies whether this member is displayed in the Vertec Model Browser. Showing members that are not displayed in the Model Browser shown should not be used or should only be used with caution, as they are classes that are not normally addressed via Python code.        
isattribute
Indicates whether the member is an attribute. x x
isindirect
Specifies whether the Role 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
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
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 be seen in the Vertec Model Browser on the right hand side when you select a member in the list.    

The vtcmodel module is also available as a Python Stub File.

Example script

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

import vtcmodel

typeinfo = vtcmodel.gettypeinfo(argobject) # argobject is a project
print("Klassenname (aktuelle Modellsprache): {}".format(typeinfo.name)) # Projekt/Project
print("Klassenname (Modell): {}".format(typeinfo.defaultname)) # Project
print("In DB gespeichert: {}".format(typeinfo.persistent)) # True

members = typeinfo.members # Liste von allen "Member" Objekten

member = typeinfo.memberbyname("Active") # Info über Member "aktiv"
print("Membername (aktuelle Modellsprache): {}".format(member.name)) # aktiv/active
print("Membername (Modell): {}".format(member.defaultname)) # active
print("Datentyp: {}".format(member.valuetype)) # Boolean (string)
print("In DB gespeichert: {}".format(member.persistent)) # True
print("Derived: {}".format(member.derived)) # False
print("Null/Leer erlaubt: {}".format(member.allownull)) # False
print("Ist Attribute: {}".format(member.isattribute)) # True
print("Ist Linkrolle / Association: {}".format(member.isrole)) # False
print("Ist Single Rolle: {}".format(member.issinglerole)) # False
print("Ist Multi Rolle: {}".format(member.ismultirole)) # False
print("Spaltenname: {}".format(member.columnname)) # Active
print("Length: {}".format(member.length)) # 255, nur relevant bei Strings
print("Backlink auf 'Project' ClassInfo: {}".format(member.classinfo.name)) # Projekt/Project

role_member = typeinfo.memberbyname("Customer") # Info über die Association zum Kunden
# Attribute wie oben, ausser "valuetype" und "derived", dafür:
print("Linkklasse: {}".format(role_member.linkclass)) # None
print("Sortierung: {}".format(role_member.ordered)) # True
print("Attributsname auf der anderen Seite: {}".format(role_member.otherend.name)) # projekte/projects

Netherlands

United Kingdom