Download as pdf or txt
Download as pdf or txt
You are on page 1of 80

ARCHICAD

scripting language C++


programmer's guide

1
Welcome to the site of our scale models workshop
www.Maquettes.ru

You will see and be able to order perhaps the most beautiful building scale models.

2
Introduction
This manual is a complete reference to the LabPP's C++ scripting language for GRAPHISOFT® ARCHICAD®.
The manual is recommended for those users who wish to expand on the possibilities presented by the
GRAPHISOFT® ARCHICAD® - great BIM CAD software for architects. It gives a detailed description of C++
scripting for ARCHICAD, including syntax definitions, commands, variables, etc.
Applying scripts on this language is available in add-ons LabPP_Automat and any add-ons, that includes LabPP C++
interpreter for ARCHICAD.

3
Table of contents
General overview ........................................................................................................................................................... 12
My first programm ......................................................................................................................................................... 12
C ++ semantics for ARCHICAD ........................................................................................................................................ 13
General structure of the program .............................................................................................................................. 13
Function main() .......................................................................................................................................................... 13
Identifiers ................................................................................................................................................................... 14
Variable Types ............................................................................................................................................................ 14
Comments .................................................................................................................................................................. 14
Comment to the end of the line - // comment ...................................................................................................... 14
Comment on several lines / * comment * /........................................................................................................... 15
Cycle organization ...................................................................................................................................................... 15
Cycle for.................................................................................................................................................................. 15
Cycle do-while ........................................................................................................................................................ 15
Cycle while.............................................................................................................................................................. 16
Logical operations .................................................................................................................................................. 16
Conditional transitions ............................................................................................................................................... 16
Operator if .............................................................................................................................................................. 16
Construction if-else ................................................................................................................................................ 17
Construction if-else if-else ..................................................................................................................................... 17
Operarot switch...................................................................................................................................................... 17
Creating your own functions (subroutines) ............................................................................................................... 18
Directive #include................................................................................................................................................... 19
Shell functions ................................................................................................................................................................ 20
shell_func ................................................................................................................................................................... 20
get_path ................................................................................................................................................................. 20
set_cur_dir ............................................................................................................................................................. 20
shellexecute ........................................................................................................................................................... 20
Output to the message box - cout ................................................................................................................................. 21
4
File operations................................................................................................................................................................ 21
open ....................................................................................................................................................................... 21
write ....................................................................................................................................................................... 22
close ....................................................................................................................................................................... 22
String functions .............................................................................................................................................................. 23
strcmp ........................................................................................................................................................................ 23
tolower ....................................................................................................................................................................... 23
toupper....................................................................................................................................................................... 23
alltrim ......................................................................................................................................................................... 24
strcontains .................................................................................................................................................................. 24
strreplace ................................................................................................................................................................... 24
Work with ARCHICAD ..................................................................................................................................................... 25
Object ac_element_guid ............................................................................................................................................ 25
Object ac_element ..................................................................................................................................................... 25
ac_request() ............................................................................................................................................................... 25
store_cur_element_to_descr................................................................................................................................. 25
set_current_element_from_descr ......................................................................................................................... 25
get_guid_from_element ........................................................................................................................................ 25
load_element_from_guid ...................................................................................................................................... 26
load_elements_list ................................................................................................................................................. 26
add_elements_list .................................................................................................................................................. 27
load_elements_list_from_selection и add_elements_list_from_selection .......................................................... 27
load_elements_list_curdb...................................................................................................................................... 27
clear_list ................................................................................................................................................................. 27
get_loaded_elements_list_count .......................................................................................................................... 28
select_elements_from_list..................................................................................................................................... 28
set_current_element_from_list ............................................................................................................................. 28
Work with layers - layer ......................................................................................................................................... 28
get_element_overall_dimensions.......................................................................................................................... 29

5
get_quantity_value ................................................................................................................................................ 29
get_layer_by_substring .......................................................................................................................................... 38
elem_user_property .............................................................................................................................................. 39
get_gdlelem_property_value ................................................................................................................................. 41
get_object_property_value ................................................................................................................................... 42
set_object_property_value .................................................................................................................................... 42
set_object_property_value_curdb ........................................................................................................................ 42
get_element_value ................................................................................................................................................ 43
set_element_value................................................................................................................................................. 43
assign_element_values .......................................................................................................................................... 43
load_element_default_values ............................................................................................................................... 43
set_element_infoidtext.......................................................................................................................................... 43
create_element_on_project .................................................................................................................................. 44
get_element_infoidtext ......................................................................................................................................... 44
project_property .................................................................................................................................................... 44
autotext .................................................................................................................................................................. 44
interface_input2dline............................................................................................................................................. 46
interface_input3dline............................................................................................................................................. 46
interface_input2dpoly............................................................................................................................................ 47
ac_typeidfromstring() ................................................................................................................................................ 47
ac_getresvaluetype().................................................................................................................................................. 47
ac_getstrvalue().......................................................................................................................................................... 48
ac_getnumvalue() ...................................................................................................................................................... 48
For application configuration ......................................................................................................................................... 48
setcfg()........................................................................................................................................................................ 48
Number of decimal places - ROUNDINGPRECISION............................................................................................... 48
Dialogues ........................................................................................................................................................................ 49
Messages or option - tsalert() .................................................................................................................................... 49
File search and selection ............................................................................................................................................ 49
Enter a number or string ............................................................................................................................................ 50
6
editdoubledialog .................................................................................................................................................... 50
editstringdialog ...................................................................................................................................................... 51
Gravity to surface (LABPP) ............................................................................................................................................. 51
Landing elements - do_elements_landing ................................................................................................................. 51
Landing points - do_surface_landing ......................................................................................................................... 51
Landing point X,Y - do_point_landing ........................................................................................................................ 52
Work with Excel.............................................................................................................................................................. 53
excel_attach ............................................................................................................................................................... 53
excel_detach .............................................................................................................................................................. 53
excel_putnumvalue .................................................................................................................................................... 53
excel_putstrvalue ....................................................................................................................................................... 54
excel_select_range ..................................................................................................................................................... 54
excel_visible ............................................................................................................................................................... 54
excel_speedup............................................................................................................................................................ 54
excel_getnumvalue .................................................................................................................................................... 55
excel_getstrvalue ....................................................................................................................................................... 55
excel_request ............................................................................................................................................................. 55
set_column_width ................................................................................................................................................. 55
get_column_width ................................................................................................................................................. 55
set_row_height ...................................................................................................................................................... 56
get_row_height ...................................................................................................................................................... 56
set_borders ............................................................................................................................................................ 56
get_borders ............................................................................................................................................................ 56
put_selection_values ............................................................................................................................................. 57
put_selection_fontvalues....................................................................................................................................... 57
get_selection_area ................................................................................................................................................. 57
merged_cell_info ................................................................................................................................................... 57
is_merge_cells ........................................................................................................................................................ 57
set_backcolor ......................................................................................................................................................... 57
7
get_backcolor ......................................................................................................................................................... 57
set_interior ............................................................................................................................................................. 57
get_interior ............................................................................................................................................................ 57
selection_varvalues ................................................................................................................................................ 57
selection_font_varvalues ....................................................................................................................................... 57
sheet_select ........................................................................................................................................................... 57
range_copy ............................................................................................................................................................. 57
booknamedcell ....................................................................................................................................................... 57
Work with Word ............................................................................................................................................................. 58
word_attach ............................................................................................................................................................... 58
word_detach .............................................................................................................................................................. 58
word_visible ............................................................................................................................................................... 58
word_request ............................................................................................................................................................. 58
Reading and writing variable fields - docfield ........................................................................................................ 58
update_all_docfields .............................................................................................................................................. 59
Internal objects .............................................................................................................................................................. 59
Function object .......................................................................................................................................................... 60
create ..................................................................................................................................................................... 60
delete ..................................................................................................................................................................... 60
Objects for processing tabular data ............................................................................................................................... 60
Function ts_table........................................................................................................................................................ 60
add_column............................................................................................................................................................ 60
set_first_key ........................................................................................................................................................... 61
add_row ................................................................................................................................................................. 61
add_row_sum ........................................................................................................................................................ 62
sort ......................................................................................................................................................................... 62
search ..................................................................................................................................................................... 63
select_row .............................................................................................................................................................. 63
get_value_of........................................................................................................................................................... 63
get_rows_count ..................................................................................................................................................... 63
8
get_columns_count................................................................................................................................................ 63
Standard Library Functions ............................................................................................................................................ 64
Converting .................................................................................................................................................................. 64
atoi ......................................................................................................................................................................... 64
itoa ......................................................................................................................................................................... 64
atof ......................................................................................................................................................................... 64
ctos ......................................................................................................................................................................... 64
Mathematical functions ............................................................................................................................................. 65
abs .......................................................................................................................................................................... 65
max ......................................................................................................................................................................... 65
min.......................................................................................................................................................................... 65
rand ........................................................................................................................................................................ 65
ln ............................................................................................................................................................................. 65
log ........................................................................................................................................................................... 66
sqrt ......................................................................................................................................................................... 66
sqr ........................................................................................................................................................................... 66
pow......................................................................................................................................................................... 66
percent ................................................................................................................................................................... 66
Trigonometric functions ............................................................................................................................................. 66
cos .......................................................................................................................................................................... 66
sin ........................................................................................................................................................................... 66
arcsin ...................................................................................................................................................................... 66
arccos ..................................................................................................................................................................... 66
tg ............................................................................................................................................................................ 67
arctg........................................................................................................................................................................ 67
ctg ........................................................................................................................................................................... 67
arcctg ...................................................................................................................................................................... 67
Functions for converting angular values .................................................................................................................... 67
grad_to_radian ....................................................................................................................................................... 67
radian_to_grad....................................................................................................................................................... 67

9
putchar ................................................................................................................................................................... 68
sprintf ..................................................................................................................................................................... 68
ecvt_french ............................................................................................................................................................ 68
tsround ................................................................................................................................................................... 68
tsround_best .......................................................................................................................................................... 68
floor ........................................................................................................................................................................ 69
ceil .......................................................................................................................................................................... 69
Geometric Transformation Functions - geometry_calc_2d ....................................................................................... 69
is_point_on_element_polygon .............................................................................................................................. 69
rotate_point_and_move ........................................................................................................................................ 71
get_cross_point_of_2lines ..................................................................................................................................... 71
get_rot_and_move_point ...................................................................................................................................... 71
get_length_2point.................................................................................................................................................. 72
is_point_on_line..................................................................................................................................................... 72
get_line_angle_relative_to_center ........................................................................................................................ 72
Special functions ........................................................................................................................................................ 73
Measurement of the execution time of the code fragment - codemeter ............................................................. 73
Save text from message window to file - ac_save_messages_to_file ................................................................... 73
The connection with the apartment calculation programm (LabPP_Solaris) ................................................................ 74
Test of communication with - ac_request("solaris_test") ......................................................................................... 74
Get a room list of apartment - ac_request("get_flat_rooms"...) ............................................................................... 74
runtimecontrol ........................................................................................................................................................... 75
workline.................................................................................................................................................................. 75
Commands for managing the application LabPP_Calc................................................................................................... 75
interface ..................................................................................................................................................................... 75
calc_field ................................................................................................................................................................ 75
Data exchange between programs - external variables ................................................................................................ 76
var_extern_set ........................................................................................................................................................... 76
var_extern_get ........................................................................................................................................................... 76
Run another program - run_cpp .................................................................................................................................... 77
10
run_from_file ............................................................................................................................................................. 77
run_from_variable ..................................................................................................................................................... 77
Getting arguments inside the program ...................................................................................................................... 78
Interface functions LabPP_Automat .............................................................................................................................. 78
create_iconbutton...................................................................................................................................................... 79
create_button ............................................................................................................................................................ 79
set_palette_size_and_message_place................................................................................................................... 79
Error processing ............................................................................................................................................................. 80

