[cad-linux-dev] Re: YAML file format - Optional attributes

  • From: Bruno Postle <bruno@xxxxxxxxxx>
  • To: CAD linux development <cad-linux-dev@xxxxxxxxxxxxx>
  • Date: Wed, 22 Sep 2004 14:01:36 +0100

On Tue 21-Sep-2004 at 18:48 -0500, Eric Wilhelm wrote:

> Two line entities of different versions within the same directory is  
> incompatible with this.  Similar sentiments for units, copyright, 
> license, etc.  That's why I think these things should only be defined 
> in "./drawing".

The advantage of storing "copyright" at the entity level is that it 
allows shared ownership of drawings.

For me the prime motivation for doing this stuff is that I see 
systems that work wonderfully for software development which are 
tragically unused in the design world - One of those systems is the 
whole Open Source thing.

> This is what I've been calling the "grep litmus test".

> e.g., the following should tell me what layer ID's in this drawing 
> contain lines:
>
>  for line in `grep -l "^type: line" *.yml`
>    do grep "^layer:" $line | sed 's/layer: \+//'
>  done

A few comments:

*  The YAML file format fails the grep test immediately as soon as 
   it moves beyond simple key/value pairs.  For instance, how do you 
   ask the current system to list all circles with centres above the 
   value y=3?

   To be able to do this with a grep-able format, all lists need to 
   be collapsed onto one line:

       centre: 100, 5.6, 10

*  Your shell script could easily output a default value if it can't 
   find a defined layer:

       do (grep "^layer:" $line || echo '') | sed 's/^layer: \+//'

   ..or just use a YAML parser and don't worry about grep:

       perl -MYAML -e "\$a=YAML::LoadFile(\"$line\"); print \"\$a->{layer}\n\""

*  With AutoCAD, the "special" layer 0 is equivalent to an 
   unspecified layer, so this is exactly how existing CAD systems 
   work anyway.

-- 
Bruno

Other related posts: