Author Topic: Find block attribute tag  (Read 1907 times)

0 Members and 1 Guest are viewing this topic.

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Find block attribute tag
« on: September 29, 2015, 09:48:41 AM »
I've been out of the coding scene for way too long. I can't remember how to find an attribute within a block and subsequently modify it, but we'll cross that bridge when we get there. The block only has one attribute within it so that makes it easier. Here's my code so far.


Code - Auto/Visual Lisp: [Select]
  1. (defun C:BlkRotation ( / ss cnt bName assoclist blkRotation)
  2.    (setq ss (ssget '((0 . "insert")(66 . 1)((2 . "MYBLOCK"))))
  3.    (repeat (setq cnt (sslength ss))
  4.       (setq bName (ssname ss (setq cnt (1- cnt))))
  5.       (setq assoclist (entget bName))
  6.       (setq blkRotation (assoc 50 assoclist))
  7.  
  8. ;;;This is where I can't remember how to find the attribute and then modify it.
  9.       (if block has attribute BLKROTATION then
  10.          (entmod block attribute value with block's actual rotation angle
  11.       ) ;end if statement...
  12.  
  13.    )
  14.    (princ)
  15. )
  16.  
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Find block attribute tag
« Reply #1 on: September 29, 2015, 11:34:50 AM »
Maybe this? FWIW .. I'd use vla-* over entmod for this task.


Code - Auto/Visual Lisp: [Select]
  1. (foreach att (vlax-invoke blkobj 'getattributes) (vla-put-rotation att blkrotation))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC