mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-22 21:59:37 +08:00
Properly serialise all settings to g-code file
This makes for ugly g-code files, true, but at least the functionality of saving settings is useful now: It's traceable. Could've implemented this somewhere else too, but this is fine for now. Contributes to issue CURA-1278.
This commit is contained in:
parent
8b5c4b0361
commit
d602c0754f
@ -4,6 +4,7 @@
|
|||||||
from UM.Mesh.MeshWriter import MeshWriter
|
from UM.Mesh.MeshWriter import MeshWriter
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
from UM.Settings.InstanceContainer import InstanceContainer #To create a complete setting profile to store in the g-code.
|
||||||
import re #For escaping characters in the settings.
|
import re #For escaping characters in the settings.
|
||||||
|
|
||||||
## Writes g-code to a file.
|
## Writes g-code to a file.
|
||||||
@ -67,8 +68,11 @@ class GCodeWriter(MeshWriter):
|
|||||||
prefix = ";SETTING_" + str(GCodeWriter.version) + " " # The prefix to put before each line.
|
prefix = ";SETTING_" + str(GCodeWriter.version) + " " # The prefix to put before each line.
|
||||||
prefix_length = len(prefix)
|
prefix_length = len(prefix)
|
||||||
|
|
||||||
#TODO: This just serialises the container stack, which only indicates the IDs of the containers in that stack, not the settings themselves, making this about 9001x as useless as the fax functionality in Adobe Acrobat.
|
all_settings = InstanceContainer("G-code-imported-profile") #Create a new 'profile' with ALL settings so that the slice can be precisely reproduced.
|
||||||
serialised = settings.serialize()
|
all_settings.setDefinition(settings.getBottom())
|
||||||
|
for key in settings.getAllKeys():
|
||||||
|
all_settings.setProperty(key, "value", settings.getProperty(key, "value")) #Just copy everything over to the setting instance.
|
||||||
|
serialised = all_settings.serialize()
|
||||||
|
|
||||||
# Escape characters that have a special meaning in g-code comments.
|
# Escape characters that have a special meaning in g-code comments.
|
||||||
pattern = re.compile("|".join(GCodeWriter.escape_characters.keys()))
|
pattern = re.compile("|".join(GCodeWriter.escape_characters.keys()))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user