Select Block to Place to Points (on same layer)

Select Block to Place to Points (on same layer)

jhoageN5XUG
Participant Participant
674 Views
4 Replies
Message 1 of 5

Select Block to Place to Points (on same layer)

jhoageN5XUG
Participant
Participant

Hello,

 

I'm looking for a lisp to allow me to select a block to be placed, and then select a single point.  The block will then be placed onto all points on the same layer as the original selected point.

0 Likes
Accepted solutions (1)
675 Views
4 Replies
Replies (4)
Message 2 of 5

pendean
Community Legend
Community Legend
Accepted solution
0 Likes
Message 3 of 5

jhoageN5XUG
Participant
Participant

These are close but they place blocks on all the points in the drawing.  I need it to be limited by layer.

0 Likes
Message 4 of 5

jhoageN5XUG
Participant
Participant
I was able to make a minimal change and it works perfect now, thanks!
0 Likes
Message 5 of 5

calderg1000
Mentor
Mentor

Regards @jhoageN5XUG 

Try this code...

(defun c:ibp(/ nb sp s i sn pc lpc x)
  (setq nb (getstring "\nEnter Block name: "))
  (if (tblsearch "block" nb)
    (progn
      (setq sp (entget (car (entsel "\nSelect Base Point: ")))
            s  (ssget "a" (list '(0 . "point") (assoc 8 sp)))
      )
      (repeat (setq i (sslength s))
        (setq sn  (entget (ssname s (setq i (1- i))))
              pc  (cdr (assoc 10 sn))
              lpc (cons pc lpc)
        )
      )
      (foreach x lpc
        (entmake (list '(0 . "insert")
                       (cons 2 nb)
                       (cons 10 x)
                 )
        )
      )
    )
    (princ "¡¡¡Block Name does Not Exist...!!! ")
  )
  (princ)
)

Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes