Here are some Inkscape extensions that are possibly useful when using Inkscape to draw Barn Hunt maps.
These are a freshly updated and rewritten version of plugins that I (and Sandra, my wife) have been using for several years to draw our maps. The sample course map on the official BHA Judging Assignment Cheat Sheet is one of mine. (The previous versions of the plugins worked with Inkscape version 0.x. The plugin API has changed considerably since then, so a rewrite was necessary to get the plugins to work with more modern versions of Inkscape.)
These extensions are, as yet, poorly documented, and likely not to work without tweaks in all environments (I used Linux — these extensions are totally untested on Windows), so I'm not sure that they're generally useful, yet.
The goal is for these to work on all version of Inkscape with versions of 1.0 or greater. Currently, these have be cursorily tested under Inkscape versions 1.1.2 and 1.2.1.
Currently there are four extensions.
We use Inkscape symbol libraries containing map elements like individual bales, rat tube markers, etc to draw our maps. This plugin simply counts what symbols are visible, and reports a list of symbol names along with how many times they are used in the drawing. (By default, only symbols on visible layers are counted.)
Symbols may be marked with a custom bh:count-as
attribute, in order
to have them counted under some name other than their XML id
.
I have a number of different symbols for bales: first level bales,
second level bales, bales on edge, leaners, etc. I would like all
bales of a given size counted under the same name. So, in my symbol
libraries, I set a bh:count-as="bale-42x18x16"
on each of the
variants of 42”x18”x16” bales.
This extension creates an embedded PNG image created by exporting a portion of the drawing. Such images are useful, for example, to include a base-layer map (possibly at reduced scale) on the same page as the complete course map.
To use, one should:
-
Hide/unhide layers as you wish, to make what you want visible in the exported image visible.
-
Select one object in the drawing. That object will define the rectangular bounding box of the exported image. Then run the extension.
This will create an image. It will be created on top of all other layers in the drawing. (You will probably want to move that image into an appropriate layer.)
The layers that were visible when the image was generated, and the
object which defined the boundary of the image are recorded in custom
attributes on the <svg:image>
element. This makes it easy to
regenerate the image(s), should that become necessary (e.g. after
you've made changes to the drawing.)
Simply select just the generated images you'd like regenerated, and fire off the extension. It will adjust layer visibility to match what it was when each image was first exported, and re-export it.
The third extension is used to randomize the position of rat tubes on rat maps.
Instructions pending... :-/
This sets or updates a random number stored in a custom attribute out
the <svg>
element of the drawing. This number is used by the
barnhunt program to seed the pseudo-random number generator used
when expanding text templates. Setting it to a unique number ensure,
e.g., that the Master random rat numbers come out random, but still
reproducible.
When one copies an existing .svg
file to use a template for a new
trial, one should run this plugin, with the force-reseed checkbox
checked, to ensure that the copied file gets a new, unique random
seed.
The easiest way to install these extensions is using the new install
sub-command of my barnhunt
script:
First install Inkscape, python, and, then, my barnhunt script. Finally, run:
barnhunt install
to install both these extensions and my symbol sets into your Inkscape configuration.
It is now recommended to use the barnhunt install
sub-command to
install these extensions (see above). However, they may still be
installed manually.
To manually install a released version of this package:
-
Download the packaged zip file asset from the GitHub Releases page for the desired release. (Those are the zip files named something like
inkex_bh-
version.zip
.) -
Unzip the zip file into your Inkscape user extensions directory.
On Linux this can be done thusly:
# remove previous installed version, if any rm -r "$(inkscape --user-data-directory)/extensions/org.dairiki.inkex_bh" # unpack desired version of extensions to user's Inkscape extensions directory unzip -d "$(inkscape --user-data-directory)/extensions" inkex_bh-X.Y.Z.zip
Warning: It is no longer recommended to install the extensions using
pip
. (Though, for now, the package will continue to be published to PyPI.)
To build a packaged zip file from the git source, clone the git repository, install hatch, then run
hatch build --target zipped-directory
That should build a zip archive in the dist/
subdirectory.
There are two other bits I use when drawing maps.
Neither of these are published in a public place, yet.
And, of course, their use is not documented at all.
Kick me if you want to know more.
I've constructed some symbol libraries for Inkscape containing things like bales, boards, rat markers, fluff pile symbols, etc.
I've even got a semi-automatic scheme set up by which I can generate symbol sets for arbitrary sized bales.
I draw all my maps for a given course (for a day or weekend) on various nested layers in a single drawing. By hiding and unhiding various sets of layers all of my maps can be generated.
I have a python script named barnhunt
, whose primary job
is to automate that layer hiding/unhiding and PDF exporting process.
While exporting the map, it can also expand special template syntax in
text in the drawings. This can be used to automate the printing of
course names and blind numbers on the exported map, and is also used
to generate the random Master rat numbers.
Sadly, at present there is zero documentation on how to use it.
Kick me if you want to know more.
Jeff Dairiki, BHAJ-221A [email protected]