Author Topic: [XDrX-PlugIn(119)] BLOCK Settlement  (Read 367 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 527
[XDrX-PlugIn(119)] BLOCK Settlement
« on: April 03, 2024, 06:10:49 AM »
Align and scale the selected tiles and place them into the rectangular frame.

Code: [Select]
(defun c:XDTB_BLKHOME
       (/ box box1 dst1 dst2 e e1 i num pts1 src1 src2 ss x)
  (defun _getdir (box)
    (setq pts1 (xd::geom:box->9pt box)
  src1 (nth 4 pts1)
    )
    (if (< (distance (car box) (last box))
   (distance (car box)
     (cadr box)
   )
)
      (setq src2 (nth 7 pts1))
      (setq src2 (nth 5 pts1)
      )
    )
    (list src1 src2)
  )
  (if (and
(setq e (car (xdrx_entsel
       (xdrx-string-multilanguage
"\n选取样本矩形<退出>:"
"\nSelect sample rectangle<Exit>:"
       )
       '((0 . "lwpolyline") (-4 . "&=") (70 . 1))
     )
)
)
(setq num (getint (xdrx-string-multilanguage
    "\n一排几个?<退出>:"
    "\nHow many in a row? <Exit>:"
  )
  )
)
(xdrx_prompt "\n选取要安置的图块")
(setq ss (ssget '((0 . "insert"))))
      )
    (progn
      (setq i 0)
      (setq e1 e)
      (mapcar
'(lambda (x)
   (setq box (xdrx_entity_box e))
   (mapcar 'set '(dst1 dst2) (_getdir box))
   (setq box1 (xdrx_entity_box x))
   (mapcar 'set '(src1 src2) (_getdir box1))
   (xdrx_entity_align x src1 src2 dst1 dst2 t)
   (xdrx_entity_scale x 0.9 dst1)
   (if (/= 0 (rem (setq i (1+ i)) num))
     (xdrx_entity_copy e (car box) (cadr box))
     (progn
       (xdrx_entity_copy e1 (last box) (car box))
       (setq e1 (entlast))
     )
   )
   (setq e (entlast))
)
(xdrx_pickset->ents ss)
      )
    )
  )
  (princ)
)
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net