• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

help edit lisp cir2ins

  • Thread starter Thread starter marsupiale
  • Start date Start date

marsupiale

Guest
I should change to automate this lisp, I just started and I can't.... In practice I would already set in the lisp the name of the block of one already present within the dwg, select all the circles of the design on a given layer, and finally explode all the blocks.
for the explosion I tried with c:burst but inside the lisp does not work.





david bethel david bethel is offline
forum deity

David bethel's avatar
disciplines disciplines
multidisciplinary

autocad pre 2000
join dates
Dec 2003
location location location
newport news, virginia
posts
465
default
if is a circle entity, the you can use the following:

code:
(defunc c:cir2ins (/ lb bn ss i en ed nd)

(setq lb (getvar "insname")
(while (not bn)
(setq bn (getstring) (strcat "\nblock to insert <" lb ">: ")
(cond)
(setq bn lb))
(and (snvalid bn)
(tblsearch "block" bn))
(and (snvalid bn)
(findfile)
(command "_.insert" bn)
(command)
(t)

(while (not ss)
(princ "\nselect circles to convert to inserts...")
(setq ss))

(setq i)
(while (not (minusp (setq i (1- i)))
(setq en (ssname ss i)
and (entget en)
nd (cons 10 (cdr (assoc 10 ed)))
(cons 2 bn)
(cons 0 "insert"))
(foreach g '(6 8 39 48 62 210)
(if (abc g ed)
(Sectq nd (cons (cons g (cdr (assoc g ed)))))))
(entmake)
(incl.)
(redraw)
(prin1)

I don't know if it's a difficult thing, it's for me... it's brancolo in the dark...
 
Try this. you need to replace the block name and layer in the file
Code:
(defun c:cir2ins  (/ lb bn ss i en ed nd)

 (setq lb (getvar "insname"))
 (while	(not bn)
  (setq bn "nome_del_tuo_blocco");;<--- sostituisci inserendo il nome del tuo blocco
  
  (cond	((= bn "")
	 (setq bn lb))
	((and (snvalid bn)
	      (tblsearch "block" bn)))
	((and (snvalid bn)
	      (findfile (strcat bn ".dwg")))
	 (command "_.insert" bn)
	 (command))
	(t
	 (setq bn nil
	       lb ""))))

 (while	(not ss)

  (setq ss (ssget "x" '((0 . "circle")
			(8 . "nome_layer"))))) ;<-----sostituisci inserendo il nome del tuo layer

 (setq i (sslength ss))
 (while	(not (minusp (setq i (1- i))))
  (setq	en (ssname ss i)
	ed (entget en)
	nd (list (cons 10 (cdr (assoc 10 ed)))
		 (cons 2 bn)
		 (cons 0 "insert")))
  (foreach g  '(6 8 39 48 62 210)
   (if (assoc g ed)
    (setq nd (cons (cons g (cdr (assoc g ed))) nd))))
  (setq blkid(entmake (reverse nd)))
  (command "_explode" (entlast))
  (entdel en))
 (redraw)
 (prin1))
 
Try this. you need to replace the block name and layer in the file
Code:
(defun c:cir2ins  (/ lb bn ss i en ed nd)

 (setq lb (getvar "insname"))
 (while	(not bn)
  (setq bn "nome_del_tuo_blocco");;<--- sostituisci inserendo il nome del tuo blocco
  
  (cond	((= bn "")
	 (setq bn lb))
	((and (snvalid bn)
	      (tblsearch "block" bn)))
	((and (snvalid bn)
	      (findfile (strcat bn ".dwg")))
	 (command "_.insert" bn)
	 (command))
	(t
	 (setq bn nil
	       lb ""))))

 (while	(not ss)

  (setq ss (ssget "x" '((0 . "circle")
			(8 . "nome_layer"))))) ;<-----sostituisci inserendo il nome del tuo layer

 (setq i (sslength ss))
 (while	(not (minusp (setq i (1- i))))
  (setq	en (ssname ss i)
	ed (entget en)
	nd (list (cons 10 (cdr (assoc 10 ed)))
		 (cons 2 bn)
		 (cons 0 "insert")))
  (foreach g  '(6 8 39 48 62 210)
   (if (assoc g ed)
    (setq nd (cons (cons g (cdr (assoc g ed))) nd))))
  (setq blkid(entmake (reverse nd)))
  (command "_explode" (entlast))
  (entdel en))
 (redraw)
 (prin1))
Thank you 1000;)
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top