mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-24 11:21:14 -07:00
Merge branch 'feature_ufp_reader' of github.com:Ultimaker/Cura
This commit is contained in:
commit
3f02ad7619
5 changed files with 186 additions and 97 deletions
|
|
@ -12,9 +12,6 @@ catalog = i18nCatalog("cura")
|
|||
from . import MarlinFlavorParser, RepRapFlavorParser
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Class for loading and parsing G-code files
|
||||
class GCodeReader(MeshReader):
|
||||
_flavor_default = "Marlin"
|
||||
|
|
|
|||
41
plugins/UFPReader/UFPReader.py
Normal file
41
plugins/UFPReader/UFPReader.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from typing import cast
|
||||
|
||||
from Charon.VirtualFile import VirtualFile
|
||||
|
||||
from UM.Mesh.MeshReader import MeshReader
|
||||
from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
|
||||
from UM.PluginRegistry import PluginRegistry
|
||||
from cura.Scene.CuraSceneNode import CuraSceneNode
|
||||
from plugins.GCodeReader.GCodeReader import GCodeReader
|
||||
|
||||
|
||||
class UFPReader(MeshReader):
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
MimeTypeDatabase.addMimeType(
|
||||
MimeType(
|
||||
name = "application/x-ufp",
|
||||
comment = "Cura UFP File",
|
||||
suffixes = ["ufp"]
|
||||
)
|
||||
)
|
||||
self._supported_extensions = [".ufp"]
|
||||
|
||||
def _read(self, file_name: str) -> CuraSceneNode:
|
||||
# Open the file
|
||||
archive = VirtualFile()
|
||||
archive.open(file_name)
|
||||
# Get the gcode data from the file
|
||||
gcode_data = archive.getData("/3D/model.gcode")
|
||||
# Convert the bytes stream to string
|
||||
gcode_stream = gcode_data["/3D/model.gcode"].decode("utf-8")
|
||||
|
||||
# Open the GCodeReader to parse the data
|
||||
gcode_reader = cast(GCodeReader, PluginRegistry.getInstance().getPluginObject("GCodeReader"))
|
||||
gcode_reader.preReadFromStream(gcode_stream)
|
||||
return gcode_reader.readFromStream(gcode_stream)
|
||||
26
plugins/UFPReader/__init__.py
Normal file
26
plugins/UFPReader/__init__.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#Copyright (c) 2019 Ultimaker B.V.
|
||||
#Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
|
||||
from . import UFPReader
|
||||
|
||||
i18n_catalog = i18nCatalog("cura")
|
||||
|
||||
|
||||
def getMetaData():
|
||||
return {
|
||||
"mesh_reader": [
|
||||
{
|
||||
"mime_type": "application/x-ufp",
|
||||
"extension": "ufp",
|
||||
"description": i18n_catalog.i18nc("@item:inlistbox", "Ultimaker Format Package")
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def register(app):
|
||||
app.addNonSliceableExtension(".ufp")
|
||||
return {"mesh_reader": UFPReader.UFPReader()}
|
||||
|
||||
8
plugins/UFPReader/plugin.json
Normal file
8
plugins/UFPReader/plugin.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "UFP Reader",
|
||||
"author": "Ultimaker B.V.",
|
||||
"version": "1.0.0",
|
||||
"description": "Provides support for reading Ultimaker Format Packages.",
|
||||
"supported_sdk_versions": ["6.0.0"],
|
||||
"i18n-catalog": "cura"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue