TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jlogan02 on February 27, 2020, 12:48:21 PM

Title: Reactor? Change color of text if specific attribute tag edited.
Post by: jlogan02 on February 27, 2020, 12:48:21 PM
The attached image shows text place holders in green and color 15. Color 15 represents "future condition".
The approval stamp is attributed with each initials line being a separate tag.

So...
If tag1, tag2 and tag5 are edited, change their color to green.

How do I get the color property of a specific tag in an attribute?

J.
Title: Re: Reactor? Change color of text if specific attribute tag edited.
Post by: jlogan02 on February 27, 2020, 12:59:10 PM
attached image
Title: Re: Reactor? Change color of text if specific attribute tag edited.
Post by: Dlanor on February 27, 2020, 01:17:32 PM
Code - Auto/Visual Lisp: [Select]
  1. (if (vlax-method-applicable-p blk 'getattributes) (setq atts (vlax-invoke blk 'getattributes))) ;;blk is a block object
  2.  
  3. (if (= :vlax-true (vlax-get-property blk 'hasattributes)) (setq atts (vlax-invoke blk 'getattributes))) ;; this is probably better though, again blk is a block object
  4.  
  5. (foreach att atts
  6.   (princ (strcat (vlax-get att 'tagstring) " : " (itoa (vlax-get att 'color))))
  7. )
  8.  
Title: Re: Reactor? Change color of text if specific attribute tag edited.
Post by: rayakmal on February 28, 2020, 08:43:12 PM
Code - Auto/Visual Lisp: [Select]
  1. (if (vlax-method-applicable-p blk 'getattributes) (setq atts (vlax-invoke blk 'getattributes))) ;;blk is a block object
  2.  
  3. (if (= :vlax-true (vlax-get-property blk 'hasattributes)) (setq atts (vlax-invoke blk 'getattributes))) ;; this is probably better though, again blk is a block object
  4.  
  5. (foreach att atts
  6.   (princ (strcat (vlax-get att 'tagstring) " : " (atoi (vlax-get att 'color))))
  7. )
  8.  

I think (atoi (vlax-get att 'color)) should become (itoa (vlax-get att 'color))
Title: Re: Reactor? Change color of text if specific attribute tag edited.
Post by: Dlanor on February 29, 2020, 01:30:55 AM
Quote
I think (atoi (vlax-get att 'color)) should become (itoa (vlax-get att 'color))

You're right.  :uglystupid2:  Corrected above