[PythonCAD] schema location / colors

Eric Wilhelm ewilhelm at sbcglobal.net
Tue Jul 27 04:26:48 CEST 2004


Will this eventually point at an actual .xsd file or something?
    schemaLocation="http://www.pythoncad.org">

What I really want to know is why colors are assigned id's like so:

      <image:Color b="0" color="#000000" g="0" id="0" r="0"/>
      <image:Color b="255" color="#0000ff" g="0" id="1" r="0"/>
      <image:Color b="255" color="#00ffff" g="255" id="2" r="0"/>
      <image:Color b="210" color="#508cd2" g="140" id="3" r="80"/>
      <image:Color b="0" color="#ffff00" g="255" id="4" r="255"/>
      <image:Color b="255" color="#ffffff" g="255" id="5" r="255"/>

This seems to be an unnecessary complication in representing the colors 
(though your notes about transitioning to strictly #00FF00 representations 
are duly noted.)

Why even have a table of colors?  I'll try to answer my own question, but 
first a rant about the failings of AutoCAD.

Granted, the hexadecimal representation was not likely very standard when 
autocad started and 24-bit color was possibly even unheard-of at that time.  
However, they maintained the ACI (Autocad Color Index) convention through to 
2000 (I think it changed near version 2004?)

The ACI uses the numbers 0-256 to represent 255 colors and the special 'by 
layer' (256) and 'by block' (0) colors.  My guess is that this convention 
started partly from the need for optimization and partly from the lack of a 
predominant convention.  Today's hardware is rocket-like compared to the 
hardware of the 70's, so we can safely discard optimization as a need for 
indexing colors.

However, the #09ABCF hexadecimal convention limits us to some extent because 
we cannot have the non-color colors (or rather, inherited colors) of 'by 
block' or 'by layer' or even 'by date' (that last one is just for fun.)  But, 
since we are storing things textually and not allocating three byte-sized 
registers on a magnetic drum, we can use arbitrarily high ascii characters in 
these slots and have colors like #BY0001, or simply deliberately disobey the 
6-character limit and call it #BYLAYER.  The presence of one high character 
is enough to throw a color_parse() subroutine into mode-2, but a convention 
of #BYfoo allows us a little bit of delicious optimization (e.g. color[1] == 
"Y".)

So, I propose that the colors be represented directly in the entities' 
properties as 'extended hexidecimal'.  If a color table is needed then, it 
would belong to a layer (or to the drawing), simply listing the default 
colors per-layer.

A blue circle:
  <image:Circle color="#0000ff" cp="0" id="1" r="127.27922061357856" 
style="0"/>

A blue layer:
  <image:Layer id="0" color="#0000ff" name="TopLayer" scale="1.0">
    <image:Circles>
      <image:Circle color="#BYLAYER" cp="0" id="1" r="127.27922061357856" 
style="0"/>

I don't have any strong opinion about where the layer's properties are stored, 
but this seems to be a fitting place.

--Eric


More information about the PythonCAD mailing list