Giter Site home page Giter Site logo

willmac16 / octoprint-translatemodel Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 1.0 1.61 MB

An OctoPrint plugin to move models around without re-slicing

Home Page: https://plugins.octoprint.org/plugins/translatemodel/

License: GNU Affero General Public License v3.0

Python 26.96% C++ 41.87% JavaScript 18.94% Jinja 12.23%

octoprint-translatemodel's Introduction

OctoPrint-TranslateModel

Translate Model allows you to move models around in gcode files without reslicing.

Features

  • Select files via the translate button in the file pane
  • Quick and easy model movement along the x and y axes
  • Options to automatically print files after translation

translateActionButton

translateTab

viewerGraphic

Setup

Install via the bundled Plugin Manager or manually using this URL:

https://github.com/Willmac16/OctoPrint-TranslateModel/archive/main.zip
  • This plugin will compile its C++ code on install, but this should be pretty quick.

Credits

  • Thanks to KenLucke for the plugin suggestion and testing help.
  • Thanks to AlexDashwood for the fix for a conflict with ContinuousPrint
  • Thanks to ScottWell1 for adding support for Prusa's M555 command

octoprint-translatemodel's People

Contributors

alexdashwood avatar scottwell1 avatar willmac16 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

scottwell1

octoprint-translatemodel's Issues

Fails to install on Windows 10 OctoPrint instance

I am running an OctoPrint instance on a Windows 10 computer with Python 3.10.1. I have the appropriate C++ build tools as recommended in step 2 of this Windows installation guide.

When I install this plugin with the OctoPrint plugin manager, the file translate.cpp fails to compile. This is based on this excerpt from the output shown in the "Installing plugin..." dialog.

Running setup.py install for OctoPrint-TranslateModel: started
ERROR: Command errored out with exit status 1:
command: 'C:\Program Files\OctoPrint\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Windows\\Temp\\pip-req-build-1_33esbh\\setup.py'"'"'; __file__='"'"'C:\\Windows\\Temp\\pip-req-build-1_33esbh\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Windows\Temp\pip-record-r5kzp4t6\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Program Files\OctoPrint\venv\include\site\python3.10\OctoPrint-TranslateModel'
cwd: C:\Windows\Temp\pip-req-build-1_33esbh\
Complete output (45 lines):
Found packages: {'octoprint_translatemodel'}
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.10
creating build\lib.win-amd64-3.10\octoprint_translatemodel
copying octoprint_translatemodel\__init__.py -> build\lib.win-amd64-3.10\octoprint_translatemodel
running egg_info
creating OctoPrint_TranslateModel.egg-info
writing OctoPrint_TranslateModel.egg-info\PKG-INFO
writing dependency_links to OctoPrint_TranslateModel.egg-info\dependency_links.txt
writing entry points to OctoPrint_TranslateModel.egg-info\entry_points.txt
writing requirements to OctoPrint_TranslateModel.egg-info\requires.txt
writing top-level names to OctoPrint_TranslateModel.egg-info\top_level.txt
writing manifest file 'OctoPrint_TranslateModel.egg-info\SOURCES.txt'
reading manifest file 'OctoPrint_TranslateModel.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*' under directory 'octoprint_translatemodel\translations'
adding license file 'LICENSE'
writing manifest file 'OctoPrint_TranslateModel.egg-info\SOURCES.txt'
creating build\lib.win-amd64-3.10\octoprint_translatemodel\src
copying octoprint_translatemodel\src\translate.cpp -> build\lib.win-amd64-3.10\octoprint_translatemodel\src
creating build\lib.win-amd64-3.10\octoprint_translatemodel\static
creating build\lib.win-amd64-3.10\octoprint_translatemodel\static\js
copying octoprint_translatemodel\static\js\translatemodel.js -> build\lib.win-amd64-3.10\octoprint_translatemodel\static\js
creating build\lib.win-amd64-3.10\octoprint_translatemodel\templates
copying octoprint_translatemodel\templates\translatemodel_settings.jinja2 -> build\lib.win-amd64-3.10\octoprint_translatemodel\templates
running build_ext
building 'translate' extension
creating build\temp.win-amd64-3.10
creating build\temp.win-amd64-3.10\Release
creating build\temp.win-amd64-3.10\Release\octoprint_translatemodel
creating build\temp.win-amd64-3.10\Release\octoprint_translatemodel\src
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Program Files\OctoPrint\venv\include -IC:\Program Files\Python310\include -IC:\Program Files\Python310\Include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpoctoprint_translatemodel/src/translate.cpp /Fobuild\temp.win-amd64-3.10\Release\octoprint_translatemodel/src/translate.obj
translate.cpp
octoprint_translatemodel/src/translate.cpp(136): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data
octoprint_translatemodel/src/translate.cpp(142): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data
octoprint_translatemodel/src/translate.cpp(435): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data
octoprint_translatemodel/src/translate.cpp(435): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'const int', possible loss of data
octoprint_translatemodel/src/translate.cpp(436): error C2131: expression did not evaluate to a constant
octoprint_translatemodel/src/translate.cpp(436): note: failure was caused by a read of a variable outside its lifetime
octoprint_translatemodel/src/translate.cpp(436): note: see usage of 'numShifts'
octoprint_translatemodel/src/translate.cpp(446): error C3863: array type 'double [numShifts][2]' is not assignable
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Program Files\OctoPrint\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Windows\\Temp\\pip-req-build-1_33esbh\\setup.py'"'"'; __file__='"'"'C:\\Windows\\Temp\\pip-req-build-1_33esbh\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Windows\Temp\pip-record-r5kzp4t6\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Program Files\OctoPrint\venv\include\site\python3.10\OctoPrint-TranslateModel' Check the logs for full command output.
Running setup.py install for OctoPrint-TranslateModel: finished with status 'error'
Error!
Could not parse output from pip, see plugin_pluginmanager_console.log for generated output

Full output from the dialog should be attached. I can't really show you my full plugin_pluginmanager_console.log since it seems to be just the same errors repeated and the output of some sanity checks I tried to do (like uninstalling my C++ build tools and seeing the installer complain about it, which makes sense).

output.txt

Windows installations of OctoPrint are usually more problematic, so I tried installing other plugins to check if it was an issue with my setup. Installing other plugins worked fine. I also looked around the plugin repository for projects that use C++, and installing the ones I could find worked fine. Eventually I deleted OctoPrint's venv files and reinstalled it using pip and venv using the instructions in the Windows installation guide mentioned above. This plugin still would still give the same error when installed, and other plugins continued to install fine. Based on this I'm fairly sure this is a plugin-specific issue.

I also discovered early on that I was using the 2022 C++ build tools instead of the 2019 build tools suggested by the Windows installation tutorial. Downgrading did not solve the error. The error shown when the 2022 build tools were installed was identical to the error shown above, but a different cl.exe. Is there a very specific compiler I should be using, and how would I tell the installer to use it? Would I have to fork this repository and mess with the build config somehow so I could install it properly on my own? (I haven't done that yet since I don't even know how to create a basic dev enviroment for OctoPrint plugins)

Thanks for reading, and sorry if this was the wrong place to post this.

Won't Install on Python 2

Hello,

Thank you for your plugin. While installing from the repository or directly from the zip, it shows an error.
Config:
env.plugins.pi_support.model: Raspberry Pi 3 Model B Plus Rev 1.3
env.python.pip: 20.2
env.python.version: 2.7.16
env.python.virtualenv: true
octoprint.version: 1.5.3

Log:
2021-03-02 11:45:32,490 - octoprint.plugins.pluginmanager - INFO - Installing plugin from https://github.com/Willmac16/OctoPrint-TranslateModel/archive/main.zip
2021-03-02 11:45:32,970 - octoprint.plugin.core - INFO - Plugin Anonymous Usage Tracking is disabled.
2021-03-02 11:45:54,643 - octoprint.plugins.pluginmanager - ERROR - Could not install plugin from https://github.com/Willmac16/OctoPrint-TranslateModel/archive/main.zip
Traceback (most recent call last):
File "/home/pi/octoprint/OctoPrint/lib/python2.7/site-packages/octoprint/plugins/pluginmanager/init.py", line 738, in _command_install_archive
returncode, stdout, stderr = self._call_pip(pip_args)
File "/home/pi/octoprint/OctoPrint/lib/python2.7/site-packages/octoprint/plugins/pluginmanager/init.py", line 1414, in _call_pip
return self._pip_caller.execute(*args, **kwargs)
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/pip.py", line 209, in execute
return self.call(command, **kwargs)
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/commandline.py", line 243, in call
all_stderr += process_stderr(p.stderr.readlines(timeout=0.5))
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/commandline.py", line 239, in process_stderr
return process_lines(lines, self._log_stderr)
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/commandline.py", line 230, in process_lines
*map(lambda x: to_unicode(x, errors="replace"), lines)
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/pip.py", line 511, in _preprocess_lines
return list(map(self._preprocess, lines))
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/pip.py", line 530, in _preprocess
return to_unicode(clean_ansi(text))
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/commandline.py", line 57, in clean_ansi
return _ANSI_REGEX.sub(b"", line.encode("latin1")).decode("latin1")
UnicodeEncodeError: 'latin-1' codec can't encode character u'\u2018' in position 40: ordinal not in range(256)
2021-03-02 11:45:54,644 - octoprint.plugins.pluginmanager - ERROR - Reason: UnicodeEncodeError('latin-1', u' cc1plus: warning: command line option \u2018-Wstrict-prototypes\u2019 is valid for C/ObjC but not for C++\n', 40, 41, 'ordinal not in range(256)')
Traceback (most recent call last):
File "/home/pi/octoprint/OctoPrint/lib/python2.7/site-packages/octoprint/plugins/pluginmanager/init.py", line 738, in _command_install_archive
returncode, stdout, stderr = self._call_pip(pip_args)
File "/home/pi/octoprint/OctoPrint/lib/python2.7/site-packages/octoprint/plugins/pluginmanager/init.py", line 1414, in _call_pip
return self._pip_caller.execute(*args, **kwargs)
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/pip.py", line 209, in execute
return self.call(command, **kwargs)
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/commandline.py", line 243, in call
all_stderr += process_stderr(p.stderr.readlines(timeout=0.5))
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/commandline.py", line 239, in process_stderr
return process_lines(lines, self._log_stderr)
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/commandline.py", line 230, in process_lines
*map(lambda x: to_unicode(x, errors="replace"), lines)
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/pip.py", line 511, in _preprocess_lines
return list(map(self._preprocess, lines))
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/pip.py", line 530, in _preprocess
return to_unicode(clean_ansi(text))
File "/home/pi/octoprint/OctoPrint/local/lib/python2.7/site-packages/octoprint/util/commandline.py", line 57, in clean_ansi
return _ANSI_REGEX.sub(b"", line.encode("latin1")).decode("latin1")
UnicodeEncodeError: 'latin-1' codec can't encode character u'\u2018' in position 40: ordinal not in range(256)

