Background masking is one of the cool new time saving features in AutoCAD 2005. Even though I have been MIA from my Blog and Website for about a week, I have still been monitoring the Autodesk NGs (Newsgroups). There have been several things that people have been looking for information on. The top items that I have seen are Sheet Sets, Fields and Background masking... if you want to include the multiple Copy change that has been on the top of the list as well. I will talk about that later though. The way Background Masking was implemented for Dimensions Styles some will bark about it and others will be happy with it. Background Masking is implemented as a bolt onto Dimensions Styles as Xdata and like I said for most they will use the UI and be done with it.
So if you wanted to set Background Masking on a Dimension style via Visual LISP how would you go about it. The first thing you should always do is attempt to rip apart or breakdown what the standard AutoCAD commands do. This is the first thing I do before I try to emulate core AutoCAD behavior when implementing custom functionality. Anyways, below is an example of the Xdata that is appended to a Dimension Style when Background Masking is enabled through the UI.
(-3
("ACAD_DSTYLE_DIMTEXT_FILL"
(1070 . 376)
(1070 . 2)
(1070 . 377)
(1004 . "1800000001000000020000C3000000000000000000000000")
)
)
All I can ask is don't send me an e-mail to try and explain it as I have not broken everything down yet and don't think I will get everything figure out for a while yet. I have a feeling a couple of the values are intended for future use as Autodesk does this at times with new features.
What I do know is that the second 1070 value does vary when using the Background color or a specified color.
1 - Use for Background Color
2 - Use the specified color in value 1004
Based on what I have figured out on the 1040 value I have broken down the value of the ACI and True colors.
1800000001000000020000C3000000000000000000000000
1800000001000000 020000 C3 000000000000000000000000
The first part determines if a True/ACI color or Color Book color is used.
The second part determines color in the format of Hexadecimal values in the order of B,G,R or RGB backwards.
So CCF4BE would be equal to 190,244,204 in the True color tab of the Color Dialog box. Since the value is in hexadecimal value you need the following to decipher the value into the correct color values.
CC = 12*16 + 12 = 204
Hexadecimal is base 16 vs. binary base of 2.
F = 15
E = 14
D = 13
C = 12
B = 11
A = 10
9 = 9
8 = 8
7 = 7
6 = 6
5 = 5
4 = 4
3 = 3
2 = 2
1 = 1
0 = 0
The third element in the value seems to be related to the color as well. This could be part of how the color is determined and calculated as FF0000 as an ACI (255) value would sure be different than FF0000 as a True Color.
C0 - Background or ByLayer
C1 - ByBlock
C2 - True Color or Color Book
C3 - ACI
As for the fourth element I can only find that it relates to a Color Book color. Now for what the value standards for it might be an Object ID value of some sort, but I have yet to actually figure out a cross reference to it yet.
So to make things a little bit easier I created a function that allows you to assign and change the value via LISP.
;; Begin code
;; Written by Lee Ambrosius
;; Created on: 4/3/2004
;; This program allows you to specify a Dimension Style to add Background Color to
;; Not sure why this varies so much from the way Mtext and single Dimension objects work.
;; Use the DDim command to set the value that you want and then use the line of LISP code below
;; to get the newly set value.
;; (assoc -3 (entget (tblobjname "dimstyle" "standard") '("*")))
;; Use Yellow for the fill color
;; (-3 ("ACAD_DSTYLE_DIMTEXT_FILL" (1070 . 376) (1070 . 2) (1070 . 377) (1004 . "1800000001000000020000C3000000000000000000000000")))
;; Use Background Color for the fill color
;; (-3 ("ACAD_DSTYLE_DIMTEXT_FILL" (1070 . 376) (1070 . 1) (1070 . 377) (1004 . "1800000001000000000000C0000000000000000000000000")))
;; Use Bylayer for the fill color
;; (-3 ("ACAD_DSTYLE_DIMTEXT_FILL" (1070 . 376) (1070 . 2) (1070 . 377) (1004 . "1800000001000000000000C0000000000000000000000000")))
;; Use ByBlock for the fill color
;; (-3 ("ACAD_DSTYLE_DIMTEXT_FILL" (1070 . 376) (1070 . 2) (1070 . 377) (1004 . "1800000001000000000000C1000000000000000000000000")))
;; Use Color Book Color for the fill color
;; (-3 ("ACAD_DSTYLE_DIMTEXT_FILL" (1070 . 376) (1070 . 2) (1070 . 377) (1004 . "3100000001000000B6CFFAC203000000060000004449432031001300000044494320434F4C4F5220475549444528522900")))
;; Use True Color for the fill color
;; (-3 ("ACAD_DSTYLE_DIMTEXT_FILL" (1070 . 376) (1070 . 2) (1070 . 377) (1004 . "1800000001000000DFF2C0C2000000000000000000000000")))
;; Example (setBackgroundColorDimStyle "Standard" '("ACAD_DSTYLE_DIMTEXT_FILL" (1070 . 376) (1070 . 1) (1070 . 377) (1004 . "1800000001000000000000C0000000000000000000000000")))
(defun setBackgroundColorDimStyle (sDimStyleName lstValue / tableEnt entData)
(if (/= (setq tableEnt (tblobjname "dimstyle" sDimStyleName)) nil)
(progn
(setq entData (entget tableEnt '("ACAD_DSTYLE_DIMTEXT_FILL")))
(if (/= (assoc -3 entData) nil)
(if (= (nth 0 (cadr (assoc -3 entData))) "ACAD_DSTYLE_DIMTEXT_FILL")
(setq entData (subst (cons -3 (list lstValue)) (assoc -3 entData) entData))
(setq entData (append entData (list (list -3 lstValue))))
)
(setq entData (append entData (list (list -3 lstValue))))
)
(entmod entData)
)
)
(princ)
)
;; End code
I hope to figure out more to these values in the upcoming weeks, but until then the information above is all that I have on file and is more than what is in the help files in AutoCAD.
Sincerely,
Lee Ambrosius

Hi, Lee
have you come up with a lisp for applying a background color fill to selected dimensions? or to add the background color fill to selected dimensions' dimstyle?
Posted by: Paulo | Wednesday, December 09, 2009 at 12:38 PM