Skip to content

Commit

Permalink
Правка размеров
Browse files Browse the repository at this point in the history
  • Loading branch information
kuvbur committed Feb 21, 2025
1 parent 0fc4dec commit 70fb00a
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Sources/AddOn/AutomateFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ void ProfileByLine ()
if (elems.IsEmpty ()) return;
Point2D startpos;

if (!ClickAPoint ("Click point", &startpos))
if (!ClickAPoint ("Click morph-line", &startpos))
return;

API_Element elemline;
Expand All @@ -518,7 +518,7 @@ void ProfileByLine ()
store = -1;
err = NoError;
}
err = ACAPI_CallCommand ("Create 3d",
err = ACAPI_CallCommand ("Create profile by line",
[&]() -> GSErrCode {
GSErrCode err = NoError;
// Получаем настройку хотспотов, которые будем расставлять на краях
Expand Down
10 changes: 10 additions & 0 deletions Sources/AddOn/ClassificationFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void AddClassificationItem (const API_ClassificationItem& item, const API_Class
classificationitem.parentname = parent.id.ToLowerCase ();
classifications.Add (itemname, classificationitem);
}

if (desc.ToLowerCase ().Contains ("some_stuff_class") || desc.ToLowerCase ().Contains ("somestuff_class") || desc.ToLowerCase ().Contains ("somestuffclass")) {
ClassificationValues classificationitem;
classificationitem.item = item;
Expand All @@ -83,6 +84,15 @@ void AddClassificationItem (const API_ClassificationItem& item, const API_Class
classificationitem.parentname = "";
classifications.Add ("@some_stuff_class@", classificationitem);
}

if (desc.ToLowerCase ().Contains ("some_stuff_finwalls") || desc.ToLowerCase ().Contains ("somestuff_finwalls") || desc.ToLowerCase ().Contains ("somestufffinwalls")) {
ClassificationValues classificationitem;
classificationitem.item = item;
classificationitem.system = system;
classificationitem.itemname = "@some_stuff_finwalls@";
classificationitem.parentname = "";
classifications.Add ("@some_stuff_finwalls@", classificationitem);
}
}
void GetFullName (const API_ClassificationItem& item, const ClassificationDict& classifications, GS::UniString& fullname)
{
Expand Down
38 changes: 24 additions & 14 deletions Sources/AddOn/CommonFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,16 @@ Int32 ceil_mod (Int32 n, Int32 k)
return n;
}

// --------------------------------------------------------------------
// Округлить целое n до ближайшего целого числа, кратного k
// --------------------------------------------------------------------
Int32 ceil_mod_classic (Int32 n, Int32 k)
{
if (!k) return 0;
Int32 tmp = abs (n % k);
if (tmp) n += (n > -1 ? (abs (k) + tmp) : (tmp));
return n;
}
// --------------------------------------------------------------------
// Перевод метров, заданных типом double в мм Int32
// --------------------------------------------------------------------
Expand Down Expand Up @@ -1501,15 +1511,15 @@ GSErrCode GetRElementsForCWall (const API_Guid & cwGuid, GS::Array<API_Guid>&ele
}
}
}
const GSSize nWallJunctions = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.cWallJunctions)) / sizeof (API_CWJunctionType);
const GSSize nWallJunctions = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.cWallJunctions)) / sizeof (API_CWJunctionType);
if (nWallJunctions > 0) {
for (Int32 idx = 0; idx < nWallJunctions; ++idx) {
if (memo.cWallJunctions[idx].hasSymbol) {
elementsSymbolGuids.Push (std::move (memo.cWallJunctions[idx].head.guid));
}
}
}
const GSSize nWallAccessories = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.cWallAccessories)) / sizeof (API_CWAccessoryType);
const GSSize nWallAccessories = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.cWallAccessories)) / sizeof (API_CWAccessoryType);
if (nWallAccessories > 0) {
for (Int32 idx = 0; idx < nWallAccessories; ++idx) {
if (memo.cWallAccessories[idx].hasSymbol) {
Expand Down Expand Up @@ -1547,73 +1557,73 @@ GSErrCode GetRElementsForRailing (const API_Guid & elemGuid, GS::Array<API_Guid>
elementsGuids.Push (std::move (memo.railingRailConnections[idx].head.guid));
}
}
n = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.railingHandrailConnections)) / sizeof (API_RailingRailConnectionType);
n = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.railingHandrailConnections)) / sizeof (API_RailingRailConnectionType);
if (n > 0) {
for (Int32 idx = 0; idx < n; ++idx) {
elementsGuids.Push (std::move (memo.railingHandrailConnections[idx].head.guid));
}
}
n = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.railingToprailConnections)) / sizeof (API_RailingRailConnectionType);
n = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.railingToprailConnections)) / sizeof (API_RailingRailConnectionType);
if (n > 0) {
for (Int32 idx = 0; idx < n; ++idx) {
elementsGuids.Push (std::move (memo.railingToprailConnections[idx].head.guid));
}
}
n = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.railingRailEnds)) / sizeof (API_RailingRailEndType);
n = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.railingRailEnds)) / sizeof (API_RailingRailEndType);
if (n > 0) {
for (Int32 idx = 0; idx < n; ++idx) {
elementsGuids.Push (std::move (memo.railingRailEnds[idx].head.guid));
}
}
n = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.railingHandrailEnds)) / sizeof (API_RailingRailEndType);
n = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.railingHandrailEnds)) / sizeof (API_RailingRailEndType);
if (n > 0) {
for (Int32 idx = 0; idx < n; ++idx) {
elementsGuids.Push (std::move (memo.railingHandrailEnds[idx].head.guid));
}
}
n = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.railingToprailEnds)) / sizeof (API_RailingRailEndType);
n = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.railingToprailEnds)) / sizeof (API_RailingRailEndType);
if (n > 0) {
for (Int32 idx = 0; idx < n; ++idx) {
elementsGuids.Push (std::move (memo.railingToprailEnds[idx].head.guid));
}
}
n = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.railingPosts)) / sizeof (API_RailingPostType);
n = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.railingPosts)) / sizeof (API_RailingPostType);
if (n > 0) {
for (Int32 idx = 0; idx < n; ++idx) {
elementsGuids.Push (std::move (memo.railingPosts[idx].head.guid));
}
}
n = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.railingRails)) / sizeof (API_RailingRailType);
n = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.railingRails)) / sizeof (API_RailingRailType);
if (n > 0) {
for (Int32 idx = 0; idx < n; ++idx) {
if (memo.railingRails[idx].visible) elementsGuids.Push (std::move (memo.railingRails[idx].head.guid));
}
}
n = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.railingToprails)) / sizeof (API_RailingToprailType);
n = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.railingToprails)) / sizeof (API_RailingToprailType);
if (n > 0) {
for (Int32 idx = 0; idx < n; ++idx) {
if (memo.railingToprails[idx].visible) elementsGuids.Push (std::move (memo.railingToprails[idx].head.guid));
}
}
n = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.railingHandrails)) / sizeof (API_RailingHandrailType);
n = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.railingHandrails)) / sizeof (API_RailingHandrailType);
if (n > 0) {
for (Int32 idx = 0; idx < n; ++idx) {
if (memo.railingHandrails[idx].visible) elementsGuids.Push (std::move (memo.railingHandrails[idx].head.guid));
}
}
n = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.railingInnerPosts)) / sizeof (API_RailingInnerPostType);
n = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.railingInnerPosts)) / sizeof (API_RailingInnerPostType);
if (n > 0) {
for (Int32 idx = 0; idx < n; ++idx) {
elementsGuids.Push (std::move (memo.railingInnerPosts[idx].head.guid));
}
}
n = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.railingBalusters)) / sizeof (API_RailingBalusterType);
n = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.railingBalusters)) / sizeof (API_RailingBalusterType);
if (n > 0) {
for (Int32 idx = 0; idx < n; ++idx) {
elementsGuids.Push (std::move (memo.railingBalusters[idx].head.guid));
}
}
n = BMGetPtrSize (reinterpret_cast<GSPtr>(memo.railingPanels)) / sizeof (API_RailingPanelType);
n = BMGetPtrSize (reinterpret_cast<GSPtr> (memo.railingPanels)) / sizeof (API_RailingPanelType);
if (n > 0) {
for (Int32 idx = 0; idx < n; ++idx) {
if (memo.railingPanels[idx].visible) elementsGuids.Push (std::move (memo.railingPanels[idx].head.guid));
Expand Down
66 changes: 32 additions & 34 deletions Sources/AddOn/CommonFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,18 @@ static const Int32 DMeterStringID = 19;
static const GSCharCode GChCode = CC_Cyrillic;
typedef std::map<std::string, API_Guid, doj::alphanum_less<std::string>> SortByName; // Словарь для сортировки наруальным алгоритмом

struct Story
{
struct Story {
Story (short _index, double _level)
: index (_index)
, level (_level)
{
, level (_level) {
}
short index;
double level;
};
using Stories = GS::Array<Story>; // Хранение информации об этажах в формате Индекс - Уровень

// Структура для хранения формата перевода чисел в строку и округления чисел
typedef struct
{
typedef struct {
int n_zero = 3; //Количество нулей после запятой
GS::UniString stringformat = ""; // Формат строки (задаётся с помощью .mm или .0)
bool needRound = false; //Использовать в расчётах округлённые значения
Expand Down Expand Up @@ -195,6 +192,8 @@ bool ReserveElement (const API_Guid& objectId, GSErrCode& err);
// --------------------------------------------------------------------
bool check_accuracy (double val, double tolerance);

Int32 ceil_mod_classic (Int32 n, Int32 k);

// --------------------------------------------------------------------
// Перевод метров, заданных типом double в мм Int32
// --------------------------------------------------------------------
Expand Down Expand Up @@ -316,34 +315,33 @@ API_Coord3D GetWordCoord3DTM (const API_Coord3D vtx, const API_Tranmat& tm);
Point2D GetWordPoint2DTM (const Point2D vtx, const API_Tranmat& tm);
bool ClickAPoint (const char* prompt, Point2D* c);

namespace FormatStringFunc
{
FormatString GetFormatStringFromFormula (const GS::UniString& formula, const GS::UniString& part, GS::UniString& stringformat);
// -----------------------------------------------------------------------------
// Обработка количества нулей и единиц измерения в имени свойства
// Удаляет из имени paramName найденные единицы измерения
// Возвращает строку для скармливания функции NumToStig
// -----------------------------------------------------------------------------
GS::UniString GetFormatString (GS::UniString& paramName);

// -----------------------------------------------------------------------------
// Возвращает словарь строк-форматов для типов данных согласно настройкам Рабочей среды проекта
// -----------------------------------------------------------------------------
FormatStringDict GetFotmatStringForMeasureType ();

// -----------------------------------------------------------------------------
// Извлекает из строки информацио о единицах измерении и округлении
// -----------------------------------------------------------------------------
FormatString ParseFormatString (const GS::UniString& stringformat);

// -----------------------------------------------------------------------------
// Переводит число в строку согласно настройкам строки-формата
// -----------------------------------------------------------------------------
GS::UniString NumToString (const double& var, const FormatString& stringformat);

void ReplaceMeters (GS::UniString& formatstring);

void ReplaceMeters (GS::UniString& formatstring, Int32& iseng);
namespace FormatStringFunc {
FormatString GetFormatStringFromFormula (const GS::UniString& formula, const GS::UniString& part, GS::UniString& stringformat);
// -----------------------------------------------------------------------------
// Обработка количества нулей и единиц измерения в имени свойства
// Удаляет из имени paramName найденные единицы измерения
// Возвращает строку для скармливания функции NumToStig
// -----------------------------------------------------------------------------
GS::UniString GetFormatString (GS::UniString& paramName);

// -----------------------------------------------------------------------------
// Возвращает словарь строк-форматов для типов данных согласно настройкам Рабочей среды проекта
// -----------------------------------------------------------------------------
FormatStringDict GetFotmatStringForMeasureType ();

// -----------------------------------------------------------------------------
// Извлекает из строки информацио о единицах измерении и округлении
// -----------------------------------------------------------------------------
FormatString ParseFormatString (const GS::UniString& stringformat);

// -----------------------------------------------------------------------------
// Переводит число в строку согласно настройкам строки-формата
// -----------------------------------------------------------------------------
GS::UniString NumToString (const double& var, const FormatString& stringformat);

void ReplaceMeters (GS::UniString& formatstring);

void ReplaceMeters (GS::UniString& formatstring, Int32& iseng);

}
#endif
Loading

0 comments on commit 70fb00a

Please sign in to comment.