Giter Club home page Giter Club logo

inkex-bh's Introduction

Inkscape Extensions for Barn Hunt

Tests PyPI Version Python Versions Inkscape Versions PyPI Status Trackgit Views

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.

What’s Here?

Currently there are four extensions.

Count Symbols

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.)

Example output from the "Count Symbols" extension

The bh:count-as symbol attribute

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.

Create Inset

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:

  1. Hide/unhide layers as you wish, to make what you want visible in the exported image visible.

  2. 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.)

Regenerating the Insets

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.

Hide Rats

The third extension is used to randomize the position of rat tubes on rat maps.

Instructions pending... :-/

Set Random Seed

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.


Installation

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.

Manual Installation

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:

  1. 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.)

  2. 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.)

Packaging

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.


What's Elsewhere?

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.

Barn Hunt Symbol Libraries for Inkscape

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.

The barnhunt command-line export utility

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.

Author

Jeff Dairiki, BHAJ-221A [email protected]


inkex-bh's People

Contributors

dairiki avatar

Watchers

 avatar

Forkers

dairiki

inkex-bh's Issues

"Create Inset" plugin doesn't work with Inkscape-1.2.2 AppImage

The attempt by the plugin to run Inkscape to export the PNG image fails with some complaint from ld-linux-x86-64.so.2 about AppRun being an unrecognized binary.

/tmp/.mount_inkscaz5AuvJ/AppRun: error while loading shared libraries: /tmp/.mount_inkscaz5AuvJ/AppRun: invalid ELF header

Command '('/tmp/.mount_inkscaz5AuvJ/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2', '--inhibit-cache', '--library-path', '/tmp/.mount_inkscaz5AuvJ/lib/x86_64-linux-gnu:/tmp/.mount_inkscaz5AuvJ/usr/lib/x86_64-linux-gnu:/tmp/.mount_inkscaz5AuvJ/usr/lib', '/tmp/.mount_inkscaz5AuvJ/AppRun', '--export-filename=/tmp/bh-cesfmuma/output.png', '--export-type=png', '--export-id=g294', '--export-dpi=72.000000', '--export-background=#ffffff', '--export-background-opacity=1.000000', '/tmp/bh-cesfmuma/input.svg')' returned non-zero exit status 127.

I suspect this is connected to the setting of INKSCAPE_COMMAND environment variable in AppRun which is new in 1.2.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.