11
General overview
You can run any of scripts with LabPP add-ons for ARCHICAD.
As the basis of the programming language in LabPP_Automat, the well-known, simple and flexible C ++ language is used.The
advantages of this language are:
- high execution speed;
- water readability, conciseness and clarity of the code;
- ease of creation and access to functions;
- A large library of various procedures.
- its development is much easier and it is more convenient for work.
For more convenient use of language constructs, a string data type has been added to LabPP_Automat.
If you set the function MyStringFunc, which returns a string value, you can write like this:
string MyString = MyStringFunc ();
Here we immediately declare a variable of type "string" MyString and immediately write to it the value from the function
MyStringFunc ().
There are limitations with which the creation of programs is greatly simplified:
1. You can use only built-in classes through descriptors.
2. missing pointers.
3. missing data type "link".
Program modules are created as separate text files.
On www.labpp.net you can download examples.

My first programm
Create a file and paste the following into it.
int main()
{
cout << "Hello, World!)))";

12
}

In labpp, select and execute this file.


A greeting will appear in the message box.

C ++ semantics for ARCHICAD


General structure of the program
The program must contain the main () function with which its execution begins.
You can create subroutines. Declare variables.
Variables can be global and local.
The overall structure of the program is shown below.
int my_global_var1 = 1; // declare a variable of type integer and assign it an initial value.
double my_global_var2; // declaration of a real type variable
int main()
{
int my_local_var = 2; // declaration of integer type
my_local_var = my_func(); // function call my_func () with assignment of the result to a variable
}
// declaration of an own function returning an integer
int my_func()
{
int my_local_var = 3; // declaration of an integer type variable inside a function
return 10; // the value that the function returns
}

Function main()
Each program file must contain the basic function main ().
This function is called when the program starts. Like all C ++ functions, its contents are enclosed in braces.
General structure

13
int main()
{
/ / function body enclosed in braces
return 0;
}

In order to be able to get data from outside the program, there are two options - getting the arguments with which the program is
running (run_cpp ("get_args", ...)) and getting the values of external variables initiated by other programs (var_extern_get).

Identifiers
Identifiers are the names of variables and functions. Names may be in English only. Uppercase and lowercase letters do not differ. So
that the int iValue variable and the int IVALUE are the same.

Variable Types
In the program, you can declare and use variables with the following data type:
bool - boolean (values 0-false / 1-true).
int is an integer.
double - the everlasting number (float).
string is a string variable.
Example.
Declare a string variable and write several words into it.
string mystring;
mystring = "fragment1" + "fragment2";
mystring += "fragment3";

Comments
Comment to the end of the line - // comment
After the // end of the line, the expression is considered a comment.
Example:
int i=0; // here we declare a variable - an integer and assign it a value of 0

14
Comment on several lines / * comment * /
Text between the notation / * and * / regardless of the number of lines is considered a comment.
Example:
/* If you need to write a long explanation on several lines in the text of the program
or comment out a program fragment,
it is convenient to do so */

Cycle organization
Cycle for
The classic form of looping for C ++.
It is possible to interrupt the execution of a loop anywhere by the break directive;
Note. Braces are required. Declaring a loop variable inside a for (...) clause is not allowed.
Example.
Write in the message box the phrase "Hello World" 10 times.
int i;
for(i=0;i<10;i++)
{
cout << "Hello World!";
}

Cycle do-while
int i;
i=0;
do {
cout << i; // Display the value of the LabPP_Automat message box i
i++; // Increment i by 1
} while (i<10) // Cycle as long as i is less than 10

15
Cycle while
int i;
i=0;
while(i<10) {
cout << i;
i++;
}

Logical operations
== Equality True, if the number or line on the left is equal to the number or line on the right
! = Inequality True if the number or line on the left is NOT equal to the number or line on the right
< Less True, if the number on the left is less than the number on the right
<= Less than or equal to True, if the number on the left is less than or equal to the number on the right
> True if the number on the left is greater than the number on the right.
> = Greater than or equal to True if the number on the left is greater than or equal to the number on the right.
&& logical AND

If the expression on the left and right is true, then the result is true. If at least one of the expressions on the left or on the right is false,
then the result is false.
|| Logical OR If at least one expression to the left and right is true, then the result is true. If both expressions are false, the result is
false.

Conditional transitions
Operator if
if(i<0)
{
cout << "yes";
}

16
Construction if-else
if(i<0) // If the expression in brackets is true, the first fragment is executed.
{
cout << "yes";
}
else // If the expression in brackets is false, then the second fragment is executed.
{
cout << "no";
}

Construction if-else if-else

if(i<0) // If the expression in brackets is true, the first fragment is executed.


{
cout << "i<0";
}
else if(i==0) // If the expression in parentheses is true, then the second fragment is executed.
{
cout << "i=0";
}
else // If none of the expressions is true (else if clauses can be many)
{
cout << "i>0";
}

Operarot switch
В зависимости от значения числа в скобках выполняется соответствующих фрагмент программы.

switch(i)
{
case 1:
cout << "i=1";
break;
17
case 2:
cout << "i=2";
break;
case 10:
cout << "i=10";
break;
default:
// операторы, выполняемые при любом другом значении i
}

Creating your own functions (subroutines)


To make it easier to understand and adjust the text of the programs, you can select its fragments into separate subprograms.
The same is done with repeating fragments containing a significant number of lines of text in the program.
Such fragments are written below the main () function after its last brace.
They are given a name, equipped with input arguments and a return value.
Example.
Display text in the message window, depending on the code passed to the subroutine.
int main()
{
cout << "String from function with argument 1= " << get_string(1) << ", also but arg. 2 = " << get_string(2);
}
// function declaration, takes the argument arg - an integer.
// returns a string value.
string get_string(int arg)
{
string sresult;
if(arg==1) // if arg equally 1
{
sresult = "string 1"; // then assign this value to the variable sresult.
}
else if(arg==2) // if arg is 2
{
sresult = "string 2";
18
}
else // if neither 1 nor 2, then for any other value
{
sresult = "string N"; // set the sresult variable to this value.
}
return sresult; // return the contents of the sresult variable as a function value.
}

Several variables (arguments) can be passed to the subroutine at once. Then they are separated by commas.
Example.
Declare a function that takes two integers and one floating point number as arguments, and returns a floating point value.
double my_func(int a, int b, double c)
{
return 10;
}

Due to the fact that C ++ text has high execution speed, it is possible to create any number of eigenfunctions..

Directive #include
To use the same text or subroutines in different program files, it is convenient to place the text of programs in header files. Usually in
C ++ these files are given the extension .h or .hpp.
Appeal
#include "my_heading.hpp"
The code in the file my_heading.hpp will be inserted in this place of the program.
Unlike a normal program file, the code in the include file should not contain the main () function.
If for some reason the file is not found at runtime, there will be an error message.

19
Shell functions
shell_func
get_path
Set current directory.
Appeal:
int res = shell_func("get_path", string what, string result);

The variable what sets the return type of the path:


"rootconfig" - get the path to the root directory of the current configuration
"tsimages" - get the path to the directory of pictures of the current configuration
"tsprg" - get the path to the current configuration program directory
"rootaddons" - get the path to the directory where LabPP_Automat itself is located
The result is written to the result variable.

set_cur_dir
Appeal:
int res = shell_func("set_cur_dir", string path_or_what);

path_or_what - can be a path or a directive ("rootconfig", tsimages, tsprg or rootaddons).


Example. Set current directory "C:\\MyDir":
string mydir = "C:\\MyDir";
int res = shell_func("set_cur_dir",mydir);
if(res==0)
cout << " Working directory successfully changed ";
else
cout << " Set the directory to " << mydir <<" failed ";

shellexecute
Perform shell operation.
20
You can open files, send them to print, etc. with the help of the appropriate program specified at the operating system level.
Example. Open the "Example.xls" file located in the current configuration directory of LabPP_Automat.
int res = shell_func("set_cur_dir","rootconfig");
if(res !=0)
return -1;
res = shell_func("shellexecute","Example.xls");

The example.xls file will be opened using the program that is used by default for files with the .xls extension on the user's computer.
This is usually EXCEL.
This way you can open EXCEL files from ARCHICAD.

Output to the message box - cout


The cout command allows you to display information in a message box. Numeric data is converted automatically.
Command format:
cout << arg1 << arg2 << argN;
Here:
arg1, arg2, argN - any number of variables of any type.
Example
Display in the messages window the result of calculating the sum of the areas of all apartments from the variable dsum
cout << " Area of all apartments = " << dsum;

File operations
File operations are performed using the ts_file function. To access the required object handle type "ts_file".

open
Open file
Int ires = ts_file(int iFileDescr, "open", string filepath, string what, string mode);

