BlocksToLine for fire alarm risers vertical LISP

BlocksToLine for fire alarm risers vertical LISP

jlicerioAQQLC
Contributor Contributor
1,812 Views
11 Replies
Message 1 of 12

BlocksToLine for fire alarm risers vertical LISP

jlicerioAQQLC
Contributor
Contributor

Using this lisp to make fire alarm risers how would I add a vertical function to it?  It lays them out horizontally.

 

(vl-load-com)

(defun c:BlocksToLine ( / s p i a l x)

(or *btl-a* (setq *btl-a* "STROMKREIS"))
(or *btl-d* (setq *btl-d* 2.))

(if (and (setq s (ssget "_:L" '((0 . "INSERT") (66 . 1 ))))
(not (initget 128))
(setq *btl-a* (cond ((getkword (strcat "\nTag name to sort by <" *btl-a* ">: "))) (*btl-a*)))
(setq *btl-d* (cond ((getdist (strcat "\nDistance in between <" (rtos *btl-d*) ">: "))) (*btl-d*)))
(setq p (getpoint "\nPlace them here: "))
)
(repeat (setq i (sslength s))
(setq e (ssname s (setq i (1- i))))
(if (not (vl-catch-all-error-p (setq a (vl-catch-all-apply 'getpropertyvalue (list e *btl-a*)))))
(setq l (cons (cons e a) l)))))
(setq l (vl-sort l '(lambda (e1 e2) (< (cdr e1) (cdr e2)))))
(setq x (- (car p) *btl-d*))
(foreach e l (command "_copy" (car e) "" "_non" (trans (cdr (assoc 10 (entget (car e)))) 0 1) "_non" (list (setq x (+ x *btl-d*)) (cadr p))))
(princ)
)

0 Likes
Accepted solutions (1)
1,813 Views
11 Replies
Replies (11)
Message 2 of 12

Kent1Cooper
Consultant
Consultant

Show us what that would look like.

Kent1Cooper_0-1664280427030.png

 

Kent Cooper, AIA
Message 3 of 12

jlicerioAQQLC
Contributor
Contributor
The first vertical one was what I was looking for the other two as well I could use for a different project.
0 Likes
Message 4 of 12

Kent1Cooper
Consultant
Consultant

Untested, but try changing this much:
(setq x (- (car p) *btl-d*))

to this:

(setq y (+ (cadr p) *btl-d*))

 

and changing this much:

...(list (setq x (+ x *btl-d*)) (cadr p))...

to this:

...(list (car p) (setq y (- y *btl-d*)))...

 

And change the x at the end of the localized variables list at the top to y.

Kent Cooper, AIA
0 Likes
Message 5 of 12

jlicerioAQQLC
Contributor
Contributor

jlicerioAQQLC_0-1664372973683.png

It changed the direction of the blocks to opposite numerical order greatest to least .

0 Likes
Message 6 of 12

jlicerioAQQLC
Contributor
Contributor
(vl-load-com)

(defun c:BlocksToLineY ( / s p i a l x)

(or *btl-a* (setq *btl-a* "NACTAG"))
(or *btl-d* (setq *btl-d* 2.))

(if (and (setq s (ssget "_:L" '((0 . "INSERT") (66 . 1 ))))
(not (initget 128))
(setq *btl-a* (cond ((getkword (strcat "\nTag name to sort by <" *btl-a* ">: "))) (*btl-a*)))
(setq *btl-d* (cond ((getdist (strcat "\nDistance in between <" (rtos *btl-d*) ">: "))) (*btl-d*)))
(setq p (getpoint "\nPlace them here: "))
)
(repeat (setq i (sslength s))
(setq e (ssname s (setq i (1- i))))
(if (not (vl-catch-all-error-p (setq a (vl-catch-all-apply 'getpropertyvalue (list e *btl-a*)))))
(setq l (cons (cons e a) l)))))
(setq l (vl-sort l '(lambda (e1 e2) (< (cdr e1) (cdr e2)))))
(setq Y (+ (car p) *btl-d*))
(foreach e l (command "_copy" (car e) "" "_non" (trans (cdr (assoc 10 (entget (car e)))) 0 1) "_non" (list (setq Y (- Y *btl-d*)) (cadr p))))
(princ)
)
0 Likes
Message 7 of 12

Kent1Cooper
Consultant
Consultant

@jlicerioAQQLC wrote:
....
(setq Y (+ (car p) *btl-d*))
(foreach e l (command "_copy" (car e) "" "_non" (trans (cdr (assoc 10 (entget (car e)))) 0 1) "_non" (list (setq Y (- Y *btl-d*)) (cadr p))))
....

You didn't make all the changes suggested in Message 4 [the red parts above are wrong].

Kent Cooper, AIA
0 Likes
Message 8 of 12

jlicerioAQQLC
Contributor
Contributor
Got errors in the script malformed list while using the exact suggestion.
0 Likes
Message 9 of 12

Kent1Cooper
Consultant
Consultant

Post it.  [It's not a Script, by the way -- that word has a specific and different (though related) meaning in AutoCAD.]

Kent Cooper, AIA
0 Likes
Message 10 of 12

jlicerioAQQLC
Contributor
Contributor

*

0 Likes
Message 11 of 12

jlicerioAQQLC
Contributor
Contributor
(vl-load-com)

(defun c:BlocksToLineY ( / s p i a l x)

(or *btl-a* (setq *btl-a* "NACTAG"))
(or *btl-d* (setq *btl-d* 2.))

(if (and (setq s (ssget "_:L" '((0 . "INSERT") (66 . 1 ))))
(not (initget 128))
(setq *btl-a* (cond ((getkword (strcat "\nTag name to sort by <" *btl-a* ">: "))) (*btl-a*)))
(setq *btl-d* (cond ((getdist (strcat "\nDistance in between <" (rtos *btl-d*) ">: "))) (*btl-d*)))
(setq p (getpoint "\nPlace them here: "))
)
(repeat (setq i (sslength s))
(setq e (ssname s (setq i (1- i))))
(if (not (vl-catch-all-error-p (setq a (vl-catch-all-apply 'getpropertyvalue (list e *btl-a*)))))
(setq l (cons (cons e a) l)))))
(setq l (vl-sort l '(lambda (e1 e2) (< (cdr e1) (cdr e2)))))
(setq y (+ (cadr p) *btl-d*))
(foreach e l (command "_copy" (car e) "" "_non" (trans (cdr (assoc 10 (entget (car e)))) 0 1) "_non" (list(car p) (setq y (- y *btl-d*)) ))
(princ)
)
0 Likes
Message 12 of 12

Kent1Cooper
Consultant
Consultant
Accepted solution

....

  (foreach e l

    (command

      "_copy"

      (car e) ""

      "_non" (trans (cdr (assoc 10 (entget (car e)))) 0 1)

      "_non"

        (list

          (car p) ; X coordinate

          (setq y (- y *btl-d*)) ; Y coordinate

        ) ; list [completes Copy command]

    ; command

  ) ; foreach <-- MISSING

  (princ)

....

Kent Cooper, AIA