Skip to content

Commit

Permalink
Fix empty file, help
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubAndrysek committed Oct 6, 2021
1 parent 47d2fc7 commit 4b9104a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ dmypy.json

# Pyre type checker
.pyre/
bac
19 changes: 11 additions & 8 deletions InkSvgNest/inkSvgNest.inx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<name>InkSvgNest</name>
<id>org.inkscape.inksvgnest</id>

<label>InkSvgNest is tool for fast nesting SVG components</label>
<label>InkSvgNest is tool for backup nesting configuration</label>
<param name="tab" type="notebook">
<page name="absolute" gui-text="Absolute path">
<param name="a_mode" type="optiongroup" appearance="combo" gui-text="Choose mode" gui-description="Will be writed">
Expand All @@ -25,13 +25,16 @@

<page name="Help" gui-text="Help">
<label xml:space="preserve">
Will be wrote in the nearest future
<!--Adjusts hue, saturation and lightness in the HSL representation of the selected objects's color.-->
<!--Options:-->
<!-- * Hue: rotate by degrees (wraps around).-->
<!-- * Saturation: add/subtract % (min=-100, max=100).-->
<!-- * Lightness: add/subtract % (min=-100, max=100).-->
<!-- * Random Hue/Saturation/Lightness: randomize the parameter's value.-->
InkSvgNest is tool for backup nesting configuration. It is used to easily save, read and edit the position of individual objects in the file. The extension simplifies the prototyping of parts that are precisely nested on the work plane.

Original SVG to new SVG
* The extension reads original nested version and tries to apply same coordination to opened objects.

SVG to YAML with coordinates
* The extension reads the coordinates of the currently open file and saves them in a YAML file in the format "Object name"->"Coordinates".

YAML with coordinates to SVG
* The opposite variant to the previous option. Extension opens a YAML file with coordinates and tries to apply them to the open file according to the object name.
</label>
</page>
</param>
Expand Down
10 changes: 10 additions & 0 deletions InkSvgNest/inkSvgNest.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def svg_to_yaml(self, yaml_file: str):
for el in self.svg.getiterator():
if "transform" in el.attrib:
data[el.attrib["id"]] = [el.attrib["transform"]][0]

if not data:
self.raise_error("Nothing to save")

self.yaml_write(data, yaml_file)

Expand All @@ -91,6 +94,9 @@ def yaml_to_svg(self, yaml_file):
data = {}
self.yaml_read(data, yaml_file)

if not data:
self.raise_error("YAML file is empty. Nothing to move.")

for el in self.svg.getiterator():
if "id" in el.attrib:
if el.attrib["id"] in data:
Expand All @@ -104,6 +110,10 @@ def svg_to_svg(self, svg_file_nested):
if "transform" in el.attrib:
data[el.attrib["id"]] = [el.attrib["transform"]][0]

if not data:
self.raise_error("SVG file is empty. Nothing to move.")


for el in self.svg.getiterator():
if "id" in el.attrib:
if el.attrib["id"] in data:
Expand Down

0 comments on commit 4b9104a

Please sign in to comment.