Clicking the translate icon on the translate tab only works once

I have both TranslateModel and Arc-Welder plugins installed and enabled. I did a successful(?) translate and Arc-Welder did its thing automatically. I went to delete the arc-welder file but deleted the translated file as well. Now pressing the translate icon on the translate tab does nothing.

Relative movement at the end of print suppressed

Translated G-code has G91/G90 lines removed, unfortunately this will make the hotend crash on the printed model.
When modifying gcode files created in Cura, this part:

G91 ; Set coordinates to relative
G1 F2400 E-3 ; Retract filament 3mm at 40mm/s to prevent stringing
G0 F5000 Z20 ; Move Z Axis up 20mm to allow filament ooze freely
G90 ; Set coordinates to absolute
G0 X0 Y235 F5000 ; Move Heat Bed to the front for easy print removal

becomes:

G1 F2400 E-3 ; Retract filament 3mm at 40mm/s to prevent stringing
G0 F5000 Z20 ; Move Z Axis up 20mm to allow filament ooze freely

G0 X-10 Y225 F5000 ; Move Heat Bed to the front for easy print removal

Not working for me

I installed the plugin and attempted to use it. My first comment is that it isn't immediately obvious how to run it. Clicking on the icon in the file list doesn't appear to do anything. I was expecting the translate model dialog to pop up but it did not.

I moved to the Translate Model Plugin tab and found the file name, x and y at 0 and with "do nothing" selected. I changed X and Y to 10 and clicked the translate button. This did start the process and generated a new .gcode file. I downloaded the original file and the translated file and compared them. They were identical (i.e. no translation took place).

I thought maybe "do nothing" was exactly that so I went back to the tab and selected "load". Clicking on the translate button does nothing. The process won't run a second time.

My printer is a LulzBot TAZ 6. Since the start gcode includes wiping the nozzle on a pad in a fixed location, I was curious if those commands would get translated which would render the resulting gcode useless.

Below is my system info. Let me know if you want anything else.

browser.user_agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) Gecko/20100101 Firefox/86.0
connectivity.connection_check: 8.8.8.8:53
connectivity.connection_ok: true
connectivity.enabled: true
connectivity.online: true
connectivity.resolution_check: octoprint.org
connectivity.resolution_ok: true
env.hardware.cores: 4
env.hardware.freq: 1200
env.hardware.ram: 915058688
env.os.bits: 32
env.os.id: linux
env.os.platform: linux
env.plugins.pi_support.model: Raspberry Pi 3 Model B Rev 1.2
env.plugins.pi_support.octopi_version: 0.18.0
env.plugins.pi_support.throttle_state: 0x0
env.python.pip: 20.2.4
env.python.version: 3.7.3
env.python.virtualenv: true
octoprint.safe_mode: false
octoprint.version: 1.5.3
printer.firmware: Virtual Marlin 1.0

Need similar plugin, can you maybe help?

