Skip to content

Commands on Project Level

  • cna.project_area() returns the area of the project in m²
  • cna.calc_all_imm() recalculates all receivers
  • cna.limit.calc() recalculates limits of the project
  • cna.print() writes in the output dialog
  • cna.load_file()loads CadnaA projects
  • cna.import_file() imports CadnaA projects (all objects)
  • cna.save_file()saves CadnaA projects
  • cna.redraw() redraws the limits
  • cna.import_file_ascii(p,o,x,y,z,d) imports ASCII files, where p is the file path, o the object type to be imported (integer), x the column No. of the X coordinate (default: 1), y the column No. of the Y coordinate (default: 2), z the column No. of the Z coordinate (default 3) and d an optional separator as string (default: nil, in this case the semicolon is assumed).
  • cna.import_citygml(p, b, d) imports CityGML files, where p is the file path, b the setting for „Building geometry for LoD2“ in the same order as shown in the dialog with possible values 1...4 and d the setting for „Reconstruct DTM from buildings ground floors“ with values true/false.
  • cna.export_raster_ascii(p) saves the present grid as ASCII grid via file path p.
  • cna.export_raster_shape(p) saves the present grid as SHP file via file path p.
  • cna.export_report_text(p) saves the report as TXT file via file path p.
  • cna.tables addresses CadnaA table objects (see Grid and Grid Arithmetics)
  • cna.get_ini_path() returns the file path and file name of the file CADNAA.INI
  • cna.polygons_are_intersecting(poly1, poly2) returns true if polygon poly1 and polygon poly2 have intersecting edges, false otherwise. In the case of identical polygons it returns false. Example:
if cna.polygons_are_intersecting(mybuilding.poly, myroad.poly) then 
    mybuilding.poly.MARK=1 
end
  • cna.set dirty () advices CadnaA that the current project has been changed. (Note: Many LUA functions call this function automatically, but not all.)
  • cna.is_dirty() checks whether unsaved changes have occurred to the CadnaA project
  • cna.quit_at_once() terminates CadnaA, unsaved changes are lost!
  • cna.version() returns the current CadnaA release as a string
  • cna.messagebox_timeout(x) defines the time in seconds after which the dialog boxes are closed automatically.

Note

This function can be used to bypass the „No Multithreading“ message, for example, with calculations using the Nord2000 standard.

  • cna.activate_protocol() activates/deactivates the protocol generation with parameter true/false
  • cna.protfile() returns the name of the log file as a string. As second parameter, a user-defined output path can be defined.
  • cna.set_weighting() defines the weighting method at menu Options | Miscellaneous with parameters 0...4.
  • cna.get_weighting(), get-function analogous to cna.set_weighting()
  • cna.getobj() provides direct access to an object from an object table (instead of iterating using cna.tables).Parameter options (The subsequent examples refer to the second entry in the „Point Source“ table): - HOBJ as hexadecimal String or integer: „0x0C000001“ or 201326593 - number of object type + index in table: (12, 2) - object type as string (see table at end of chapter) + index in table: („PQ“, 1)
  • cna.hobj(x) returns the HOBJ as an integer of the passed object p
  • cna.plot_designer_print_all() print all pages of the current PlotDesigner project via the selected printer
  • cna.plot_designer_num_pages () returns the number of pages of the current PlotDesigner project
  • cna.plot_designer_print_page (X) prints only the one-based page X of the current PlotDesigner project
  • cna.set_scale(d) sets the scale to 1:d
  • cna.get_ini_entry(s,k) reads from the file CADNAA.INI, using variables s, k - see below)
  • cna.set_ini_entry(s,k,v) writes to the file CADNAA.INI, using the variables:
    • s = section (section name in the INI file)
    • k = key (expression in front of the equal sign)
    • v = value (value after the equal sign)
  • cna.scandir(path, ext) returns a lua table with absolute pathes to all files in this directory / all subdirectories. With the second argument ext a filter for a specific file type can be defined, e.g., "*.cna" returns CadnaA files only. If no filter should be applied, ext has to be set to "*". Since the Windows function called with "*cna" sometimes also returns files with the extension ".cnaprot", separate filtering with Lua may be necessary, see the following example:
files = cna.scandir("C:\\tmp")

for _, file in pairs(files) do 
    if file:match("%.cna$") then  -- additional filter with lua string function match()
        cna.print(file)
    end
end