Jump to content

Recommended Posts

Posted (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 by mhupp
Posted
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

Posted

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)
)

 

  • Like 2
Posted

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 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...