LISP for arranging blocks and set distance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello to everyone. I would need a little help from experts 😄
Some time ago, @Kent1Cooper helped me to write this LISP, so I can arrange large number off different blocks to single line:
From this,
to this, with just one command.
;|BlocksInRow.lsp [command name: BIR]
; Puts all selected Blocks In a Row, starting at a User-specified location, placing
; them with their insertion points horizontally aligned, with equal-sized gaps
; between their extents in the horizontal direction.
; Space between extents of Blocks is entered by the user.
; Kent Cooper, 7 June 2023
|;
(vl-load-com)
(defun C:BIR (/ ss space nextleft blk blkLL blkUR blkleft blkins)
; Check if any blocks are selected on unlocked layers
(if (setq ss (ssget "_:L" '((0 . "INSERT"))))
(progn ; If blocks are selected, proceed
(setq
nextleft (getpoint "\nLeft edge of first Block at Y-coordinate level of insertion point: ")
space (getdist "\nEnter the distance between blocks: ") ; Prompt for the distance between blocks
); setq
; Iterate over each selected block
(repeat (setq n (sslength ss))
(setq blk (ssname ss (setq n (1- n))))
; Get the bounding box of the block
(vla-getboundingbox (vlax-ename->vla-object blk) 'minpt 'maxpt)
; Extracting the coordinates of the lower-left corner and upper-right corner of the block
(setq
blkLL (vlax-safearray->list minpt)
blkUR (vlax-safearray->list maxpt)
blkleft (list (car blkLL) (caddr (assoc 10 (entget blk)))); left edge at Y coord. of ins. pt.
); setq
; Move the block to the next position
(command "_.move" blk "" "_non" blkleft "_non" nextleft)
; Calculate the next left edge position for the next block
(setq nextleft (polar nextleft 0 (+ (- (car blkUR) (car blkLL)) space)))
); repeat
); progn
); if
; Print the result
(prin1)
); defun
Thank you for that, that really was live safer, because sometimes i have 1000 blocks, that I need to arrange them in rows.
But now i got a new problem. Now I am using attributes and because off the attributes, the line doesn't get to the next block any more:
So my idea is, that i make all my blocks dynamic and make my connecting line stretching:
Now, I would need a LISP, that would arrange selected blocks to row and will connect my line to next block. My parameter for extending connecting line is "Distance1".
And I have a Visibility parameter to, so that original block doesn't have connecting line, then I switch visibility to use block for row drawing. But I will just make sure, that all blocks have same Visibility parameters and change them by hand.
I only made one block for now, but after I have a solution, I will make sure to make all my blocks with right parameters.
Thanks in advance, Gašper