(vl-load-com)
(defun c:sv_lamps (/ nabor _len1 _eff_name _block _conduit quantity point counter poinsert _cond _lenbl x_half x_half y_coord z_coord x_coord` chname chlenbl )
(setq acadd (vlax-get-acad-object))
(setq active_doc (vla-get-ActiveDocument acadd))
(setq mspace (vla-get-ModelSpace active_doc))
(setq L300 3.1)
(setq L600 6.1)
(setq L900 9.1)
(setq L1000 11)
(setq L1200 13)
(setq xscale 1)
(setq yscale 1)
(setq zscale 1)
(setq rot (/ (getint "Введите угол поворота светильников на карнизах: 0; 180 ") (/ 180 pi)))
(setq rot1 (/ (getint "Введите угол поворота светильников в дверных проемах: 0; 180 ") (/ 180 pi)))
(setq nabor (ssget "_X" (list (cons 8 "_АХП_Вспомогательный_слой_не_печать" ) (cons 0 "insert"))))
(if nabor
(progn
(princ (strcat "Найдено блоков:" (rtos (sslength nabor) 2 0) "шт."))
(terpri)
(initget 1 "Да Нет")
(setq cond_bl (getkword "Использовать выбранный блок для всего чертежа? [Да/Нет]: "))
(if (wcmatch cond_bl "Да") (progn
(setq name (getstring T "Введите имя блока светильника (см. палитру): "))
(setq counter 0)
(while (< counter (sslength nabor))
(setq _block (vlax-ename->vla-object (ssname nabor counter)))
(setq chlenbl
(cond
((wcmatch name "L (300 mm)") (setq _lenbl L300))
((wcmatch name "L (600 mm)") (setq _lenbl L600))
((wcmatch name "L (900 mm)") (setq _lenbl L900))
((wcmatch name "L (1000 mm)") (setq _lenbl L1000))
((wcmatch name "L (1200 mm)") (setq _lenbl L1200))))
(setq point (cdr (assoc 10 (entget (ssname nabor counter)))))
(setq x_coord (nth 0 point))
(setq y_coord (nth 1 point))
(setq z_coord (nth 2 point))
(setq _eff_name (vla-get-effectivename _block))
(princ _eff_name)
(terpri)
(if
(wcmatch _eff_name "!Карниз")
(progn
(setq drop (vlax-invoke _block 'getdynamicblockproperties ))
(nth 0 drop)
(setq _len1 (vlax-variant-value (vla-get-value (nth 0 drop) )))
(setq quantity (fix (/ _len1 _lenbl)))
(setq counter1 0)
(while (< counter1 quantity)
(setq x_coord` (+ x_coord (/ (+ _lenbl (/ (- _len1 (* quantity _lenbl)) quantity)) 2) (* 1 counter1 (+ _lenbl (/ (- _len1 (* quantity _lenbl)) quantity)))))
(setq poinsert (vlax-3d-point x_coord` y_coord z_coord))
(vla-InsertBlock mspace poinsert name xscale yscale zscale rot)
(setq counter1 (+ 1 counter1)))(princ "ok !Карниз")(terpri))
(progn (setq _cond (getint "\n Выберите вариант: 1 - Один блок; 2 - Заполнить проем"))
(if (= _cond 1) (progn
(setq drop (vlax-invoke _block 'getdynamicblockproperties ))
(nth 0 drop)
(setq _len1 (vlax-variant-value (vla-get-value (nth 0 drop) )))
(setq x_half (+ x_coord (/ _len1 2)))
(setq poinsert (vlax-3d-point x_half y_coord z_coord))
(vla-InsertBlock mspace poinsert name xscale yscale zscale rot1)
(princ "ok !Дверной проем")(terpri))
(progn
(setq drop (vlax-invoke _block 'getdynamicblockproperties ))
(nth 0 drop)
(setq _len1 (vlax-variant-value (vla-get-value (nth 0 drop) )))
(setq quantity (fix (/ _len1 _lenbl)))
(setq counter1 0)
(while (< counter1 quantity)
(setq x_coord` (+ x_coord (/ (+ _lenbl (/ (- _len1 (* quantity _lenbl)) quantity)) 2) (* 1 counter1 (+ _lenbl (/ (- _len1 (* quantity _lenbl)) quantity)))))
(setq poinsert (vlax-3d-point x_coord` y_coord z_coord))
(vla-InsertBlock mspace poinsert name xscale yscale zscale rot1)
(setq counter1 (+ 1 counter1))(princ "ok !Дверной проем")(terpri))
)
)))
(terpri)(princ counter)
(setq counter (+ 1 counter))(terpri)(princ "Расстановка выполнена"))
)
(progn
(setq counter 0)
(while (< counter (sslength nabor))
(setq _block (vlax-ename->vla-object (ssname nabor counter)))
(vla-highlight _block :vlax-true)
(setq name (getstring T "Введите имя блока светильника (см. палитру): "))
(setq chlenbl
(cond
((wcmatch name "L (300 mm)") (setq _lenbl L300))
((wcmatch name "L (600 mm)") (setq _lenbl L600))
((wcmatch name "L (900 mm)") (setq _lenbl L900))
((wcmatch name "L (1000 mm)") (setq _lenbl L1000))
((wcmatch name "L (1200 mm)") (setq _lenbl L1200))))
(setq point (cdr (assoc 10 (entget (ssname nabor counter)))))
(setq x_coord (nth 0 point))
(setq y_coord (nth 1 point))
(setq z_coord (nth 2 point))
(setq _eff_name (vla-get-effectivename _block))
(princ _eff_name)
(terpri)
(if
(wcmatch _eff_name "!Карниз")
(progn
(setq drop (vlax-invoke _block 'getdynamicblockproperties ))
(nth 0 drop)
(setq _len1 (vlax-variant-value (vla-get-value (nth 0 drop) )))
(setq quantity (fix (/ _len1 _lenbl)))
(setq counter1 0)
(while (< counter1 quantity)
(setq x_coord` (+ x_coord (/ (+ _lenbl (/ (- _len1 (* quantity _lenbl)) quantity)) 2) (* 1 counter1 (+ _lenbl (/ (- _len1 (* quantity _lenbl)) quantity)))))
(setq poinsert (vlax-3d-point x_coord` y_coord z_coord))
(vla-InsertBlock mspace poinsert name xscale yscale zscale rot)
(setq counter1 (+ 1 counter1)))(princ "ok !Карниз")(terpri))
(progn (setq _cond (getint "\n Выберите вариант: 1 - Один блок; 2 - Заполнить проем"))
(if (= _cond 1) (progn
(setq drop (vlax-invoke _block 'getdynamicblockproperties ))
(nth 0 drop)
(setq _len1 (vlax-variant-value (vla-get-value (nth 0 drop) )))
(setq x_half (+ x_coord (/ _len1 2)))
(setq poinsert (vlax-3d-point x_half y_coord z_coord))
(vla-InsertBlock mspace poinsert name xscale yscale zscale rot1)
(princ "ok !Дверной проем")(terpri))
(progn
(setq drop (vlax-invoke _block 'getdynamicblockproperties ))
(nth 0 drop)
(setq _len1 (vlax-variant-value (vla-get-value (nth 0 drop) )))
(setq quantity (fix (/ _len1 _lenbl)))
(setq counter1 0)
(while (< counter1 quantity)
(setq x_coord` (+ x_coord (/ (+ _lenbl (/ (- _len1 (* quantity _lenbl)) quantity)) 2) (* 1 counter1 (+ _lenbl (/ (- _len1 (* quantity _lenbl)) quantity)))))
(setq poinsert (vlax-3d-point x_coord` y_coord z_coord))
(vla-InsertBlock mspace poinsert name xscale yscale zscale rot1)
(setq counter1 (+ 1 counter1))(princ "ok !Дверной проем")(terpri))
)
)))
(princ counter)
(vla-highlight _block :vlax-false)
(setq counter (+ 1 counter))(terpri)(princ "Расстановка выполнена"))
)))
(progn
(alert (princ "\nНет блоков, расположите блоки на фасаде здания"))
(terpri))
)
(princ))