Hi, apologies if this is a little cheeky, but I need a similar kind of plugin and I wondered if you could give me some direction or maybe even help (I am a coder, but I have never done an Octoprint plugin before).
I have an IDEX printer and want a plugin that will change all instances of E0 to E1 - such that, if I have a GCode file which is sliced for Extruder 1, instead have it print using Extruder 2 (Because the filament I want is already loaded into extruder 2).
Your plugin already does a lot more complex stuff - I just need to work out what bits I need to change to make it a unique plugin, and where my entry point is. I guess essentially what you are doing is registering some hook - you get passed each line of Gcode and do some string manipulation, then write it out.
If you could give me a leg up, I would really appreciate it.

Unable to install on Python 2

I am running Octoprint on the latest version with everything updated to the latest version on a Pi 3b+. Here is my error:

Installing plugin from https://github.com/Willmac16/OctoPrint-TranslateModel/archive/main.zip... /home/pi/oprint/bin/python2 -m pip --disable-pip-version-check install file:///tmp/tmpmv3f5b/main.zip --no-cache-dir Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Processing /tmp/tmpmv3f5b/main.zip ERROR: Package 'OctoPrint-TranslateModel' requires a different Python: 2.7.13 not in '>=3,<4' Error! Could not parse output from pip, see plugin_pluginmanager_console.log for generated output

Here is the relevant log:

plugin_pluginmanager_console.log.txt

I tried running the installation from cmd, but it failed as well. Here is my error:

pi@octopi:~ $ pip install "https://github.com/Willmac16/OctoPrint-TranslateModel/archive/main.zip" Defaulting to user installation because normal site-packages is not writeable Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting https://github.com/Willmac16/OctoPrint-TranslateModel/archive/main.zip Using cached https://github.com/Willmac16/OctoPrint-TranslateModel/archive/main.zip (25 kB) ERROR: Command errored out with exit status 255: command: /usr/local/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-6basxqjt/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-6basxqjt/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-6lmi0n42 cwd: /tmp/pip-req-build-6basxqjt/ Complete output (1 lines): Could not import OctoPrint's setuptools, are you sure you are running that under the same python installation that OctoPrint is installed under? ---------------------------------------- WARNING: Discarding https://github.com/Willmac16/OctoPrint-TranslateModel/archive/main.zip. Command errored out with exit status 255: python setup.py egg_info Check the logs for full command output. ERROR: Command errored out with exit status 255: python setup.py egg_info Check the logs for full command output.
Hope this helps.

Translate M555 Print Origin

Enhancement Request.

Prusa's current implementation (MK4, XL, and perhaps MINI) uses M555 to tell the firmware what portion of the bed is actually being used for the print. The "G29 P1" bed leveling then probes only the area defined by M555 instead of the entire bed.

Octoprint-TranslateModel does not currently translate that M555 (I assume because it occurs before the start of the first layer). That leads to the bed leveling area and print area being inconsistent after translation.

PrusaSlicer's start Gcode uses placeholders to emit the M555 when slicing:
M555 X{(min(print_bed_max[0], first_layer_print_min[0] + 32) - 32)} Y{(max(0, first_layer_print_min[1]) - 4)} W{((min(print_bed_max[0], max(first_layer_print_min[0] + 32, first_layer_print_max[0])))) - ((min(print_bed_max[0], first_layer_print_min[0] + 32) - 32))} H{((first_layer_print_max[1])) - ((max(0, first_layer_print_min[1]) - 4))}

That results in an embedded Gcode such as:
M555 X76.9202 Y72.6461 W99.2314 H83.4777

Would it be appropriate for Octoprint-TranslateModel to translate the print origin X and Y positions in the M555 command?

PreRelease Discussion

Goals for v0.1.0

  • add threading support, so it is non-blocking
  • handle already translated objects
  • some sort of object copying (possibly with cancel object support)

No button at Files panel. Conflict with Continuousprint plugin.

Hello! I have an issue with the missing TranslateModel button in the Files panel. It's happening on all my instances.
Before writing this issue, I remembered that one of my favorite plugins, Scheduler, had a similar problem. It was related to a conflict between PrintScheduler and the Continuousprint plugin, which was successfully solved by @jneilliii.
original
Since I'm using both of these plugins, I decided to try taking the button code from PrintScheduler and inserting it into TranslateModel (leaving only the "template" code). Everything started working and the button appeared. Inspired by that, I decided to submit a pull request.
I'm not a developer, so I don't know if this code leads to any issues, but it works for me. Also, I'm new to Github, so if make something wrong, please tell me.
modif

TL;DR: If you don't have the button at the Files panel and you're using Continuousprint plugin, you likely have the same issue. If you need to fix it ASAP, you can install modified version using this URL in Plugin Manager just update plugin, it works great.
Upd: thanks for heartwarming response :)

Featurerequest: Bed Visualization

Hi

I like the idea, but still I am using the slicer to move things around. The only reason is that I see where I am going to. It is for me more secure the calculating/visualizing it in my head.
If you could add the print bed vew showing the actual and the translated position as displayed in the readme this would be great.
thx in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.