Wblock Lisp

Wblock Lisp

Anonymous
Not applicable
3,196 Views
4 Replies
Message 1 of 5

Wblock Lisp

Anonymous
Not applicable

Hi 

 

I have got a drawing that has got about 500 blocks in it and i need to wblock them out one by one 


They have all got text above them that gives the name that i want to use for the block name then i just need to select the objects and the insersion point of the block 

 

I have found a lisp on the fourms that seems to work for other people but it doesnt seem to work for me it asks me to select the block name text i select it and then it doesnt do anything else 

 

(defun c:qwblock (/ DIR ENTXT SS TXT PT TXT0)
  (setq Dir (getvar "DWGPREFIX"))
  (vl-cmdf "_undo" "be")
  (while (AND (vl-file-directory-p Dir)
       (setq enTxt (car(entsel "\nSelect Block name Text: ")))
       (eq (cdr (assoc 0 (entget enTxt))) "TEXT")
       (setq txt0 (cdr (assoc 1 (entget enTxt))))
       (not (findfile (setq txt (strcat Dir txt0))))
       (setq pt (getpoint "\nPick Insertion Point: "))
       (setq ss (ssget))
       )
    (progn
      (vl-cmdf "_undo" "mark")
      (vl-cmdf "_move" ss "" pt "0,0,0")
      (vl-cmdf "_zoom" "object" "p" "")
      (vl-cmdf "_-wblock" txt "" pt ss "")
      (vl-cmdf "_undo" "back")
      )
    )
  (vl-cmdf "_undo" "end")
  (princ)
  )

Would anyone be able to help me to get this to work ?

 

Tia

Accepted solutions (1)
3,197 Views
4 Replies
Replies (4)
Message 2 of 5

regisrohde
Advocate
Advocate

Works, save the block in the same folder dwg.

Please mark this as the solution if it resolves your issue.Kudos gladly accepted.
Regis Rohde
0 Likes
Message 3 of 5

Anonymous
Not applicable

doesnt seem to be working for me for some reason 

 

i run the command qwblock 

 

click on the text that i want to use for the block name and it doesnt do anything 

 

heres whats in the command window

 

Command: QWBLOCK

Select Block name Text:
Command:

 

If i remove some of the lisp it lets me select the text and then objects and insersion point but it wont output the block because its not passing all the information to be able to save it 

 

here is what i removed and it allows me to do the above 

 

(eq (cdr (assoc 0 (entget enTxt))) "TEXT")

 

0 Likes
Message 4 of 5

Anonymous
Not applicable

It seems to be working for me now i have removed 

 

(eq (cdr (assoc 0 (entget enTxt))) "TEXT")
0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

It seems to be working for me now i have removed 

 

(eq (cdr (assoc 0 (entget enTxt))) "TEXT")

Were you perhaps selecting an Mtext object, instead of Text?  That would stop the whole thing, because the (and) function would return nil.

 

If that's the issue, but you want to allow either Text or Mtext, you could replace the above with:

(wcmatch (cdr (assoc 0 (entget enTxt))) "*TEXT")

which would allow either, but it would just quietly stop if you picked, say, a Line, rather than giving you some kind of error from trying to get text content from such a thing, or look for a file name that's only a directory name because no text content is added to the end of it.

Kent Cooper, AIA