Calculate the mid-height of the Morph element relative to project 0 and write it in the LabPP_Calc field
Скачать файл можно здесь.
// Lesson 1
// To begin with, create an element of the Morph type in the ARCHIKAD project.
// set the classifier "Stairs" to it according to the classification "ARCHICAD classification"
// select it
// open LabPP_Calc
// open a message box in it with the lower right small button
// second from the right bottom small button launch this software module using LabPP_Calc
// Result - in the calculated field "a" of the calculator, the height of the middle of the Morph element will be written, and in the comment - its ID
// Exercise 1
// Make it so that the value is written to the second field
// Task 2
// Create the "Wall decoration" class in the "ARCHICAD Classification" classifier.
// Assign this class to Morph element
// Make the LabPP_Calc field record the mid-height of this element.
// Hint: when selecting elements from the project - the word "Stair" must be replaced with something
// Task 3
// Increase the result before writing to the field by 10% (multiply by 1.1)
int main()
{
// загрузить из проекта в список 1 все элементы, у которых присвоено любое значение классификатора ARCHICAD
ac_request_special("add_elements_list_from_selection", 1, "MorphType", 2,
"", "Cls", "Классификация ARCHICAD", "=", "Лестница", "");
// запросить количество собранных элементов
ac_request("get_loaded_elements_list_count", 1);
int icount = ac_getnumvalue(); // получить количество в переменную
coutvar << icount; // вывести в окно сообщений
if (icount == 0)
{
cout << "В списке нет элементов";
return -1;
}
// объявляем необходимые переменные для работы
double dLevel, dHeight, elemlevel, elemprojectlevel;
string sElemTypeName, sID;
int ielemstoreindex;
int i;
int ires;
// выполнить цикл icount раз
// в нашем случае нам нужен один элемент, поэтому отработаем цикл только 1 раз на элементе с индексом 0
icount = 1;
for (i = 0; i < icount; i++)
{
ires = ac_request("set_current_element_from_list", 1, i); // сделать текущим i-вый элемент из списка 1
ires = ac_request("get_element_value", "Level"); // запрашиваем значение свойства Level (для Морф - высота над уровнем его этажа)
dLevel = ac_getnumvalue(); // получаем его в переменную
coutvar << dLevel; // выводим в окно сообщений
ires = ac_request("get_quantity_value", "max_height"); // запрашиваем максимальный размер Морф по вертикали
dHeight = ac_getnumvalue(); // получаем его в переменную
coutvar << dHeight; // выводим в окно сообщений
elemlevel = dLevel + dHeight / 2; // рассчитываем уровень центра Морф по высоте относительно этажа
ac_request("get_element_value", "StoreIndex"); // запрашиваем индекс этажа
ielemstoreindex = ac_getnumvalue(); // получаем индекс этажа в переменную
// получаем высоту центра Морф относительно 0 проекта в переменную elemprojectlevel
ac_request("get_levelfromprojectnull_by_floorindexandlevel", ielemstoreindex, elemlevel, elemprojectlevel);
coutvar << elemprojectlevel; // выводим в окно сообщений
ires = ac_request("get_element_value", "ID"); // запросить ID элемента
sID = ac_getstrvalue(); // получить его в переменную
coutvar << sID; // вывести ID в окно сообщений
}
string svalue = ecvt(elemprojectlevel);
string scomment = "Высота элемента с ID=" + sID + "от 0 проекта";
ac_request("interface", "calc_field", "set", "a", 1, svalue, scomment);
// "a" - здесь имя ячейки у LabPP_Calc куда записать значение. Всего ячеек - a,b,c и main
}