Sure.
I will assume there is only 1 attribute per block. But it doesn't matter what the tag is now.
;; Get Attribute Values - Lee Mac
;; Returns an association list of attributes present in the supplied block.
;; blk - [ent] Block (Insert) Entity Name
;; Returns: [lst] Association list of ((<tag> . <value>) ... )
(defun LM:getattributevalues ( blk / enx lst )
(while (and (setq blk (entnext blk)) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk))))))
(setq lst
(cons
(cons
(cdr (assoc 2 enx))
(cdr (assoc 1 (reverse enx)))
)
lst
)
)
)
(reverse lst)
)
;; Set Attribute Values - Lee Mac
;; Sets attributes with tags found in the association list to their associated values.
;; blk - [ent] Block (Insert) Entity Name
;; lst - [lst] Association list of ((<tag> . <value>) ... )
;; Returns: nil
(defun LM:setattributevalues ( blk lst / enx itm )
(if (and (setq blk (entnext blk)) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk))))))
(if (setq itm (assoc (cdr (assoc 2 enx)) lst))
(progn
(if (entmod (subst (cons 1 (cdr itm)) (assoc 1 (reverse enx)) enx))
(entupd blk)
)
(LM:setattributevalues blk lst)
)
(LM:setattributevalues blk lst)
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Increment Decrement Attribute
(defun c:ida ( / tag ent pp inc attr val)
(while (setq ent (entsel "\nClick right of the circle/block to increment, left to decrement: "))
(setq pp (cadr ent))
(setq inc
(-
(nth 0 pp) ;; pick point, x value
(nth 0 (cdr (assoc 10 (entget (car ent))))) ;; IP, x value
)
)
;; read the attributes; I only expect 1
(setq attr (LM:getattributevalues (car ent)))
(setq tag (nth 0 (nth 0 attr)))
(setq val (atoi (cdr (assoc tag attr))))
(if (> inc 0.0)
(LM:setattributevalues (car ent) (list (cons tag (itoa (+ val 1)))))
(LM:setattributevalues (car ent) (list (cons tag (itoa (- val 1)))))
)
)
(princ)
)