Показать сообщение отдельно
Старый 17.09.2018, 16:14   #1008
Letos
Консультант
 
Регистрация: 28.06.2017
Сообщений: 555
Сказал(а) спасибо: 127
Поблагодарили 1,030 раз(а) в 366 сообщениях
Вес репутации: 344
Letos за этого человека можно гордитсяLetos за этого человека можно гордитсяLetos за этого человека можно гордитсяLetos за этого человека можно гордитсяLetos за этого человека можно гордитсяLetos за этого человека можно гордитсяLetos за этого человека можно гордитсяLetos за этого человека можно гордится
По умолчанию

Цитата:
Сообщение от DSS Посмотреть сообщение
Пример для 5 полок

Код

Код:
// Установка полок в секцию
ShelfCount = NewNumberInput('Количество полок');
ShelfCount.Value = 5;
KrMat = NewButtMaterialInput("Кромка");

SetCamera(p3dFront);
LeftPanel = GetPanel('Укажите левую панель');
RightPanel = GetPanel('Укажите правую панель');
Left = LeftPanel.GabMax.x;
Right = RightPanel.GabMin.x;
Top = GetEdge('Укажите верхнюю границу', AxisX).First.y;
Bottom = GetEdge('Укажите нижнюю границу', AxisX).First.y;

SetCamera(p3dLeft);
Back = GetEdge('Укажите заднюю границу', AxisY).First.z;
Front = GetEdge('Укажите переднюю границу', AxisY).First.z;

Offset = 1;
Offset2 = 0;
Offset3 = 10;
OP = 64; //Отступы полкодержателей друг от друга
OB = 32; //Отступ от задней границы
OF = 32; //Отступ от передней границы
Count = ShelfCount.Value;
Thick = ActiveMaterial.Thickness;

PosY = Bottom;
SectionHeight = Top - Bottom;
YInc = (SectionHeight - Count * Thick) / (Count + 1);
YInc = Math.round(YInc);

LCorner = OpenFurniture('Крепёж\\Полкодержатель2.f3d');

for (var k = 0; k < Count; k++) {
    PosY += YInc;
    Panel = AddHorizPanel(Left + Offset, Back + Offset2, Right - Offset,
        Front - Offset3, PosY + 0.5);
    Panel.TextureOrientation = ftoHorizontal;
    Panel.Name = 'Полка';

    PosY += Thick;
    for (i = 0; i < Panel.Contour.Count; i++) {
            Panel.AddButt(KrMat, i);
        }
}

LCorner.Mount1(LeftPanel, Left, Bottom + YInc + 0.5, Back + OB, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc + 0.5 + OP, Back + OB, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc + 0.5 - OP, Back + OB, 0);

LCorner.Mount1(LeftPanel, Left, Bottom + YInc + 0.5, Front - OF, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc + 0.5 + OP, Front - OF, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc + 0.5 - OP, Front - OF, 0);

LCorner.Mount1(RightPanel, Right, Bottom + YInc + 0.5, Back + OB, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc + 0.5 + OP, Back + OB, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc + 0.5 - OP, Back + OB, 0);

LCorner.Mount1(RightPanel, Right, Bottom + YInc + 0.5, Front - OF, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc + 0.5 + OP, Front - OF, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc + 0.5 - OP, Front - OF, 0);


LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 2 + 0.5 + Thick, Back + OB, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 2 + 0.5 + Thick + OP, Back + OB, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 2 + 0.5 + Thick - OP, Back + OB, 0);

LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 2 + 0.5 + Thick, Front - OF, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 2 + 0.5 + Thick + OP, Front - OF, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 2 + 0.5 + Thick - OP, Front - OF, 0);

LCorner.Mount1(RightPanel, Right, Bottom + YInc * 2 + 0.5 + Thick, Back + OB, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 2 + 0.5 + Thick + OP, Back + OB, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 2 + 0.5 + Thick - OP, Back + OB, 0);

