Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create a legend from blocks in drawing.

1 REPLY 1
Reply
Message 1 of 2
blackbird2006
1171 Views, 1 Reply

Create a legend from blocks in drawing.

First id like to say that this is my first lisp I've ever written so excuse any major errors.

I am attempting to create a lisp that will prompt you to select an area and as an end result will give you a list of blocks that are contained in your box.
i succeeded in doing this but the drawings im working on have hundreds if not thousands of blocks in them.

You can see as how having duplicates would be a big problem.

What i am attempting now is to go through the list before inserting it into the drawing and systematically take out any blocks with the same name.

Here is my attempt so far.

 

(defun c:tester ()
(setq ww 0)
(setq i 0)
(setq j -1)
(prompt "\nSelect Objects by Window")
(setq p1 (getpoint "\nFirst Corner: "))
(setq p2 (getpoint p1 "\nSecond Corner: "))
(setq a (ssget "_C" p1 p2 '((0 . "INSERT"))))
(setq n (sslength a))
(prin1 n)
(princ " Blocks Found")
(while (< j (length a))
progn(
(+ j 1)
(= ww 0)
(while (= ww 0)
(setq fir (entget (ssname a j)))
(+ i 1)
(setq sec (entget (ssname a i)))
(if (= (nth 10 fir) (nth 10 sec ))
(progn
(vl-remove (nth i a) a)
(if (= i (length a))
(setq ww 1)
)
)
)
)
)
)
(setq i 0)
(setq ip1 (getpoint "\nInsertion Point : "))
(setq w 10)
(setq x (car ip1))
(setq y (cadr ip1))
(setq z (caddr ip1))
(repeat n
(setq y (- y 5.5))
(setq atr (entget (ssname a i)))
(setq i (1+ i))
(setq spec (nth 10 atr))
(setq nspec (list w x y z))
(setq natr (subst nspec spec atr))
(entmake natr)

)

(princ)
;clean running

) ;end defun
(princ)
;clean loading

 

Im getting the error "bad argument type listp: <selection set: 16b2>"


any help would be appreciated.

Calvin D

1 REPLY 1
Message 2 of 2
Shneuph
in reply to: blackbird2006

First I'd recommend trying to do whatever it is you're doing with datextraction.  That being said.

 

The error you are getting is from:

(setq a (ssget "_C" p1 p2 '((0 . "INSERT"))))
(setq n (sslength a))
(prin1 n)
(princ " Blocks Found")
(while (< j (length a))

 a is a selection set.  The length function returns the length of a list.  The error is telling you that a is not a list.  Use sslength for a selection set.

 

Hope that helps to nudge you along.

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost