added convert to path
This commit is contained in:
parent
fa9bcb6afc
commit
970ab2ff72
|
@ -9,7 +9,7 @@ class ExportAndRunScript(inkex.EffectExtension):
|
||||||
def effect(self):
|
def effect(self):
|
||||||
# Define the export file path
|
# Define the export file path
|
||||||
png_file_path = "/home/devdesk/yair/thermatext/labels/exported.png"
|
png_file_path = "/home/devdesk/yair/thermatext/labels/exported.png"
|
||||||
|
|
||||||
# Get the current selection
|
# Get the current selection
|
||||||
selection = self.svg.selected
|
selection = self.svg.selected
|
||||||
|
|
||||||
|
@ -21,12 +21,27 @@ class ExportAndRunScript(inkex.EffectExtension):
|
||||||
# Get the IDs of the selected elements
|
# Get the IDs of the selected elements
|
||||||
selected_ids = ",".join(element.get('id') for element in selection.values())
|
selected_ids = ",".join(element.get('id') for element in selection.values())
|
||||||
|
|
||||||
|
# Convert objects to paths
|
||||||
|
self.convert_to_path(selected_ids)
|
||||||
|
|
||||||
# Run the Inkscape CLI command to export the selection to a PNG
|
# Run the Inkscape CLI command to export the selection to a PNG
|
||||||
self.run_export_command(selected_ids, png_file_path)
|
self.run_export_command(selected_ids, png_file_path)
|
||||||
|
|
||||||
# Run the bash script on the exported PNG
|
# Run the bash script on the exported PNG
|
||||||
self.run_script_on_png(png_file_path)
|
self.run_script_on_png(png_file_path)
|
||||||
|
|
||||||
|
def convert_to_path(self, selected_ids):
|
||||||
|
# Create a command that calls Inkscape's command line interface to convert objects to paths
|
||||||
|
command = [
|
||||||
|
"inkscape",
|
||||||
|
"--select={}".format(selected_ids),
|
||||||
|
"--verb=ObjectToPath",
|
||||||
|
self.options.input_file
|
||||||
|
]
|
||||||
|
|
||||||
|
# Run the command
|
||||||
|
subprocess.check_call(command)
|
||||||
|
|
||||||
def run_export_command(self, selected_ids, png_file_path):
|
def run_export_command(self, selected_ids, png_file_path):
|
||||||
# Create a command that calls Inkscape's command line interface to export the selection to a PNG
|
# Create a command that calls Inkscape's command line interface to export the selection to a PNG
|
||||||
command = [
|
command = [
|
||||||
|
@ -36,19 +51,19 @@ class ExportAndRunScript(inkex.EffectExtension):
|
||||||
"--export-filename={}".format(png_file_path),
|
"--export-filename={}".format(png_file_path),
|
||||||
self.options.input_file
|
self.options.input_file
|
||||||
]
|
]
|
||||||
|
|
||||||
# Run the command
|
# Run the command
|
||||||
subprocess.check_call(command)
|
subprocess.check_call(command)
|
||||||
|
|
||||||
def run_script_on_png(self, png_file_path):
|
def run_script_on_png(self, png_file_path):
|
||||||
# Define the path to your bash script
|
# Define the path to your bash script
|
||||||
# bash_script_path = "print.sh"
|
# bash_script_path = "print.sh"
|
||||||
|
|
||||||
# Create a command that calls the bash script with the PNG as an argument
|
# Create a command that calls the bash script with the PNG as an argument
|
||||||
command = ["sudo", "brother_ql", "-b", "pyusb", "--model", "QL-570", "-p", "usb://0x04f9:0x2028/000M6Z401370", "print", "-l", "62", png_file_path]
|
command = ["sudo", "brother_ql", "-b", "pyusb", "--model", "QL-570", "-p", "usb://0x04f9:0x2028/000M6Z401370", "print", "-l", "62", png_file_path]
|
||||||
|
|
||||||
# Run the command
|
# Run the command
|
||||||
subprocess.check_call(command)
|
subprocess.check_call(command)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
ExportAndRunScript().run()
|
ExportAndRunScript().run()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user