This xslt will convert inkscape's PLAIN svg files to dia shapes. xsltproc svg2shape.xslt --stringparam icon-file firewall.icon \ firewall.svg > firewall.shape
The attached bash script "genshape" will use inkscape to export the icon and the simple svg and converts this to the shape file all in one go. DIA-isms Here is how the standard dia meta data is obtained: 1. The first "text" with id "textbox" is converted into the shape's textbox and removed from the svg. The text in this text becomes the <name> of the shape. 2. All items with an id that begins with "connector_" generate a <connections><point> tag with the connection point in the middle. This is calculated by taking the average of the min and max x points and the min and max y points. The min and max taken from attributes x, x1, x2, width and pulling out all the X coordinates in draw paths, or y, y1, y2, height or all of the Y coordinates in the draw paths (@d attribute) There are also some -isms to correlate the -isms in shape2svg, such that the connections were put into a <connections> layer and the shape was put into a shape layer. inkscape is explicit about draw styles, so there was no need to fixup assumptions when converting to shape. BUGS: Currently I do NOTHING about transforms or groups or other svg forms that dia can't handle. I don't preserve the order of connection points, ubt I don't think it matters. I still haven't worked out how to get xsltproc to generate the right namespace prefixes. So where does this leave us? I can make simple drawings (and moderately complex ones) in SVG. 1. I just make sure the ID for visual connection points begins with "connection_", 2. I make sure there is a text area with id "textbox" and contents "Network -Firewall" or whatever. then I can convert and make a shape file really easily! Sam
#! /bin/bash PNG="`dirname "$1"`/`basename "$1" .svg`.png" SHAPE="`dirname "$1"`/`basename "$1" .svg`.shape" # generate png inkscape -e "$PNG" -w 22 "$1" # generate simple svg inkscape --export-plain-svg=/dev/stdout "$1" | \ xsltproc --stringparam icon-file "`basename "$PNG"`" xslt/svg2shape.xslt - \ > "$SHAPE"
_______________________________________________ Dia-list mailing list Diafirstname.lastname@example.org http://mail.gnome.org/mailman/listinfo/dia-list FAQ at http://live.gnome.org/Dia/Faq Main page at http://live.gnome.org/Dia