Skip to content

Table-Object

CadnaA table objects of namespace cna.tables. Here tabobj is a wild card for identifiers of the table Table here.

  • for obj in cna.tables.tabobj:all() do .. iterate over all objects (i.e. rows) of the table.
  • for obj in cna.tables.tabobj:all{...} do iterate over all objects (i.e. rows) of the table that satisfy the conditions of the parameters:
    • id="identi" only elements with given ID. The ID parameter cna be a pattern i.e. id="!01!*" could be used to match a specific ObjectTree definition.
    • active_only=true only active elements
  • local cnaobj = cna.tables.tabobj:first_by_id (id) yields the first element with the given id
  • local newobj = cna.tables.tabobj:append() creates a new object and appends it to the end of the table.
  • local num_rows= #tabobj number of table rows (objects)
  • X:break_lines(Y) calls for the „Break Lines“ feature, where X is the objects at which breaking occurs and Y the object which is broken (not work for/with point objects).Example: breaking at buildings:
for x cna.tables.Haus:all() do
    x:break_lines(...)
  • cnaobj.clone() duplicates an object. In case successful, the cloned object will be returned, otherwise nil.
  • regular expressions for object selection: When iterating over CadnaA objects like „Building“, etc. a regular expression can be supplied for the ID parameters. For example, it is possible to use the ObjectTree naming scheme to only iterate over certain branches of the ObjectTree, or to iterate over objects with a certain ID pattern. The regular expression engine is identical to the one used in the CadnaA dialogs:
cna.print("BEZ\tID\t\tActive?")
local i
for i in cna.tables.Haus:all{id="!0*!*1"} do
    cna.print(string.format("'%s'\t'%s'\taktiv: %d", i.BEZ, i.ID, i.MARK))
end
local i = cna.tables.Haus:first_by_id("!*!a1")
cna.print(string.format("'%s'\t'%s'\taktiv: %d", i.BEZ, i.ID, i.MARK))
  • Facades can be excluded in the „Building Evaluation“ object. For this purpose, the operator facades establishes a reference to the façades. This enables to either include or exclude the façades with the [ ] operator, where 1 is excluded and 0 is included. A prerequisite is a valid building evaluation within a building with a real positive height. The maximum number of facades per building is 256.Example:
for k in cna.tables.bld_eval:all() do
    fac = k.facades
    if fac then - check if valid
        for i=1, #fac, 1 do
            fac[i] = 1 -- exclude like this
            fac[i] = 0 -- include like this
        end
    end
end