How to pull hex-values from an autocad color book “acb” file

The “.acb” file is actually an xml file. If you open the .acb file inside a text editor, you’ll see something like this:

<?xml version="1.0" encoding="UTF-8"?>
<colorBook>
  <bookName>Eiffel Tower Screen-Shot-2021-03-10-at-8.25.35-AM copy</bookName> 
    <colorPage>
      <pageColor>
        <RGB8>
          <red>245</red>
          <green>244</green>
          <blue>250</blue>
        </RGB8> 
      </pageColor>
      
      <colorEntry> 
        <RGB8> 
          <red>245</red>
          <green>244</green>
          <blue>250</blue> 
        </RGB8> 
      </colorEntry> 
                
      <colorEntry>
        <RGB8>
          <red>236</red>
          <green>235</green>
          <blue>237</blue>
        </RGB8>
      </colorEntry>
    
      <colorEntry>
        <RGB8>
          <red>221</red>
          <green>221</green>
          <blue>224</blue>
        </RGB8>
      </colorEntry>
      
      <colorEntry>
        <RGB8>
          <red>209</red>
          <green>208</green>
          <blue>210</blue>
        </RGB8>
      </colorEntry>
    
      <colorEntry>
        <RGB8>
          <red>137</red>
          <green>138</green>
          <blue>145</blue> 
        </RGB8> 
    </colorEntry>
  </colorPage>
</colorBook>

You’ll see the color values are stored in RGB format. We want them in hex.

Steps to convert acb to hexvalues

1. Convert your acb file to a tab-delimited file

1a. Create an xls file to convert your xml to a tab-delimited file.

Copy the following text into a text document, and name it with an .xsl ending. I used “xsl-pull_rgb_color.xsl”

<xsl:stylesheet version="2.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
<xsl:template match="/">
  <html>
    <body>
       <xsl:for-each select="colorBook/colorPage/colorEntry/RGB8">
               <xsl:value-of select="red"/><xsl:text>&#009;</xsl:text>
               <xsl:value-of select="green"/><xsl:text>&#009;</xsl:text>
               <xsl:value-of select="blue"/>
               <xsl:text>&#xa;</xsl:text>
               
    </xsl:for-each>
   </body>
 </html>
</xsl:template>
</xsl:stylesheet>

1b. Open the .acb file in Xmplify.

1c. Go to Transform > Current Document, Using An XSL File as Template…

1d. Select the xsl file we just made: “xsl-pull_rgb_color.xsl”

1e. It will convert your acb file to this:

245 244 250
236 235 237
221 221 224
209 208 210
137 138 145

2. Copy the tab-delimited file into Google Sheets

Copy that text and paste it into a Google spreadsheet.

First column, red. Second column, blue. Third column, green.

3. Have Google Sheets make the conversion

Fourth column will be a formula: =dec2hex(A2)&dec2hex(B2)&dec2hex(C2)
The dec2hex function suggestion came from Craig Cornelius, Senior Software Engineer at Google

Boom. Now you have your hexvalues!

It’s a little clumsy. Maybe some day I’ll write something in PHP that simply converts the acb file to hex values in one step.

Enjoyed this blog post?

Join the creatives who receive thoughtful Spudart blog posts via the email newsletter

guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x