mhupp Posted May 19 Posted May 19 (edited) 3 hours ago, Kvlar said: i get an error like this: error: bad argument type: VLA-OBJECT <Entity name: 181bbe5aaf0> Is there anything I did wrong? But, thank you for helping me No just me coding in notepad and not testing the code. needed to converted the nentsel to vla-object updated the code. Edited May 19 by mhupp Quote
Kvlar Posted May 19 Author Posted May 19 50 minutes ago, mhupp said: No just me coding in notepad and not testing the code. needed to converted the nentsel to vla-object updated the code. I tried testing the code, but the block name I got was random like *U414 or *U180 . Not the original block name. Correct me if I'm wrong Quote
marko_ribar Posted May 19 Posted May 19 Here, try this mhupp's mod... ;;----------------------------------------------------------------------------;; ;; PULL BLOCKS NAME TO UPDATE ATTRIBUTE (defun C:ATTBLKNAME () (C:ABN)) (defun C:ABN ( / effectivename ent Name Att ) (defun effectivename ( ent / blk rep ) (if (wcmatch (setq blk (cdr (assoc 2 (entget ent)))) "`**") (if (and (setq rep (cdadr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" blk) ) ) ) '("AcDbBlockRepBTag") ) ) ) ) (setq rep (handent (cdr (assoc 1005 rep)))) ) (setq blk (cdr (assoc 2 (entget rep)))) ) ) blk ) (while (setq ent (car (entsel "\nSelect Block"))) ;gets an entity name using while will keep repeating if you keep selecting an entity (if (= (cdr (assoc 0 (entget ent))) "INSERT") ;test if its a block (progn (setq Name (effectivename ent)) ; pulls the name (setq Att (vlax-ename->vla-object (car (nentsel "Select Attribute Text to update")))) ; nentsel can get entity names inisde blocks (vla-put-textstring Att Name) ;update entity with name ) (progn ;if entity isn't a block will prompt user (prompt "\nNot a Block Pick again") (c:ABN) ;and start the comman over again. ) ) ) (princ) ) 2 Quote
Kvlar Posted May 19 Author Posted May 19 this is exactly what I need. Thank you very much to all of you guys I hope I can be an expert in making autolisp like all of you 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.