lisp to converts alot of objects to block in one time

lisp to converts alot of objects to block in one time

pink_floid23
Enthusiast Enthusiast
4,363 Views
27 Replies
Message 1 of 28

lisp to converts alot of objects to block in one time

pink_floid23
Enthusiast
Enthusiast

hi

i have this lisp convert object to block , but it make one by one , i need it fix to convert a lot of objects in one time to block ,(choose block by click on block or choose from list or insert be type new name ) 

0 Likes
4,364 Views
27 Replies
Replies (27)
Message 21 of 28

ВeekeeCZ
Consultant
Consultant

Silly me, sorry about that. Fixed.

Message 22 of 28

EiPM_Xavi
Participant
Participant

A-M-A-Z-I-N-G !!

It works perfect: it's rock&Roll 😄

Thanks!

Xcoll

0 Likes
Message 23 of 28

s_pongpaitoon
Explorer
Explorer

Hi, any chance that we could edit this script to set the insertion point at the center of the selected object instead of 0, 0, 0?  Thanks in advance!!

0 Likes
Message 24 of 28

Sea-Haven
Mentor
Mentor

This needs to be replaced with a bounding box solution for multiple objects then get mid point. Check Lee-mac website Selection Set Bounding Box | Lee Mac Programming (lee-mac.com)

 

(not (setq i -1 pt (getpoint "\nSpecify Base Point: "))))

 

0 Likes
Message 25 of 28

jneesNTKKP
Explorer
Explorer

Can you help explain to me or help me make this block so I could set the name of the block. Hoping to be able to set the name and when it creates it would change the block in other locations within my drawing.

0 Likes
Message 26 of 28

ВeekeeCZ
Consultant
Consultant

Try this if it's what you need.

 

(defun c:Blockitinnotime (/ :AddLeadingZeros s o e n m x b l)

    (defun :AddLeadingZeros (a d / b) ;add zeros to 'd' many digits  ;a string
    (strcat (substr "000000000" 1 (if (>= d (setq b (strlen (itoa (fix (atof a)))))) (- d b) 0)) a))

  (setq n (getstring "\nSpecify block name prefix: "))
  
  (if (setq s (ssget '((-4 . "<NOT") (0 . "VIEWPORT,RAY,XLINE,INSERT") (-4 . "NOT>"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i)))
;	    n (cdr (assoc 8 (entget e)))
	    l (assoc 8 (entget e)))
      (setq x 0)
      (while (tblsearch "BLOCK" (setq m (strcat n "_" (:AddLeadingZeros (itoa (setq x (1+ x))) 2)))))
      (entmake (list '(0 . "BLOCK") '(10 0 0 0) (cons 2 m) '(70 . 0)))
      (entmake (entget e))
      (and (= 1 (cdr (assoc 66 (entget (setq b e)))))
	   (while (not (= "SEQEND" (cdr (assoc 0 (entget (setq b (entnext b)))))))
	     (entmake (entget b)))
	   (entmake (entget b)))
      (entdel e)
      (entmake '((0 . "ENDBLK") (8 . "0")))
      (entmake (list '(0 . "INSERT") (cons 2 m) l '(10 0 0 0)))))
  (princ)
  )

 

0 Likes
Message 27 of 28

jneesNTKKP
Explorer
Explorer

thank you that does work, however if I wanted to remove the counting (added number) off at the end, where in the lisp can that change be made?

0 Likes
Message 28 of 28

faisal_kazi6RK49
Observer
Observer

SIMPLE SOLUTION GO TO RENAME AND BATCH UPDATE LIKE *varies* INTO A8 THEN ALL WILL UPDATE ONE TIME DIRECTLY 

0 Likes