Creating Color Layers for Plotting Using Beautiful Soup to Decompose Inkscape SVG Elements and Using Axidraw Hatch Fill Inkscape Extension
DigitalPeople1_BYR |
with open("composite1_nosquares.svg") as fp:
soup = BeautifulSoup(fp, "lxml-xml")
for tag in soup.find_all(re.compile("")):
if tag.name == 'rect':
tag.decompose()
print(soup)
This gives me a file like this in Inkscape:
I decided to arbitrarily divide the rect elements into 3 groups with the plan for each group to be a given color. I created a variation on the above script to remove polygons and then keep one out of threee of the rects in order that they appear in my svg called parse_keeprect0.py :
from bs4 import BeautifulSoup
import re
rect_count = 0
with open("composite1_nosquares.svg") as fp:
soup = BeautifulSoup(fp, "lxml-xml")
for tag in soup.find_all(re.compile("")):
if tag.name == 'polygon':
tag.decompose()
for tag in soup.find_all(re.compile("")):
if tag.name == 'rect':
if rect_count == 1:
tag.decompose()
if rect_count == 2:
tag.decompose()
rect_count = rect_count + 1
if rect_count == 3:
rect_count = 0
print(soup)
This gives me an SVG file like this when opened up in Inkscape:
I made two more variations of this to keep the other two groups of rect elements, e.g. parse_keeprect1.py would give me the next group of rects with keeping one out of three.
The next challenge is to fill the rect elements. If this was going to be printed out with an inkjet printer the the fill attribute could be used to color the squares, but since I want to plot the artwork, I need to create paths to fill the interior of the rects.
I looked into how to create the paths to fill an enclosed svg element and I discovered that Evil Mad Scientists Laboratory (EMSL) has already created an Inkscape extension for hatching that is amazing and will fill all enclosed paths with hatching at a user defined angle and density (thank you for making this available EMSL!).
I opened my rect element only SVG's and used the EMSL Inkscape extension Hatch fill to create paths to fill in the rectangle outlines.
This gives me an output like this in Inkscape:
The next step is to generate gcode for each of the four SVG files (outline file of polygons and three rect element files), which I used juicy-gcode to accomplish, then send them via Octoprint to my plotter. I originally only purchased black Staedtliner fine tip pens, but I purchased another set that contains many colors. I picked some color combinations that seem pleasing together and created some different plots.
The first plot I made with bright yellow, red and deep blue "DigitalPeople1_color_BYR" which is at the top, it has a couple of lines across because I didn't set the pen quite high enough.
I made a couple more DigitalPeople1 plots with some other color combinations, they each have different emotional energies.
DigitalPeople1_GPB |
DigitalPeople1_CYG |
DigitalPeople2_CYR |
DigitalPeople3_CYR |
Disclaimer
The author does not make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information on this site is strictly at your own risk, and the author will not be held liable for any losses and damages in connection with the use of this information.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Comments
Post a Comment