PrimeTimeAction Posted May 12 Posted May 12 Any idea why this is giving me error "bad argument type: VLA-OBJECT nil". I am using Autocad 2024. The code is quite old, but iam not not sure if it ever worked. ;;----------------------------------------------------------------------------;; ;; Add Prefix/Suffix to Block Name (defun C:BLKRENAME1 (/ blklst SS blk lst c a n) (vl-load-com) (setq blklst (vla-get-Blocks Drawing)) (prompt "\nSelect Block(s) or Enter To Rename All") (if (or (setq ss (ssget '((0 . "INSERT")))) (setq ss (ssget "_X" '((0 . "INSERT"))))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (setq blk (cdr (assoc 2 (entget ent)))) ;Get Block Name (if (not (vl-position blk lst)) ;If Block Name is not in List Add (setq lst (cons blk lst)) ) ) ) (setq c 0) ;Count (initget "Prefix Suffix") (setq rep (cond ((getkword "\n Specify your aim [Prefix/Suffix] :")) ( "Suffix"))) (cond ((= rep "Prefix") (setq prfx (getstring "\nEnter Prefix: ")) (foreach n lst (vla-put-Name (vla-item blklst n) (strcat prfx n)) (setq c (1+ c)) ) ) ((= rep "Suffix") (setq sufx (getstring "\nEnter Suffix: ")) (foreach n lst (vla-put-Name (vla-item blklst n) (strcat n sufx)) (setq c (1+ c)) ) ) ) (prompt (strcat "\n" (rtos c 2 0) " Block(s) Renamed")) (princ) ) Quote
GLAVCVS Posted May 12 Posted May 12 Hi I don't know what 'drawing' contains. Try replacing it with (vla-get-activeDocument (vlax-get-acad-object)) 1 Quote
PrimeTimeAction Posted May 12 Author Posted May 12 28 minutes ago, GLAVCVS said: Hi I don't know what 'drawing' contains. Try replacing it with (vla-get-activeDocument (vlax-get-acad-object)) This did the job. Thanks a alot. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.