21
Here: iFileDescr is the file object handle obtained when the object was created with the object command ("create" ..., filepath is the
file system path to the file system, what - what to do if the file is not found ("create" - create a new one, "fail" - give an error and stop,
"ignore" - ignore and continue).
mode - file opening mode:
"r" is read only
"w" - write only
"we" - to write clear the file
"rw" - for reading and writing
"a" - add to the end of the file
ires = ts_file(iFileDescr, "open",filepath,"create","we");

write
Write to file
int ires = ts_file(int iFileDescr, "write",string stowrite);
Here: iFileDescr is the file object handle, stowrite is the string to write to the file. Returns 0 if the record was successful. The number
of written characters can be read using the ac_getnumvalue () function;

close
Close file
int ires = ts_file(Int iFileDescr,"close");
Here: iFileDescr is the file object handle. Returns 0 if the file was successfully closed.

Example.
Create the file "my_file.txt" on the disk "C:" in the root directory and write several lines to it.
string filepath="c:\\my_file.txt";
int iFileDescr;
object("create","ts_file",iFileDescr); // create file type object in memory
// open a blank file for writing; if not, create
int ires = ts_file(iFileDescr, "open",filepath,"create","we");
if(ires != 0)
{
cout << " File failed to open:"<< filepath; // put in the message box
return;
22
}
ires = ts_file(iFileDescr, "write"," First line \nSecond line \n "); // write two lines to file
if(ires !=0)
{
cout << " Could not write to file ";
return;
}

ires = ts_file(iFileDescr, "write"," Third row "); // write the third line
ires = ts_file(iFileDescr,"close"); // close file
object("delete",iFileDescr); // remove file object from memory
cout << " Completion of the program \n";

String functions
strcmp
Two strings comparison
Appeal
bool result = strcmp(string s1, string s2);
Here:
string1 and string2 - string variables for comparison
The function returns 1 if the strings completely match.

tolower
Translate all characters in a string to lower case
Appeal
string sresult = tolower(string svalue);

toupper
Convert all characters in string to upper case.
23
Appeal
string sresult = toupper(string svalue);

alltrim
Remove all spaces from the beginning and from the end of the line.
Appeal
string sretult = alltrim(string svalue);

strcontains
Checks if a string contains a specified fragment.
Appeal
int ires = strcontains(string sstring, string sfragment);
Here:
sstring is a string in which you need to know if there is a sfragment fragment. If yes, then ires will get 1.

strreplace
Replace all fragments in the string with other fragments.
Appeal
string sresult = strreplace(string s, string fragmentold, string fragmentnew, int how, int pos, int count);
Here:
s - the string in which to replace the fragmentold fragment with the fragmentnew,
how - where to start from - 0/1/2 - all / from the beginning / from the end
pos - how much to retreat
count - how many to replace (-1 - completely).
Example.
Translate the floating-point number into a string and replace the point separating the integer and fractional parts with a comma.
double d_value = 126.983;
string s_value = sprintf("%10.3f", d_value);
s_value = strreplace(s_value, ".", ",", 0, 0, -1);

Result - 126,983
24
Work with ARCHICAD
Object ac_element_guid
Object ac_element
ac_request()
store_cur_element_to_descr
Save current item to ac_element_guid object.
To work with an element through the ac_request functions (... we make the element current. For example, this is done when we load
the elements into one of the internal lists and select the current position.
But you may need to keep its unique number for processing other functions. Then create an object of type ac_element_guid. When
creating an object, we get its descriptor - the internal number of the object. And with this handle, contact here. As a result, a unique
element number will be written to the ac_element_guid object.
Request format:
ac_request("store_cur_element_to_descr", int &iGuidDescr);
Here iGuidDescr is a handle to an object of the type ac_element_guid, in which the unique number of the current element will be
saved.

set_current_element_from_descr
Make current to work with ac_reauest commands (... an element from the ac_element_guid object. This is essentially the inverse
operation specified above.
Request format:
ac_request("set_current_element_from_descr", int &iGuidDescr);
Here iGuidDescr is the handle of an object of the type ac_element_guid, which will be set as the current one for working with the
ac_request functions (....

get_guid_from_element
Get the unique number of the ARCHICAD element from an object of type ac_element into an object of type ac_element_guid.

25
Such conversion may be required for technical purposes.
Request format:
ac_request("get_guid_from_element",int iElementDescr, int iGuidDescr);
Here:
iElementDescr - the ac_element dip object handle, from which a unique code will be written into an ac_element_guid object pointed
to by iGuidDescr.

load_element_from_guid
Load into the object of type ac_element the data of the element ARCHICAD, with a unique number (guid), which is specified in the
object of type ac_element_guid.
This is also a technical function to create the ability to work with an element through the mechanism of a special object ac_element.
Appeal:
ac_request("load_element_from_guid",int iElementDescr, int iGuidDescr);
Here:
iElementDescr - a handle to the ac_element dip object, into which we load the unique element code written in an object of the type
ac_element_guid, pointed to by iGuidDescr.

load_elements_list
Load the specified list with ARCHICAD elements according to the specified conditions
Appeal:
ac_request("load_elements_list",int iListNum,string sElemTypeName,"MainFilter",int iMainFilterValue,string
filterparametrname, string/double filterparametervalue,...);
Here:
iListNum - number of the internal list of items (from 0 ... 9).
sElemTypeName is the name of the item type. If you need to select any elements - "ZombieElemType", if only columns, then
"ColumnType", walls - "WallType", etc.
"MainFilter" - reports that we set the parameters for filtering items by the type of accessibility for editing, visibility, etc.
iMainFilterValue - usually the value for visible and editable items is 3.
Next come the names of the parameters and their meanings for additional selection.
For example, "ID", "ID value" - means that you need to select items with ID = "Value ID", etc.
The "MainFilter" filter can be omitted. This is equivalent to writing "MainFilter", 0.
Those. when forming the list, all relevant elements in the project will be included in it without taking into account the main criterion.
The value of the filter is calculated by the formula.
26
MainFilterValue=j1+2*j2+4*j3+8*j4+16*J5+32*j6+64*j7+128*j8+256*j9+512*j10+1024*j11+2048*j12+4096*j13+268435456*j14,
where each j can be 0 or 1.
j1: editable only.
j2: on the visible layer.
j3: on the current floor
j4: has an idea in 3d window
j5: in my workspace
j6: not subordinate but only independent elements
j7: on active drawing
j8: displayed inside the trimmed part of the drawing database

j9: indicates whether a change identifier in the variationID parameter is passed to this element
j10: element access rights
j11: element is visible in renovation
j12: additional flag; checks whether the element attributes are overridden by the current update filter
j13: additional flag; checks the visibility of an element with regard to the current structure mapping setting
j14: from 2d windows only

add_elements_list
Same as load_element_list, with the only difference that the list is not reset. So we can add to the list the items selected by any
parameters and any types..

load_elements_list_from_selection и add_elements_list_from_selection
Same as load_elements_list, only elements are taken from the number of selected elements in the current ARCHICAD window.

load_elements_list_curdb
Same as load_elements_list, but elements are selected without switching to another window and the current selection of elements is
saved..

clear_list
Clear the specified list of items.
Appeal:
ac_request("clear_list",int iListNum);
Here:
27
iListNum - the number of the internal list of items to be cleared.

get_loaded_elements_list_count
Determine the number of items in the specified list.
Appeal:
ac_request("get_loaded_elements_list_count", int iListNum);
Here:
iListNum - the number of the list from which the number of items is requested.
The result of the operation is read by the ac_getnumvalue () command;

select_elements_from_list
Highlight the items in the internal list with the specified number in the current ARCHICAD window.
Appeal:
ac_request("select_elements_from_list", int iListNum);
Here - iListNum - list number.

set_current_element_from_list
Set the current item with the specified index from the specified list.
Appeal:
ac_request("set_current_element_from_list", int iListNum, int index);
Here - iListNum - the number of the list,
index - the element in the list.

Work with layers - layer


create
Create layer in ARCHICAD.
get_index
Get the index of the layer in the ARCHICAD project.
set_layer_visible
Manage layer visibility.
Ablation:
ac_request("layer", string whatdo);
28
Here whatdo = "ON" / "OFF" / "SWITCH" enable, disable or switch the state (was turned off - turned on and vice versa).

get_element_overall_dimensions
Get the overall dimensions of the item.
Appeal:
ac_request("get_element_overall_dimensions", double &lx, double &ly, double &lz);
Here: lx, ly, sz - the returned values of the overall dimensions of the current element.

get_quantity_value
Get quantitative data from the current item
Appeal:
int iret = ac_request("get_quantity_value", string svaluename);
Here:
svaluename - the name of the calculated parameter of the current element,
iret - 0 if successful data acquisition occurred.
The result of the query is read by the function ac_getnumvalue ();
Example.
Select in the list # 1 items with ID = "s plot".
Sum the areas of the elements and display the result in the message window.
ac_request("load_elements_list",1,"ZombieElemType","ID","s area","MainFilter",3);
ac_request("get_loaded_elements_list_count", 1);
int icount = ac_getnumvalue();
cout << "Elements count=" << icount;
int i; // declare cycle variable.
double value; // variable for current area values
double summa=0; // variable for total area
for(i=0;i<icount;i++)
{
ac_request("set_current_element_from_list", 1, i);
ac_request("get_quantity_value", "Surface");
value = ac_getnumvalue();
cout <<"element № "<< i << ", area="<< value << "\n";
summa += value;
}

29
cout << "total area=" << summa;

Details
Different quantities are available for different types of items..
Walls - WallType:
volume - the wall's wolume;
length - average wall length:
volume сond - conditional volume;
volumeaskin - the volume of the wall covering from the reference line;
volumebskin - the volume of the wall covering on the reverse side of the reference line;
volumeaskincond is the conditional volume of the wall covering on the side of the reference line;
volumebskincond is the conditional volume of the wall covering on the reverse side of the reference line;
surfacereflineside - surface area on the side of the reference line;
surfacereflineoppside - surface area on the back side of the reference line;
surfaceofedge - surface area of the wall end;
surfacereflinesidecond - conditional surface area on the side of the reference line;
surfacereflineoppsidecond - conditional surface area on the back side of the reference line;
surfacewindows - the area of window openings;
surfacedoors - the area of doorways;
surfacetmptyholes - the area of unfilled openings;
columnsvolume - the volume of columns in the wall;
columnsnumber - the number of columns in the wall;
widthofwindows - the total width of all windows;
widthofdoors - the total width of all doors;
minheight - the minimum height of the wall;
maxheight - maximum wall height;
minheightaskin - the minimum height of the wall covering on the side of the reference line;
maxheightaskin - the maximum height of the wall covering on the side of the reference line;
minheightbskin - the minimum height of the wall covering on the back side of the reference line;
maxheightbskin - the maximum height of the wall covering on the back side of the reference line;
centerlength - the length of the wall along the center line;
area - the area of the wall support;

30
petimeter - wall support perimeter;
grossvolume - total wall volume;
grosssurfacereflineside - the total surface area of the wall along the side of the reference line;
grosssurfacereflineoppside is the total surface area of the wall on the back side of the reference line;
emptyholesvolume - analytical volume of openings in the wall;
emptyholessurfreflineside - analytical opening area in the wall from the side of the reference line;
emptyholessurfreflineoppside - analytical area of openings in the wall from the back of the reference line;
lengthonreflineside - the length of the wall along the side of the reference line;
lengthonreflineoppside - the length of the wall on the reverse side of the reference line;
lengthonreflinesidecond - conditional length of the wall from the side of the reference line;
lengthonreflineopp sideside - conditional length of the wall from the back of the reference line:
insulationskinthickness - wall insulation thickness;
wallairskinthickness - thickness of the air gap in the wall;
skinreflinethickness - insulation thickness along the side of the reference line;
skinreflineoppthickness - insulation thickness from the back side of the reference line;
reflinelength - the length of the wall along the reference line.
ColumnType:
surface - area;
coresurface - base area of the column;
venesurface - finishing area;
volume - volume;
veneervolume - the amount of finish;
minheight - minimum height;
maxheight - maximum height;
perimeter - perimeter;
area - area;
grosssurfaceofcore - gross surface area of the base;
grosssurfaceofveneer - gross surface area of the finish;
coregrossvolume - gross bulk of the column footing;
veneergrossvolume - gross bulk of the column base;
coretopsurface - surface area of the upper part of the column base;
corebottomsurface - surface area of the column footing;
31
veneertopsurface - surface finish on top;
veneergrosssurface - gross surface finish below;
coregrosstopandbotsurface - gross surface of the base at the top and bottom;
veneergrosstopandbotsurface - gross surface finish at the top and bottom.
BeamType:
rightlength - jumper length on the right side of the reference line;
leftlength - jumper length on the left side of the reference line;
length - average length;
bottomsurface - lower surface area;
topsurface - upper surface area;
edgesurfaceleft - surface area to the left of the reference line;
edges surface - the surface area to the right of the reference line;
The edgesurface is the surface area of both ends of the web;
holessurface - surface cutouts;
holesedgesurface - area of cuts on the side faces of the lintel;
holesnumber - the number of cuts;
volume - volume;
condvolume - conditional volume;
holesvolume - the volume of the notches;
WindowType:
openwidthrevside - the width of the opening on the opening side;
openwidthrevsideopp - width of the opening on the side opposite to the disclosure;
openheightrevside - opening height on the opening side;
openheightrevsideopp - height of the hole on the side opposite to the disclosure;
opensurfacerevside - opening surface on the opening side;
opensurfacerevsideopp - opening surface on the side opposite to the disclosure;
nominalopenwidthrevside - the nominal opening width on the opening side;
nominalopenwidthrevsideopp - the nominal opening width on the side opposite to the disclosure;
nominalopenheight revside - - the nominal opening height on the opening side;
nominalopenheightrevsideopp - nominal opening height on the side opposite to the disclosure;
nominalopensurfacerevside - nominal opening surface from the side of disclosure;
nominalopensurfacerevsideopp - nominal opening surface on the side opposite to the disclosure;
32
volume - volume;
nominalopensurgace - nominal opening area;
nominalopenvolume - nominal opening volume;
surface - area;
nominalsillheight - nominal sill height;
nominalsillheightrevside - the height of the sill on the opening side;
nominalsillheightrevsideopp - the height of the window sill on the side opposite to the disclosure;
nominalheadheight - the nominal height of the window head;
nominalheadheightrevside height of the window head on the side of disclosure
nominalheadheightrevsideopp - height of the window head on the side opposite to the disclosure;
sillheightaccvertanchor - sill height in accordance with the vertical anchor;
headheightaccvertanchor - height of the window head in accordance with the vertical anchor.
DoorType:
openwidthrevside - - opening width on the opening side;
openwidthrevsideopp - width of the opening on the side opposite to the disclosure;
openheightrevside - opening height on the opening side;
openheightrevsideopp - height of the hole on the side opposite to the disclosure;
opensurfacerevside - opening surface on the opening side;
opensurfacerevsideopp - opening surface on the side opposite to the disclosure;
nominalopenwidthrevside - the nominal opening width on the opening side;
nominalopenwidthrevsideopp - the nominal opening width on the side opposite to the disclosure;
nominalopenheightrevside - the nominal opening height on the opening side;
nominalopenheightrevsideopp - nominal opening height on the side opposite to the disclosure;
nominalopensurfacerevside - nominal opening surface from the side of disclosure;
nominalopensurfacerevsideopp - - the nominal opening surface on the side opposite to the disclosure; "
volume - volume;
nominalopensurgace - nominal opening area;
nominalopenvolume - nominal opening volume;
surface - area;
nominalsillheight - nominal sill height;
nominalsillheightrevside - the height of the threshold of the door on the opening side;
nominalsillheightrevsideopp - the height of the door threshold on the side opposite to the disclosure;
33
nominalheadheight - the nominal height of the door head;
nominalheadheightrevside - the nominal height of the door head on the opening side;
nominalheadheightrevsideopp - height of the door head on the side opposite to the disclosure;
sillheightaccvertanchor - threshold height in accordance with the vertical anchor;
headheightaccvertanchor - height of the door head in accordance with the vertical anchor.
ObjectType:
volume - the volume;
surface - area of the 2d symbol.
LampType:
volume - the volume;
surface - area of the 2d symbol.
SlabType:
bottomsurface - reference surface area;
surface - the area of the upper surface;
edgesurface is the area of side edges;
condbottomsurface - conditional surface area;
condtopsurface - conditional area of the upper surface;
volume - volume;
condvolume - conditional volume;
perimeter - perimeter;
holessurface - cut area;
holesperimeter - cut perimeter;
grossbottomsurface - total surface area;
grosstopsurface - total surface area;
grossedgessurface - the total surface area of the faces;
grossvolume - total volume;
grossbottomsurfacewithholes - the total area of the supporting surface, along with the notches;
grosstopsurfacewithholes - the total area of the upper surface along with the notches;
grossedgessurfacewithholes - the total area of the edges, along with the notches;
grossvolumewithholes - total volume with cutouts.

34
RoofType:
bottomsurface - internal surface area;
topsurface - upper surface area;
edgesurface is the area of side edges;
condbottomsurface - conditional area of the inner surface;
condtopsurface - conditional area of the upper surface;
volume - volume;
сondvolume - conditional volume;
perimeter - perimeter;
holessurface - cut area;
holesperimeter - perimeter area;
grossbottomsurface - total internal area;
grosstopsurface - total surface area;
grossedgesurface - the total area of the faces;
areacontourpoligon - roof area by contour polygons;
grossvolume - total volume;
insskinthickness is the thickness of the insulation layer;
lengthofridgeedgesdiv2 - the length of the edges of the rib type, divided by 2;
lengthofvalleyedgesdiv2 - the length of the faces of the flume type, divided by 2;
lengthofgableedges - gable length;
lengthofhipedgesdiv2 - the length of the ribs of the type of the thigh, divided by 2;
lengthofeaveedges - the length of edges such as edges;
lengthofpeakedges - the length of the edges of the peak type;
lengthofsidewalledges - the length of the edges of the side walls;
lengthofendwalledges - the length of the edges of the type of the end of the walls;
lengthofrtdomeedgesdiv2 - the length of the edges of the type rtdom, divided by 2;
lengthofrthollowedgesdiv2 - the length of the edges of the type rthollow, divided by 2;
sumofopeningssurfaces - the total area of openings in the roof;
numofholes - the number of cuts;
numofskylight - the number of skylights.
MeshType:
bottomsurface - reference surface area;
35
topsurface - upper surface area;
edgesurface is the area of side edges;
volume - volume;
perimeter - perimeter;
holessurface cut-out area;
holesperimeter - cut perimeter;
projectedarea - projection area;
ZoneType:
area - area of the zone;
perimeter - perimeter;
holesperimeter - cut perimeter;
wallsperimeter - perimeter walls;
numberofcornersprojectedarea - the number of corners of the zone;
numberofconcavecorners - the number of concave corners of the zone;
surfaceareaofperimeterwall - the surface area of the walls around the perimeter of the zone;
widthofdoors - the width of all doors in the walls around the perimeter of the zone;
surfaceofdoors - the area of all doors in the walls around the perimeter of the zone;
widthofwindows - the width of all windows in the walls around the perimeter of the zone;
surfaceofwindows - the surface area of all windows in the walls around the perimeter of the zone;
floorlevel - the level of the floor in the zone;
subfloorthickness - thickness under the floor in the zone;
height - height;
netarea - net area of the zone;
netperimeter - clean perimeter;
volume - zone volume;
areareducement - the magnitude of the reduction in area;
calcarea - calculated area;
totalextractedarea - deducted area near the zone;
reducedextractedarea - reduced area of the zone;
lowareaofzone - subtracted lower part of the zone;
extractedwallarea - deducted area due to walls;
extractedcolumnarea - the area deducted from the columns;
36
extractedfillarea - area deducted due to hatching;
wallincettopsurface - the top surface of the wall insert;
wallincetbacksidesurface - the back side of the wall;
wallincetsidesurface - side surface of the wall insert;
tsfloorplintuslength - the length of the plinth, taking into account the doors (if it is possible to lay the plinth under the door, then we
count);
tsseilingplintuslength - the length of the ceiling plinth;
HatchType:
surface - surface area;
perimeter - perimeter;
holesperimeter - cut perimeter;
holessurface - cut-out area.
LineType:
length - line length.
PolyLineType:
length - polyline length.
ArcType:
length - arc length.
CircleType:
length - Circle length.
SplineType:
length -spline length.
ShellType:
bottom_surface - bottom surface area; ")
top_surface - surface area on top;
volume - volume;
surface - the surface area along the reference line;
holes_surface — cutout area.

37
MorphType:
surface - surface area;
volume - volume;
floorplanprojarea - support area;
elevation - elevation;
baseheight - base height - the height range from the lowest point of the inward sloping edges to the highest point in the floor relative
to the floor;
height - body height;
floorplanprojperimeter - projection perimeter in the plan;
numberofnodes - the number of vertices;
numberofedges - the number of edges;
numberofhiddenedges - the number of invisible edges;
numberofsoftedges - the number of "soft" edges;
numberofvisiblenodes - the number of visible vertices;
numberoffacenodes - the number of faces in the body.
length_edges - the length of all edges (visible and invisible).
length_edge_max - the length of the longest edge

get_layer_by_substring
Get the full name of the layer on a partial fragment.
Required when users agree to name layers in ARCHICAD with numeric or text prefixes.
For example, the layer "Apartments" can be written as "01 Apartments" or "20 Apartments". This approach occurs when the user
wants to establish a convenient order of layers in the project.
However, from the point of view of the program, these are completely different layers.
To avoid errors, it is convenient to use this function.
Appeal:
int ires = ac_request("get_layer_by_substring",string slayernamefragment, int from);
int ires = ac_request("get_layer_by_substring",string slayernamefragment, int from, int range);
Here:
slayernamefragment - a fragment in the name that accurately identifies the layer (for example, "Apartments").
from - the ordinal number of the symbol from the beginning of the full name of the layer in the project from which to start the
comparison for compliance.
range - the number of characters to check.
38
ires - 0 if the layer is found.
The full name of the found layer is read by the ac_getstrvalue () command;
Example.
Get the full name of the "Apartments" layer in the project, if you know that it is customary in the organization to use the "01" prefix
to sort the layers.
string smalllayername="Flats";
string longlayername;
ires = ac_request("get_layer_by_substring",smalllayername,3); // start the comparison from the 3rd position
if(ires != 0) {
tsalert(-1,"Runtime Error "," No detected layer ",smalllayername);
}
longlayername = ac_getstrvalue(); // read full layer name

elem_user_property
Custom item settings.
In ARCHICAD, you can assign your own properties to any element. These properties can be numeric, textual, logical, etc. According
to the value of these properties, an element can then be selected in interactive catalogs, it can be done by autochange when shown in a
window, etc. The following commands allow you to manipulate user-defined properties of elements in C ++ scripts.
get
Read the value of the user parameter for the current item.
Appeal:
int ires = ac_request("elem_user_property","get", string sparname);
Here:
svarname is the name of the parameter from which to get the value.
ires - 0 if considered successful.
The result is obtained by calling the ac_getnumvalue () or ac_getstrvalue () function;
Example.
Read the value of the logical parameter "Useful area of the building" from the current element.
string sUP = " Useful area of the building ";
int ires = ac_request("elem_user_property","get",sUP);
if(ires==0)
{
39
istrue = ac_getnumvalue();
if(istrue==1)
{
cout << " This zone refers to the usable area of the building. ";
}
}

set
Write a new value to the user parameter for the current item.
Appeal:
int ires = ac_request("elem_user_property","set", string sparname, bool/int/double/string value);
Here:
svarname is the name of the parameter.
value is the default value of the parameter. The type of the parameter is determined by the type of variable value transmitted here.
srazdel is the section in which the user variable will be created.
ires - 0- if the variable was created successfully.
Example.
Set the new value of the logical parameter "Useful area of the building" for the current element to the "true" position.
string sUP = " Useful area of the building ";
int istrue = 1; // The new value of the variable is 1, which means "true"
int ires = ac_request("elem_user_property","set",sUP,istrue);
if(ires==0)
{
cout << " New value set successfully ";
}

create
Create a custom parameter for the current item.
Appeal:
int ires = ac_request("elem_user_property","create", string sparname, string svartype, bool/int/double/string
value, string svartype, string spargroupname);
Here:
svarname is the name of the parameter being created.
value is the default value of the parameter.
40
svartype - Variable type - "String" / "Real" / "Integer" / "Boolean" - text, real, integer or logical.
spargroupname is the section in which the user variable will be created.
ires - 0- if the variable was created successfully.
Example.
To create a custom parameter "Useful area of the building" for the current item in the "Section of the TEP" section. The type of the
parameter is logical. The default is false..
string sUP = "Useful area of the building ";
string sUPRazdelName = " Section TEC";
int ires = ac_request("elem_user_property","create",sUP,0,"Boolean", sUPRazdelName);
if(ires==0)
{
int istrue = ac_getnumvalue();
if(istrue==1)
{
cout << " This zone refers to the usable area of the building.";
}
}

get_gdlelem_property_value
Get the parameter value of the current GDL item. It is used for elements like passport zone.
Appeal:
int iret = ac_request("get_gdlelem_property_value",string parametername);
The result of the call is read by the following ac_getnumvalue () or ac_getstrvalue () function to obtain a numeric or text value,
respectively.
Returns to iret 0- if the request was successful.
Example.
Get the value of the parameter "ROOM_AREA" (measured area value) from the current zone.
int iret = ac_request("get_gdlelem_property_value", "ROOM_AREA");
double darea;
if(iret == 0)
{
darea = ac_getnumvalue();
cout << darea; // write area in the message box

41
}

get_object_property_value
Get the parameter value of the current GDL item. Used for objects.
Appeal:
int iret = ac_request("get_object_property_value",string parametername);
The result of the call is read by the following ac_getnumvalue () or ac_getstrvalue () function to obtain a numeric or text value,
respectively.
Returns to iret 0- if the request was successful.
Example.
Get the value of the text parameter "SNAME" from the current object.

int iret = ac_request("get_object_property_value","SNAME");


string svalue;
if(iret == 0)
{
svalue = ac_getstrvalue();
cout << svalue; // write the resulting value in the message box
}

set_object_property_value
Write the new value to the parameter of the current GDL element. Used for objects.
Appeal:
int iret = ac_request("set_object_property_value",string parametername, string/double valuetowrite);
Returns to iret 0- if the record was successful.
Example.
Write in the current object the value of the text parameter "SNAME" - "my new name".
int iret = ac_request("set_object_property_value", "SNAME", "my new name");
if(iret == 0)
{
cout << " Record was successful";}

set_object_property_value_curdb
Same as set_object_property_value, but without changing the current ARCHICAD window.
42
get_element_value
Get the value of the current item variable.
Appeal:
int ires = ac_request("get_element_value", string svaluename);
Here:
svaluename is the variable name of the element.
The return value is 0 - if the request was successful.
The value of the variable is read by the following ac_getnumvalue () or ac_getstrvalue ();
Example.
Read the floor number of the current item..
int floornum;
int ires = ac_request("get_element_value","StoreIndex");
if(ires == 0)
{
floornum = ac_getnumvalue();
cout << "Floor number=" << floornum;
}

set_element_value
assign_element_values
Assign an element variable value. Changes data only in the ac_element object without affecting the project.
Appeal format:
ac_request("assign_element_values",int iElemDescr, string paramname, string/double/int paramvalue);

load_element_default_values
set_element_infoidtext
Give current item a new ID
Appeal:
ac_request("set_element_infoidtext", string svalue);
Here: svalue is the new ID value for the current item.

43
create_element_on_project
Create an element in the project based on current values from an object of type ac_element.
Appeal:
int ires = acrequest("create_element_on_project",int iElemDescr);
Here :
iElemDescr - the object handle that contains the data for the element created in the project.
ires - if successful, returns 0.

get_element_infoidtext
Read the current item ID.
Appeal:
int ires = ac_request("get_element_infoidtext");
The data is obtained by the following function ac_getstrvalue ();
ires - 0 if readout was successful.

project_property
autotext
Count, write or create autotext ARCHICAD.
There is a special set of variables in the project information. You can create variables yourself. The values of these variables can be
substituted into the text in various places of the project. The value of the text in these places will always correspond to the current
value of the project variable..
get
Read the variable value from the project information.
Appeal:
int iret = ac_request("autotext","get", string svarname);
Here: svarname is the name of the variable in the project information to be counted.
iret - 0, if it was considered without errors.
The result is obtained by calling the function ac_getstrvalue ();
Example.
Read the value of the object address variable from the project information.
string svaluename = "Address of the building";

44
int iret = ac_request("autotext","get", svarname);
if( iret == 0)
{
string saddress = ac_getstrvalue();
cout << "Address = " << saddress;
}
else
{
cout << "Can't read address. May be variable " << svaluename << " in the project not exist";
}

set
Set the value of the variable in the project information.
Appeal:
int iret = ac_request("autotext","set", string svarname, string svarvalue);
Example.
Write the new value to the variable "Address of the object" from the information about the project.
string svaluename = "Object address";
string snewvalue;
snewvalue = "Kursk, Vespremskaya, 3";
int iret = ac_request("autotext","set", svarname, snewvalue);
if( iret == 0)
{
cout << "Address successfully changed";
}
else
{
cout << "Can't write address. May be variable " << svaluename << " in the project not exist";
}

create
Create a variable with the specified name in the project information and assign a value to it.
int iret = ac_request("autotext","create", string svarname, string svalue);
Here:
svarname is the name of the new variable
45
svalue - the value for this variable,
iret - the result of the function. If 0, then the variable is created.
Example.
Create a new variable "Address of the object" in the information about the project and record the original value.
string svaluename = "Address";
string snewvalue;
snewvalue = "Kursk, Vespremskaya, 3";
int iret = ac_request("autotext","create", svarname, snewvalue);
if( iret == 0)
{
cout << "Variable created";
}
else
{
cout << "Creation of variable " << svaluename << " error";
}

interface_input2dline
User input 2d lines.
Appeal:
int iret ac_request("interface_input3dline", string sFirstMessage, string sSecondMessage, double x1, double
y1, double x2, double y2, double angleInRad, double length);
Here:
sFirstMessage, sSecondMessage - a hint to the user when entering the first and second points,
x1, y1, x2, y2 - coordinates of the entered points,
angleInRad - angle in radians from the positive direction of the X axis,
length - the length of the segment.
Returns 0 if the input was successful..

interface_input3dline
User input 3d lines.
Appeal:
int iret ac_request("interface_input3dline", string sFirstMessage, string sSecondMessage, double x1, double
y1, double z1, double x2, double y2, double z2, double angleInRad, double length);
46
Here:
sFirstMessage, sSecondMessage - a hint to the user when entering the first and second points,
x1, y1, z1, x2, y2, z2 - coordinates of the entered points,
angleInRad - angle in radians from the positive direction of the X axis,
length - the length of the segment
Returns 0 if the input was successful.

interface_input2dpoly
User input 2d polygon. Returns the area and perimeter.
Request format:
int ires = ac_request("interface_input2dpoly",string sMessage, double &square, double &perimeter);
Here:
sMessage - a text message to the user,
square, perimeter in these variables returns the value of the square and the perimeter of the shape that the user specified by mouse
clicks

ac_typeidfromstring()
Get the item type code by its name.
Appeal.
int itype = ac_typeidfromstring(string selemtypename);
Here:
selemtypename - the text name of the element type ("ZoneType", "MeshType", "ObjectType", etc.)
The output is a numeric value corresponding to this name..

ac_getresvaluetype()
Specifies the data type of the result obtained from the previous operation.
Appeal
string stype = ac_getresvaluetype();
In stype will contain "String" / "Real" / "Integer" / "Boolean" if the result of the previous operation is a string, a real number, an
integer or a logical 1/0.

47
ac_getstrvalue()
Returns the text value of the previous operation.
Appeal
string sresult = ac_getstrvalue();

ac_getnumvalue()
Returns the numeric value of the previous operation.
Appeal
double dresult = ac_getnumvalue();

description of the section in development

For application configuration


setcfg()
Apartment Flat programm (LabPP_Solaris) Configuration

Number of decimal places - ROUNDINGPRECISION


Request format:
SETCFG("SETAUTOMATBUTTON",int buttonnum,string smessage, string prgfilename);
Here: buttonnum is the number of the programmable button (usually from 1 to 4), smessage is the message that will be displayed
when the user hovers the mouse over the button, prgfilename is the name of the file with the program to be run on this button.
Example.
Attach to the first programmable button on the application panel - run the program from the 1.cpp file. When pointing the mouse to
this button to give a message what the first button is..
SETCFG("SETAUTOMATBUTTON",1," First programmable button ","1.cpp");

48
Dialogues
Messages or option - tsalert()
The function calls a selection dialog or just a message. You can create up to three buttons inclusive.
Appeal format:
int res = tsalert(int messagecode,string stitle,string smessagebig, string ssmall,string button1,string
button2,string button3);
Here:
messagecode - the numeric code of the window:
-1 - error message
-2 - warning
-3 - informational message.
stitle - the title of the window, smessagebig - the message in large letters, ssmall - the message below with small text, button1 - button3
- texts for the corresponding buttons.
Res is the result of the user's selection.
If the button1 button is pressed - the result is 1, button2 - 2, button3 - 3. If the user rejects the choice, 0 is issued.
Example.
Get a decision from the user how many items to display (10, 1 or all). Explain what you can try. if the user selects "All" - report to the
message box. If he refuses - also report to the message box.
int res = tsalert(-3,"Set the value" ,"How many items to display?"," For trial uploading, it is convenient to display not all
markers first. ","10","1","All");
if(res==0)
{
cout << " User refused ";
return;
}

File search and selection


The ac_request function with the directive dialog_get_filename calls the file selection dialog.
Appeal format:

49
int iret = ac_request ("dialog_get_filename", string Title, string Filter, string sStartFolder, string & FileNameAndPath);
Here: Title - the title of the window, Filter - the filter string to select the file, sStartFolder - the initial path where to select the file.
The full path to the selected file is returned to the FileNameAndPath variable.
If iret is -1, it means that the user has refused the choice.
Example.
Select a program file with a .cpp extension. Search first in the root directory of the C: drive. Advanced - run this selected program file
for execution..
string sFileNameAndPath;
string sStartFolder="c:\\";
int iret = ac_request("dialog_get_filename","Select file to run", "cpp", sStartFolder, sFileNameAndPath);
if(iret == -1)
{
cout << "User refused file selection \n";
return -1;
}
run_cpp("run_from_file",sFileNameAndPath);
cout << "File selected and executed";

Enter a number or string


editdoubledialog
The ac_request () function with the "editdoubledialog" directive causes a dialog to enter a floating point number.
Appeal format:
int res = ac_request("editdoubledialog",string smessage, string sstartvalue);
or
int res = ac_request("editdoubledialog",string smessage, double dstartvalue);
Here:
smessage - the message in the header of the dialog panel, sstartvalue or dstartvalue - the number that is substituted by default in the
dialog edit box.
Returns 0 if the user refused to enter (clicked the "Cancel" button, clicked the button with a cross on the dialog box or press the
"Esc" key on the keyboard).
Example.
Get the distance between the elements from the user. Defaults suggest value 20.
50
int res = ac_request("editdoubledialog","Enter the distance between the elements. (м)","20");

editstringdialog
The ac_request () function with the "editstringdialog" directive invokes a dialog for the string.
Appeal format:
int res = ac_request("editstringdialog",string smessage, string sdefaultstr);
Here:
smessage is the message in the header of the dialog pane, ssdefaultstr is the string that will be inserted by default in the dialog edit box.
Returns 0 if the user refused to enter (clicked the "Cancel" button, clicked the button with a cross on the dialog box or press the
"Esc" key on the keyboard).
Example.
Get from the user name of the architect. By default, suggest the value "Ivanov V.V.".
int res = ac_request("editstringdialog","Enter the full name of the architect ","Ivanov V.V.");

Gravity to surface (LABPP)


Landing elements - do_elements_landing
You can select elements and land them on the surface of other elements.
Appeal
ac_request("do_elements_landing", int iLandList, int iLandingElemsList, double doffset, int mmode);
Here:
iLandList is the number of the internal list of elements where the elements defining the landing surface are selected.
iLandingElemsList is the number of the internal list of items where the items to be landed are selected.
doffset - height above the surface on which to stop the landing.
mmode - 0 - land each element separately, 1 - land taking into account grouping by the younger group, 2 - taking into account
grouping by the older group, 3 - group of elements as a whole.

Landing points - do_surface_landing


You can select 3d mesh elements and "land" the points of their surfaces on the surface of other elements.
51
The same team lands elements like "Beam" with both points with a slope along a curved surface.
Appeal
ac_request("do_surface_landing", int iLandList, int iLandingElemsList, double doffset);
Here:
iLandList is the number of the internal list of elements where the elements defining the landing surface are selected.
iLandingElemsList is the number of the internal list of items where the items to be landed are selected.
doffset - height above the surface on which to stop the landing.

Landing point X,Y - do_point_landing


You can set the X and Y coordinates and get the Z coordinate on the surface made up of elements collected in the iLandList list. If
the point does not lie above the surface of the "ground" or is above the hole, then the landing is not performed.
Appeal:
ac_request("do_point_landing", int iLandList, double doffset, double x1,double y1, double &z1);
Here:
x1, y1 - source coordinates of a point.
doffset - residual displacement above the surface.
z1 - the result of the landing.
iLandList - number of the internal list with items - land.
Example.
Select items from the "My land" layer in the list No. 1 and land a point with coordinates x = 1, y = 1 to a height of 0, i.e. straight to
the surface.
ac_request("load_elements_list,1,"ZombieElemType","Layer","My land","MainFilter",3);
double doffset=0;
double x=1, y=1, z=0;
ac_request("do_point_landing", 1, doffset, x,y,z);
cout << "The result is the z coordinate on the surface. = "<< z;

52
Work with Excel
excel_attach
Connect Excel to work.
At startup, Excel should be open.
By default, the current Excel page becomes active.
Appeal
int ires = excel_attach();
If 0 is returned, then the connection is successful.
Example.
Connect the current Excel table and display the number 100.1 at the current marker position..
int ires = excel_attach();
if(res != 0)
{
cout << "Can't link to Excel";
return -1;
}

double dvalue = 100.1;


excel_putnumvalue(dvalue);
excel_detach();

excel_detach
Disable Excel.
Appeal
excel_detach();

excel_putnumvalue
Write the numeric value to the current Excel focus position.
Appeal
53
excel_putnumvalue(double dvalue);

excel_putstrvalue
Write the text value to the current Excel focus position.
Appeal
excel_putstrvalue(string svalue);

excel_select_range
Focus Excel specified cells.
Appeal format:
excel_select_range( string srange);
Here: srange is the text address of the Excel cell.
Example.
Highlight cells in the range "A2:C4" in the current Excel table.
excel_select_range( "A2:C4");

excel_visible
Make it visible and bring the Excel window to the fore.
Appeal
excel_visible();

excel_speedup
Performs actions to accelerate the transfer of data to / from Excel. It is recommended to apply acceleration before outputting large
amounts of data to the table. At the end - turn off.
Appeal:
excel_speedup (int what);
Here what - 0/1 - disable / enable accelerated data processing by Excel.

54
excel_getnumvalue
Get a numeric value from the current Excel focus position.
Appeal
double dvalue = excel_getnumvalue();

excel_getstrvalue
Get the text value from the current position of the Excel focus.
Appeal
string svalue = excel_getstrvalue();

excel_request
A great feature for working with Excel with directives.

set_column_width
Sets the width of a column or a range of columns.
Appeal:
excel_request ("set_column_width", string sdiapazon, double width);
Here: sdiapazon is a text value that describes the range of columns. For example: "B: B" - means column B. If you write "B: D" then
the width will be set for columns B, C and D.
width - the width of the column.
Example.
Set the width of column B to 18.86:
excel_request ("set_column_width", "B: B", 18.86);

get_column_width
Get column width or column range
Appeal:
excel_request ("get_column_width", string sdiapazon, double width);
Here: sdiapazon is a text value that describes the range of columns. For example: "B: B" - means column B. If you write "B: D" then
the width will be set for columns B, C and D.
in width - the width of the column will be written

55
set_row_height
Set the height of the specified line or range of lines
Appeal:
excel_request ("set_row_height", string srowdiapazon, double height);
Here: srowdiapazon is a string value that defines the range of lines to which you want to set the height. For example, "1: 1" is the first
line, "2: 4" is lines two through four.
height - the height of the line.
Example.
Set the height for rows 2 through 8 at 15.75.
excel_request ("set_row_height", "2: 8", 15.75);

get_row_height
Get the height of a line or a range of lines.
Appeal:
excel_request ("get_row_height", string srowdiapazon, double height);
Here: srowdiapazon is a string value that defines the range of lines to which you want to set the height. For example, "1: 1" is the first
line, "2: 4" is lines two through four.
in height - the height of the line will be written.

set_borders
Set curbs around the currently selected cell area.
Appeal:
excel_request ("set_borders", int border_left, int border_top, int border_right, int border_bottom);
Here: border_left, border_top, border_right, border_bottom - variables that set whether or not the border will be on the left, top,
right and bottom, respectively. 1-yes, 0-no.
Calling without these arguments means setting all the borders:
excel_request ("set_borders");

get_borders
Get the arrangement of borders around the current selected cell fragment.
Appeal:
excel_request ("get_borders", int border_left, int border_top, int border_right, int border_bottom);

56
Here: border_left, border_top, border_right, border_bottom are variables where 0 or 1 values are written depending on whether or
not the border is set to the left, top, right and bottom, respectively.

put_selection_values
put_selection_fontvalues
get_selection_area
merged_cell_info
is_merge_cells
set_backcolor
get_backcolor
set_interior
get_interior
selection_varvalues
selection_font_varvalues
sheet_select
range_copy
booknamedcell

description of the section in development

57
Work with Word
word_attach
Connecting Word program for data exchange and management.
Appeal:
int ires = word_attach ();
Returns 0 if the connection was successful..

word_detach
Disable Word.
Appeal:
word_detach();

word_visible
Makes visible and brings to the fore the window of the program Word. When the window is hidden, Word handles calls much faster,
because does not reformat the mapping. So it is reasonable to speed up the output before recording hide the window, and after -
show.
Appeal:
word_visible(int ivisible);
Here: ivisible - 0/1 - hide / show window Word.

word_request
Reading and writing variable fields - docfield
Word documents have the ability to use special variables. By the type of autotext in ARCHICAD, variables in Word can be inserted in
different places of formatted text. So it’s enough for us to assign them a value and the document remaining correctly formatted will
reflect the new data.
get
Read document variable value Word
58
int ires = word_request("docfield","get", string wordfielsname, string/double/int/bool value);
Here:
wordfielsname is the name of the Word variable
string / double / int / bool value - the value of any of the listed types for assignment to the Word variable.
Returns 0 on success..
set
Set the value of the Word document variable.
Appeal:
int ires = word_request("docfield","set",string wordfielsname, string/double/int/bool value);
Here:
wordfielsname is the name of the Word variable
string / double / int / bool value - the value of any of the listed types for assignment to the Word variable.
Returns 0 on success.
Update variable fields in the text of a Word document.

update_all_docfields
After changing the values of the Word document variables, in order for the changed data to be reflected in the text, it is necessary to
update the fields in the text of the document.
Appeal:
word_request("update_all_docfields");

description of the section in development

Internal objects
Many mechanisms are implemented as internal objects.
Objects can be created, manipulated and deleted.
Work with objects is done through the object handle.
This is an integer that is assigned when the object is created..

59
Function object
Provides the ability to perform basic operations on objects - create, delete, etc.

create
Format:
int object("create", string objclass, int descr);
Creates an object of type objclass and returns its descriptor to the variable descriptor.
Returns 0 on successful creation of the object.

delete
int object("delete",int descr);
Removes an object with a descr handle from memory.

Example.
Create a ts_table object (dynamic table) and delete it.
int TableDescr1;
object("create","ts_table",TableDescr1);
object("delete",TableDescr1);

Objects for processing tabular data


Function ts_table
The ts_table function allows you to perform operations on a dynamic table object.

add_column
Add a column to the table. Columns can be string or numeric.
Command format:
ts_table(int descriptor, "add_column", int columnnumber, string columnname);
Here:

60
descriptor - a handle to an instance of a table object, in which a column is added.
columnnumber is the column number (you can put -1 so that the program itself creates a number).
columnname - the name (header) of the column.
An example to add a text column number 0:
ts_table(TableDescr1, "add_column",0,"string"," material code + unit.");

An example to add a numeric column with a calculated number by the value of the variable № = i + 3
ts_table(TableDescr1, "add_column",i+3,"double",szonename);

set_first_key
When you need to avoid duplication of records in the table, you can use a convenient mechanism.
One of the columns can be set as the so-called "primary key".
After that, all added rows will be analyzed and if the table already has a row with the same value in the column, then a new row will
not be created.
And if adding a line is not made by a simple directive "add_row" but "add_row_sum", then the values of the numeric columns will be
summarized in the detected line (see add_row_sum).
Example to make column # 1 as key column:
ts_table(TableDescr1,"set_first_key",1);

An example to make a column with the name "Object Name" key:


ts_table(TableDescr1,"set_first_key","Object name");

add_row
Adding a string.
ts_table(TableDescr1,"add_row", 0, objectname, 1, value_to_column_1, 2, value_to_column_2);

Here, in column No. 0 we write the value from the variable objectname, in column No. 1 we write the value value_to_column_1, and
in column No. 2 we write the value of the variable value_to_column_2.
If column # 0 is set as "primary key" (specified in the set_first_key directive), then the values of the columns can be written for
several commands:
ts_table(TableDescr1,"add_row", 0, objectname, 1, value_to_column_1);
61
ts_table(TableDescr1,"add_row", 0, objectname, 2, value_to_column_2);

The data will be added to the same row with the value in the key column №0.

add_row_sum
Adding a line with summation in numeric columns with a line that matches the value of the key column.
The easiest way to explain is with a relevant example.
There are objects "Board". In these objects there is a field "standard size" ("100x40", "50x40", etc.), "unit of measure" ("meter,"
"square meter", "cubic meter") and "quantity" .
We want to get a summary table, where all the objects of type "Board", in the project are summarized as follows:
Material Unit Count
Plank 100х50 m 1000
Plank 50х40 m3 2000
Plank 50х20 m2 1900
To do this, create a table with one key column and columns for regular data.
ts_table(TableDescr1,"add_column",0,"string","object name + size + unit.");
ts_table("TableDescr, "set_first_key",0);
ts_table(TableDescr1,"add_column", 1,"string",objectname);
ts_table(TableDescr1,"add_column", 2,"string",tiporazmer);
ts_table(TableDescr1,"add_column", 3,"string",edizm);
ts_table(TableDescr1,"add_column", 4,"double",kolvo);

To add a row to the table, simply use the following entry:


ts_table(TableDescr1,"add_row_sum",0,objectname+tiporazmer+edizm, 1,objectname, 2, tiporazmer, 3, edizm, 4,
kolvo);

As a result, in the table all objects with the same value name + size + unit. will be reduced to a single record, and in the "quantity"
column will be the sum of quantities.

sort
Sort the table rows by a given column or by a key column (if without arguments).
Example. Sort the table by column number 0
62
ts_table(TableDescr1,"sort",0);

Example. Sort the table by the key column specified earlier.


ts_table(TableDescr1,"sort");

After adding a new line requires re-sorting.

search
Quick search in the table of the first matching column value.
Returns the row number or -1 if such a row is not in the table.
Example. Find the row with the value in the column №1 "Plank"
int irow = ts_table(TableDescr1,"search",1,"Plank");

select_row
Make current the specified row in the table.
Example. Make current the first row in the table (the row index is from 0 to n-1):
int i=0;
ts_table(TableDescr1,"select_row",i);

get_value_of
Get the value from the specified column of the current row of the table
Example. Get the value from column 0 of the current row of the table into the variable objectname:
string objectname;
ts_table(TableDescr1,"get_value_of",0,objectname);

get_rows_count
Get the number of rows in a table into a given variable.
int rowcount;
ts_table(TableDescr1,"get_rows_count", rowcount);

get_columns_count
Get the number of columns in the table in a given variable
63
int colcount;
ts_table(TableDescr1,"get_columns_count", colcount);

Standard Library Functions


Converting
atoi
Convert a string variable to an integer
Appeal:
string ivalue = atoi(string svalue);

itoa
Converting an integer to a string.
string svalue = itoa(int ivalue);

atof
Converting a string variable to a floating point number
double dresult = atof(string svalue);
Here: svalue is a number written by text, the return value is a floating point number.

ctos
Translate character code to string. The function is useful when dynamically forming a column name in Excel, etc.
Appeal format:
string ssymbol = ctos(int isymbolcode);
Here:
icymbolcode - character code.
ssymbol is a string variable with the symbol corresponding to the code.
Example:
Form the text address of the Excel cell in the second column in the second row.
int chcolumn = 'A'+1;
64
string ssymbol = ctos(chcolumn);
string address = ssymbol+itoa(2)+":"+ssymbol+itoa(2);
cout << address;

"B2: B2" will be displayed in the message box.

Mathematical functions
abs
Return absolute value.
double dres = abs(double dvalue);
В dres - число dvalue всегда положительное.

max
Return the maximum of the numbers
Command format
double dres = max(double dvalue1, double dvalue2);
In dres, the maximum of dvalue1 and dvalue2

min
Return the minimum of the numbers
Command format:
double dres = min(double dvalue1, double dvalue2);
In dres, the minimum of the numbers dvalue1 and dvalue2.

rand
Random number generator
Appeal:
double dres = rand();
Returns a random number from 0 to 1;

ln
Natural logarithm

65
log
Logarithm

sqrt
Square root

sqr
Root of a given degree

pow
Exponentiation

percent
Calculate percent of number

Trigonometric functions
cos
Cosine of the angle. The angle is given in radians.
Appeal:
double dresult = cos(double cornerinrad);

sin
Sine angle. The angle is given in radians.
Appeal:
double dresult = sin(double cornerinrad);

arcsin
Argsine

arccos
Argcosynus
66
tg
Angle tangent in radians

arctg
Argtangent

ctg
Cotangent

arcctg
Argcotangent

Functions for converting angular values


grad_to_radian
Convert degrees to radians.
Appeal:
double grad_to_radian(double grad);
Here: grad is the angle in degrees. The return value is a number in radians.
Convert degrees to radians.
Example. Convert to radians 180 degrees:
double result = grad_to_radian(180);

As a result, the result variable will contain the number Pi (3.14 ....).

radian_to_grad
Convert angle in radians to degrees.
Appeal:
double radian_to_grad(double rad);
Example. Translate an angle of 3.14 to degrees.
double result = radian_to_grad(3.14);

As a result, the result variable will contain the number 180.


67
putchar
sprintf
ecvt_french
Translates a number into a string with a comma separated by spaces and spaces separating the thousandth digits.
Appeal:
string svalue = ecvt_french(double dvalue);
Example.
Translate number 111222333.11 into string.
double dvalue = 111222333.11;
string sresvalue = ecvt_french(svalue);
cout << sresvalue;

Result - the line “111 222 333,11” will appear in the message window

tsround
Correct mathematical rounding.
Appeal:
double tsround(double dvalue, int numpos);
Here:
dvalue - the value to be rounded.
numpos - the number of decimal places.

tsround_best
Round up. One of the variants of the rounding algorithm.
Rounds each decimal place starting with the least significant digit. So, if it is greater than 5, then 1 goes into a larger discharge.
Appeal:
double tsround_best(dvalue, int numpos);
Here:
dvalue - the value to be rounded.
numpos - the number of decimal places.

68
floor
The function rounds the argument to the largest integer that is less than or equal to the argument.
Appeal:
double dresult = floor(double dvalue);

ceil
The ceil function performs rounding and returns the nearest integer value to the dvalue, but this value will be no less than the dvalue
itself.
Appeal:
double dresult = ceil(double dvalue);

Geometric Transformation Functions - geometry_calc_2d


The ac_request () function call with the geometry_calc_2d directive provides a wide range of operations for modifying coordinates
and determining the relative positions of various elements..

is_point_on_element_polygon
Determine whether a point lies inside the polygon of an element having a support area (hatching, plate, 3d grid, etc.)
Appeal
bool res = ac_request("geometry_calc_2d","is_point_on_element_polygon",double x1,double y1, int
iElemDedcr);
Here:
x1 and y1 are the coordinates of the point being studied, iElemDescr is the object descriptor whose polygon is checked for the point
content.
Example.
Read the elements of 3d grids with ID = "Relief" in the list of elements, take the first one, create an ac_eleemnt_guid object on its
base, and obtain an ac_element object from it. Get relief in the table of coordinates. And check whether the point is inside the
polygon.
// read the table of coordinates of the relief element 3d mesh with ID = "Relief"
int iMeshCoordTable; // handle of the polygon coordinate table
// read the elements of type 3d-grid with ID = "Relief" in the list number 2
ac_request ("load_elements_list", 2, "MeshType", "ID", "Relief", "MainFilter", 2);
// determine how many items the list contains number 2
69
ac_request ("get_loaded_elements_list_count", 2);
int iicount = ac_getnumvalue ();
if (iicount == 0)
{
cout << "There is no 3d grid with ID = Relief. \ nProgram is stopped";
return -1;
}
// create a dynamic table object for polygon coordinates
object ("create", "ts_table", MeshCoordTable);
// set focus on the first element (index 0) of list No. 2
ac_request ("set_current_element_from_list", 2, 0);
// create an object for the guid element
int iMeshGuidDescr; // handle to the guid object
object ("create", "ac_element_guid", iMeshGuidDescr);
// write a guid into the iMeshGuidDescr object from the current item in the list No. 2
ac_request ("store_cur_element_to_descr", iMeshGuidDescr);
int iMeshElemDedcr; // handle of the element object
// create an object to work with the element
object ("create", "ac_element", iMeshElemDedcr);
// load object item from guid
ac_request ("load_element_from_guid", iMeshElemDedcr, iMeshGuidDescr);
// read polygon coordinate table
ac_request ("get_element_value", "SimpleCoordTable", iMeshCoordTable);
// check how many points the obtained polygon coordinate table contains
int irowcount;
ts_table (iMeshCoordTable, "get_rows_count", irowcount);
cout << "Number of points in the contour of the relief =" << irowcount << "\ n";
object ("delete", MeshCoordTable);
double x1 = 1.1, y1 = 2.2; // coordinates of the studied point
// check whether the point with coordinates x1, y1
int res = ac_request ("geometry_calc_2d", "is_point_on_element_polygon", x1, y1, iMeshElemDedcr);
if (res == 1)
70
{
cout << "The point is inside the polygon contour of the element";
}
rotate_point_and_move
Rotate the point relative to the specified center at a given angle, move the center of rotation to a specified distance and place the point
at a distance, taking into account the scaling.
Appeal:
ac_request("geometry_calc_2d","rotate_point_and_move",double centerXfrom, double centerYfrom,double
pXfrom,double pYfrom, double alpha_rad, double centerXto, double centerYto,double scale,double &pXres,
double& pYres);
centerXfrom, centerYfrom - the origin coordinates of the center of rotation,
pXfrom, pYfrom - source coordinates of the point,
alpha_rad - the angle of rotation of the point around the center,
centerXto, centerYto - new coordinates of the center of rotation,
scale - scale in the range] 0,1],
The result - pXres, PYres - new coordinates of the point.

get_cross_point_of_2lines
Find the intersection point of two straight lines defined by the points.
Appeal
ac_request("geometry_calc_2d","get_cross_point_of_2lines",double l1sX, double l1sY,double l1eX,double
l1eY, double l2sX, double l2sY, double l2eX,double l2eY,double& pXres, double& pYres);
Here:
l1sX, l1sY, l1eX, l1eY - coordinates of the initial and final points of the first straight line,
l2sX, l2sY, l2eX, l2eY - coordinates of the starting and ending points of the second straight line.
The coordinates of the point of intersection of the lines are displayed in pXres and pYres.

get_rot_and_move_point
Move a point in a given direction for a given distance.
Appeal

71
ac_request("geometry_calc_2d","get_rot_and_move_point",double P1X, double P1Y, double dL, double
dAngleRad, double & pXres, double& pYres);
Here:
P1X, P1Y - the source coordinates of the point, dL - the distance to move the point, dAngleRad - the angle counterclockwise from
the positive direction of the X axis.
pXres, pYres - coordinates of the displaced point.

get_length_2point
Calculate the distance between two points.
Appeal:
ac_request("geometry_calc_2d","get_length_2point",double l1sX, double l1sY,double l1eX,double l1eY,
double &resLength);
Here:
l1sX, l1sY, l1eX, lieY - coordinates of points.
The distance between points returns to resLength.

is_point_on_line
Determine whether a point is on a line defined by two points.
Appeal:
bool bres = ac_request("geometry_calc_2d","is_point_on_line",double P1X, double P1Y, double P2X, double
P2Y, double PointX, double PointY);
P1X, P1Y, P2X, P2Y - the start and end points of the line.
PointX, PointY - coordinates of the studied point.
Result bres - 1 or 0, depending on whether or not there is a point on the line..

get_line_angle_relative_to_center
Determine the angle of inclination of the segment relative to the center of coordinates.
Appeal
ac_request("geometry_calc_2d","get_line_angle_relative_to_center",double l1sX, double l1sY,double
l1eX,double l1eY, double &resAngleInRad);
Here:
l1sX, l1sY, l1eX, l1eY are the coordinates of the starting and ending points of the segment.

72
The angle in radians is returned in resAngleInRad.

Special functions
Measurement of the execution time of the code fragment - codemeter
Appeal format:
double dvalue = codemeter (int what);
Here what is 0 or 1.
If 0 is set, the timer is reset.
If 1 is specified, the function returns the time in seconds since the counter was reset.
Example.
Determine the cycle time of 10,000 passes..
codemeter(0);
int i;
for(i=0;i<10000;i++)
{
cout << i << "\n";
}
cout<< "Cycle on 10 000 times was created by " << codemeter(1) << " second";

Save text from message window to file - ac_save_messages_to_file


Appeal format:
ac_save_messages_to_file(string filepath);
Writes the contents of the message box to a filepath file.
Example.
Write the contents of the message box to the file c: \ my_file.txt:
ac_save_messages_to_file("c:\\my_file.txt");

Notice the double backslash.


In C ++ strings, the single backslash is used for service purposes. So in the lines you need to write a double slash, and the program
will automatically remove one.

73
The connection with the apartment
calculation programm (LabPP_Solaris)
Test of communication with - ac_request("solaris_test")
In order to use the ARCHICAD apartment cartography functional, it is necessary for the apartment cartography module to be
installed and accessible.
The test is performed by the ac_request command with the solaris_test directive.
Form of appeal
int ires = ac_request("solaris test");
Upon successful testing, 0 is returned..
int res;
res = ac_request("solaris_test");
if(res != 0) {
cout << "Нет связи с LabPP_Solaris\n";
return -1;
}

Get a room list of apartment - ac_request("get_flat_rooms"...)


Fills the specified internal list with elements of the zones assigned to the specified apartment marker.
Appeal
int ires = ac_request("get_flat_rooms",int iFlatGuidObjDescr, int iListNum);
Here:
iFlatGuidObjDescr is a handle to an apartment / office marker guid object.
iListNum - the number of the internal list of items in which to record the zones of this apartment / office.
Output - 0 - no error.

74
runtimecontrol
workline
Management of the track percent of the program.
Appeal format:
runtimecontrol("workline", string sdirective, double dvalue);
Here:
directive - a directive specifying what to do "setmin" / "setmax" / "setpos" - set the minimum, maximum or current value of the
percent track,
dvalue - a number, depending on the directive.

Commands for managing the application


LabPP_Calc
interface
calc_field
Read or write the contents of the operative fields and calculator note fields for the ARCHICAD. The application has 4 fields and
below them for the convenience of the user - comment fields.
Appeal:
ac_request("interface", "calc_field", string what, string fieldname, int dochangedot, string svalue,string
scomment);
Here:
what - expression "set" or "get" - write or receive,
fieldname - the name of the field "a" / "b" / "c" / "main" - to which of the fields the command will be applied.
dochangedot - replace the comma with a point when reading the operative field and vice versa when writing or not (1/0).
svalue - the textual value of the operative field,
scomment - the text value for the comment field of the operational field.
75
When executing the "set" command, information is saved for performing a rollback or repeating operations.
Example.
Write in the operation field "a" the value 111.11 automatically replacing the point with a comma. In the comments to this field write
down that this is the area of the apartment..
ac_request("interface","calc_field","set","a",1,"111.11","s flat");

Data exchange between programs -


external variables
After the program is executed, all its variables are destroyed from memory.
The exception is external variables.
They can be created during the execution of one program and read into another without restriction. This is done by calling the
var_extern_get and var_extern_set functions.
External variables have id and value.

var_extern_set
Set an external variable and assign a value to it. The value is assigned in text form.
Appeal
var_extern_get(string varname, string varvalue);
or
var_extern_get(string varname, double varvalue);
Here:
varname - variable name, varvalue variable value text or number.

var_extern_get
Getting the value of an external variable from memory by its identifier
Appeal
var_extern_set(string varname, string varnameforvalue);
or

76
var_extern_set(string varname, double varnameforvalue);
Here:
varname is the name of the variable; varnameforvalue is the name of the variable to which the value of the external variable is written.

Run another program - run_cpp


The run_cpp function allows you to run other programs directly from the text of the current program.
It can be launched from a file or directly from a text string that can be formed during the execution of the current program..

run_from_file
Run the program from the specified file.
Form of appeal
double dret = run_cpp("run_from_file",string sFileNameAndPath,int arg1,double arg2,string arg3);
Here:
sFileNameAndPath is the name and full path to the program file to be executed.
arg1, arg2 and arg3 are the arguments with which the program will be executed (in it you can read them as a get_args function)
The result returned in the dret corresponds to the number specified in the return command in the program file that runs here.
Example.
Run the program from the file "c: \ my_program.cpp" and transfer the integer number 100 to it.
int myintvar = 100;
double dret = run_cpp("run_from_file","c:\my_program.cpp",myintvar,0,"");

run_from_variable
Execution of a program from a string variable.
This is useful if you want to create an algorithm for the program actions in the course of execution.
Form of appeal:
double iret = run_cpp("run_from_variable",strint programtext,int arg1,double arg2,string arg3);
Here:
programtext - the text of the program to run.
arg1, arg2 and arg3 are the arguments with which the program will be executed (in it you can read them as a get_args function)
77
Example.
Form the text of the program and execute it with parameters 100, 111.1 and the "text argument". In the message window show the
result of the program.
string programtext="int main(){ cout << \"My programm \"<<\"\n\"; int iarg1; double darg2; string sarg3;
run_cpp(\"get_args\",iarg1, darg2, sarg3);";
programtext += "cout << iarg1 << \" ,\" << darg2 << \" ,\" << sarg3; return -1;}";
int iret = run_cpp("run_from_variable",programtext,100,111.1,"text argument");
cout << "iret = " << iret << "\n";

We generated the program so that on completion it performs the function return -1.
So iret will contain -1.

Getting arguments inside the program


If the program file is launched for execution with arguments, then they can be obtained using the run_cpp function with the get_args
directive.
Appeal
run_cpp("get_args",int iarg1, double darg2, string sarg3);
Here:
iarg1, darg2, sarg3 are variables of the type integer, real and string, where the values of the arguments that were set when the program
was started will be written.

Interface functions LabPP_Automat


When loaded, LabPP_Automat creates a list of configurations available in its working directory and shows the user a choice in its
launch window. The name of the configuration is the name of its directory. Each configuration directory has a tsimages directory (for
storing pictures) and tsprg (where program files are stored).
When the user has made a choice, LabPP_Automat loads the selected configuration and runs the config.cpp program from it.
At this moment, you can create interface elements (buttons, etc.) using the LabPP_Automat interface generation commands..

78
create_iconbutton
Create a button with a picture.
Appeal:
ac_request("create_iconbutton",string sPictureName,int sx,int sy, int ex, int ey, string sToolTip, string
sPrgCppFileName);
Here:
sPictureName - the name of the file with the image for the button (from the tsimages directory).
sx, sy, ex, ey - coordinates of the button on the LabPP_Automat work pane,
sToolTip - a text hint to display at the moment when the user moves the mouse over the button,
sPrgCppFileName is the name of the program file (from the tsprg directory) that will be launched by this button.

create_button
Create a button with a text label.
Appeal:
ac_request("create_button",string sButtonText, int sx, int sy, int ex, int ey, string sToolTip, string
sPrgCppFileName);
Here:
sButtonText - the text in the button.
sx, sy, ex, ey - coordinates of the button on the LabPP_Automat work pane,
sToolTip - a text hint to display at the moment when the user moves the mouse over the button,
sPrgCppFileName - the name of the program file (from the tsprg directory) that will be launched by this button.

set_palette_size_and_message_place
Set the size of the dialog for the LabPP_Automat work pane and the size of the message window in it.
ac_request("set_palette_size_and_message_place", int x, int y, int ex, int ey, int xx, int yy, int exx, int eyy);
Here:
x, y, ex, ey - coordinates of the working panel on the screen,
xx, yy, exx, eyy - coordinates of the message window in the work pane.

79
Error processing
During the execution of scripts, if an error is detected, a message is displayed in the dialog box and the program is stopped. The
message indicates the location and nature of the error. Therefore, it is easy to understand, find and eliminate.

80

You might also like