TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Matt__W on September 29, 2015, 09:48:41 AM

Title: Find block attribute tag
Post by: Matt__W 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.  
Title: Re: Find block attribute tag
Post by: ronjonp 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))