[CM] Plotters was MCL 5 with CLM / openmcl plotters?
Orm Finnendahl
finnendahl@folkwang-hochschule.de
Thu, 23 Oct 2003 15:07:02 +0200
--pf9I7BMVVzbSWLtt
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Hi Ken,
I found out that it actually is quite simple to import the edited
graphics from xfig back into cm. Attached is a simple gawk script
which does the job. Basically it is a filter which discards anything
which is not a line and wraps coordinates, length, colour and depth
(xfig's name for layers) into a list. Groupings are reflected by
sublists. Any lines in depths 45, 46 and 50 are ignored in case you
need extra lines in the graph which shouldn't be seen by cm (in my
case staff lines, timelines and such).
The script writes the lists to stdout. Following is the scheme code to
write a file to /tmp and reimport the output. I guess it could be done
with a pipe as well.
---------------------------------------------------------------
(define (import-from-xfig fname)
(call-with-input-file (format #f "~a" fname)
(lambda (my-port)
(let ((line #f))
(loop
do (set! line (read my-port))
while (not (eof-object? line))
collect line
)))))
(define imported-list '())
(let ((fname "u-name-it.fig"))
(shell
(format #f
"gawk -f scan-xfig.awk ~a > /tmp/xfig-export.scm"
fname))
(set! imported-list (import-from-xfig "/tmp/xfig-export.scm")))
---------------------------------------------------------------
Let me know if you need the code for the other way around.
I'm in the process of finishing a piece and the setup is transparent
in both directions: I go back and forth between graphic editing,
reimporting, editing with scheme and exporting again. I wonder why I
haven't come up with this idea earlier. Thanks for pushing my nose in
it...
--
Orm
Am 17. Oktober 2003, 12:52 Uhr (-0700) schrieb Ken Locarnini:
> >I'm not sure, what you mean. Go to the homepage of xfig (google for
> >it) and check the manual. The lines you see are all objects which can
> >be edited in any way you could possibly edit data in a vector graphics
> >application (move, delete, copy, scale, rotate, group, recolor...).
>
> Great, that sounds like what I was looking for.
> >
> >You only have to keep in mind that there is no way back to lisp/scheme
> >once you changed the data (at least not a trivial one).
>
> Bummer, thats what I was hoping for. What about plotting out editable
> plots in Snd or ATS? I don't know much about any of this but would like
> to work in this direction.
>
> Thanks,
> Ken
>
>
--pf9I7BMVVzbSWLtt
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: attachment; filename="scan-xfig.awk"
BEGIN {
# xfigs units are integers.
# 45 units represent one millimeter,
# the smallest value for the grid mode.
# In this setting, one eigth of time-increment
# (0.125 or a 32nd note in lisp) equals 1 grid step
# and pseudo-midi-pitch gets translated so that
# 100 cents (1.0 in lisp) also equals 1 grid step (1mm)
# in xfig (Handy for graphical transposition with
# ruler display).
xscale = 360;
yscale = 45;
}
{if ($1 == 6) {
printf "(";}
else {if ($1 == -6) {
printf ")";}
else {if (($1 == 2) && ($7 != 45) && ($7 != 46) && ($7 != 50)) {
color = $5 - 36;
depth = $7;
getline;
string = sprintf("(%d %.2f %.3f 1 %d %d)\n", \
(156 - (($2 - 45) / yscale)), \
(($1*2) / xscale), \
((($3-$1) * 2) / xscale), \
color, \
depth);
# replace "," in floats to "."
printf "%s", gensub(",",".","g",string);
}
}
}
}
END {}
--pf9I7BMVVzbSWLtt--