cmdline: select obj, hide obj, export its area

Post questions on how to use or achieve an effect in Inkscape.
ronburk
Posts: 32
Joined: Sat Nov 05, 2011 6:21 am

cmdline: select obj, hide obj, export its area

Postby ronburk » Mon Sep 17, 2018 7:54 pm

Latest Inkscape, Windows 7.

I have many .svg figures for a book. When I modify any such .svg, a custom build process regenerates the lineart file from the .svg that I need to feed into pdflatex to build the book. In each .svg, I have a box that identifies the area that should be exported. I give this box a known id ("ExportBox") so that the build tool can call Inkscape to export its area. There's lots of other crud (but potentially useful crud) in the drawing laying around outside the bounding box, so I definitely never want to export all to create a final image. This all works, albeit with an irritant that's grown so irritating I'm trying now to fix it.

Problem is, I like the bounding box to have a light fill so I can see it easily while I work. If I forget to hide that bounding box, then the exported image will, of course, display it, ruining the final image. I would really like the build tool to do the right thing and not have to manually hide the bounding box after I make every change (and then show it again if I decide to make another change).

All this seems like it would be trivial if there were actual a command-line verb to hide the current selection, but I don't see any such verb. I would be willing to switch to giving the bounding box its own layer, but I don't see any way via command-line verb to hide a specific layer either. (well, I guess you could issue N LayerPrev verbs and hope no drawing has more than N layers -- as yech a solution as my next one)

The only thing I can think of is to use command-line verbs to get the position/size of the bounding box (AFAICT, this would require running inkscape 4 separate times, as you can only get one of the coordinates at a time from the command-line), then running inkscape a fifth time and using a verb to delete the bounding box, having specified the export area using the --export-area and the 4 numbers previously gathered. Or, --query-all and locate the desired object in the output. This would be automated, but yech, so I just wondered if there's a slick trick to do this that I'm missing.

User avatar
Xav
Posts: 1209
Joined: Fri May 08, 2009 1:18 am
Location: UK
Contact:

Re: cmdline: select obj, hide obj, export its area

Postby Xav » Mon Sep 17, 2018 8:18 pm

Note: I may be misunderstanding the problem, and I'm not an Inkscape command line user.

Since each drawing must only have a single exportable area (as you're using a known ID to select it), couldn't you change the page dimensions to that of the exportable area and then export the page? Your other useful crud can still live outside the page, and you can use the Document Properties dialog to give the page a background colour (and ensure the page border is visible) - neither of which will be included in the exported file.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter

ronburk
Posts: 32
Joined: Sat Nov 05, 2011 6:21 am

Re: cmdline: select obj, hide obj, export its area

Postby ronburk » Tue Sep 18, 2018 3:14 pm

That is an excellent idea I never thought of. Normally I set the page dimension to that of the book so that I can keep an eye on how things fit on the page as I'm drawing, but I can kind of invert that arrangement by drawing an unfilled box to represent the page and putting the (now virtual, not actual) page inside that.

And, since Ctrl-Shift-R resizes the page to the selection, it's not much harder to change the "bounding box" (which will now be the Inkscape page) than it was before. Just select all the relevant objects and give it one 3-key salute. --export-area-page is definitely easier than having to remember to set a particular object ID in each drawing.

AFAICT, one can only set the background color for the entire screen, rather than just the page. But using the "Show border shadow" option for the page makes it look somewhat different than other rectangles that may be floating around. Since I'm only working in pure black and white, I can also set the page border color to red or something, which should eliminate any possible confusion.

This seems like a much better approach than the path I was following -- thanks for your help!

User avatar
Xav
Posts: 1209
Joined: Fri May 08, 2009 1:18 am
Location: UK
Contact:

Re: cmdline: select obj, hide obj, export its area

Postby Xav » Tue Sep 18, 2018 5:11 pm

Glad I could help.

You're right that you can only set the background colour for the entire screen - which is fine if you need some contrast with what you're drawing, not so useful to indicate the extent of the page. But, as you note, using a border shadow or a coloured page border addresses that issue.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter


Return to “Help with using Inkscape”