LCorner.Mount1(RightPanel, Right, Bottom + YInc * 2 + 0.5 + Thick, Front - OF, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 2 + 0.5 + Thick + OP, Front - OF, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 2 + 0.5 + Thick - OP, Front - OF, 0);


LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 3 + 0.5 + Thick * 2, Back + OB, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 3 + 0.5 + Thick * 2 + OP, Back + OB, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 3 + 0.5 + Thick * 2 - OP, Back + OB, 0);

LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 3 + 0.5 + Thick * 2, Front - OF, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 3 + 0.5 + Thick * 2 + OP, Front - OF, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 3 + 0.5 + Thick * 2 - OP, Front - OF, 0);

LCorner.Mount1(RightPanel, Right, Bottom + YInc * 3 + 0.5 + Thick * 2, Back + OB, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 3 + 0.5 + Thick * 2 + OP, Back + OB, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 3 + 0.5 + Thick * 2 - OP, Back + OB, 0);

LCorner.Mount1(RightPanel, Right, Bottom + YInc * 3 + 0.5 + Thick * 2, Front - OF, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 3 + 0.5 + Thick * 2 + OP, Front - OF, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 3 + 0.5 + Thick * 2 - OP, Front - OF, 0);


LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 4 + 0.5 + Thick * 3, Back + OB, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 4 + 0.5 + Thick * 3 + OP, Back + OB, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 4 + 0.5 + Thick * 3 - OP, Back + OB, 0);

LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 4 + 0.5 + Thick * 3, Front - OF, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 4 + 0.5 + Thick * 3 + OP, Front - OF, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 4 + 0.5 + Thick * 3 - OP, Front - OF, 0);

LCorner.Mount1(RightPanel, Right, Bottom + YInc * 4 + 0.5 + Thick * 3, Back + OB, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 4 + 0.5 + Thick * 3 + OP, Back + OB, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 4 + 0.5 + Thick * 3 - OP, Back + OB, 0);

LCorner.Mount1(RightPanel, Right, Bottom + YInc * 4 + 0.5 + Thick * 3, Front - OF, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 4 + 0.5 + Thick * 3 + OP, Front - OF, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 4 + 0.5 + Thick * 3 - OP, Front - OF, 0);



LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 5 + 0.5 + Thick * 4, Back + OB, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 5 + 0.5 + Thick * 4 + OP, Back + OB, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 5 + 0.5 + Thick * 4 - OP, Back + OB, 0);

LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 5 + 0.5 + Thick * 4, Front - OF, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 5 + 0.5 + Thick * 4 + OP, Front - OF, 0);
LCorner.Mount1(LeftPanel, Left, Bottom + YInc * 5 + 0.5 + Thick * 4 - OP, Front - OF, 0);

LCorner.Mount1(RightPanel, Right, Bottom + YInc * 5 + 0.5 + Thick * 4, Back + OB, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 5 + 0.5 + Thick * 4 + OP, Back + OB, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 5 + 0.5 + Thick * 4 - OP, Back + OB, 0);

LCorner.Mount1(RightPanel, Right, Bottom + YInc * 5 + 0.5 + Thick * 4, Front - OF, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 5 + 0.5 + Thick * 4 + OP, Front - OF, 0);
LCorner.Mount1(RightPanel, Right, Bottom + YInc * 5 + 0.5 + Thick * 4 - OP, Front - OF, 0);

SetCamera(p3dFront);
[свернуть]
В этом примере жёстко зафиксирован отступ в 0.5 мм. Самое логичное, что пришло в голову - это добавить в скрипт еще одно поле с названием, например, "диаметр полкодержателя", на основе которого будет высчитываться отступ, чтобы центр полкодержателя оказался в точке с целочисленной координатой по высоте.
Интересно ваше мнение, может есть более простой способ решить эту задачу, который я не заметил.

Последний раз редактировалось Letos; 17.09.2018 в 16:15. Причина: Загнал код в спойлер
Letos вне форума   Ответить с цитированием Вверх