TableStyle Text Color

TableStyle Text Color

MarkSanchezSPEC
Advocate Advocate
2,173 Views
5 Replies
Message 1 of 6

TableStyle Text Color

MarkSanchezSPEC
Advocate
Advocate

I've created a new text style via AutoLisp but am struggling trying to set the text color. I would like to set the Title, Header, and Data row text colors per my attachment (ACI colors 12, 11, and ByLayer respectively). I've tried (vla-put-TextColor) and (vla-SetCellContentColor) without success.

0 Likes
Accepted solutions (1)
2,174 Views
5 Replies
Replies (5)
Message 2 of 6

ronjonp
Mentor
Mentor
Accepted solution

Probably need to use VLA-SETCOLOR.

0 Likes
Message 3 of 6

ronjonp
Mentor
Mentor

Quick example to set the colors of the style from a picked table:

(defun c:foo (/ co e el o)
  ;; RJP » 2019-11-12
  (cond	((and (setq e (car (entsel)))
	      (= "ACAD_TABLE" (cdr (assoc 0 (setq el (entget e)))))
	      (setq co (vla-get-truecolor (vlax-ename->vla-object e)))
	      (setq o (cdr (assoc 342 el)))
	 )
	 (vla-put-colorindex co 12)
	 (vla-setcolor (setq o (vlax-ename->vla-object o)) actitlerow co)
	 (vla-put-colorindex co 11)
	 (vla-setcolor o acheaderrow co)
	 (vla-put-colorindex co 256)
	 (vla-setcolor o acdatarow co)
	)
  )
  (princ)
)
Message 4 of 6

MarkSanchezSPEC
Advocate
Advocate

vla-SetColor worked as follows:

 

    (setq colObj (vlax-create-object (strcat "AutoCAD.AcCmColor." (substr (getvar "ACADVER") 1 2))))
    (vla-put-colormethod colObj acColorMethodByACI)
    (vla-put-colorindex colObj 12)
    (vla-SetColor tblSty acTitleRow colObj)
    (vla-put-colorindex colObj 11)
    (vla-SetColor tblSty acHeaderRow colObj)
    (vla-put-colorindex colObj 256)
    (vla-SetColor tblSty acDataRow colObj)

(vlax-release-object colObj)

Thanks again!

0 Likes
Message 5 of 6

ronjonp
Mentor
Mentor

Glad to help 🙂 .. not sure if you saw the code above but it will let you select a table to change the style properties ( not much error checking ).

0 Likes
Message 6 of 6

MarkSanchezSPEC
Advocate
Advocate

I did. I'm just adding a table style for now but will keep that snippet handy too.

Regards!

0 Likes