You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be possible to code a version of uv3dp as a library so it would be feasible to access from other languanges and build an entire ctb file from scratch by loading it with the header, preview, layer header, raw voxel data, etc.
Much as I prefer languages like Go and C, I'd like to be able to slice and export files directly from Blender or FreeCAD to improve the flexibilty of individual layer control. However the scripting for these are both in Python.
Obviously it would be possible to recode into Python, but then you lose all the multithreading and speed of Go, so it would be a significant step backward.
On the Python side a library would then make it easy to create and send data eg
import ctypes
uv3dp = ctypes.WinDLL('uv3dp.dll')
uv3dp.SetPrinter("sonic-mini-4k")
uv3dp.SetResin("3D-Okay | Black") # eg loaded from http://bit.ly/2TCLYpJ
uv3dp.SetPreview = previewImage # (as a plain array or if easier for uv3dp as a more standard image format)
uv3dp.ClearLayers()
layerHeader = uv3dp.layerHeader()
layerData = uv3dp.encodeLayer(slice[n])
uv3dp.AddLayer(layerHeader, layerData)
uv3dp.Save("myModel.ctb")
In Python you can also store binary data using the array module or even pack formated binary data using the struct module (not the same as other languanges' structs) and potentially classes something like the following - although that would probably be overkill as uv3dp is already doing the majority of the heavy lifting required for a really useful library.
from __future__ import annotations # needed for type annotations until they become standard in Python 3.10
import struct # packs data in binary format. typedefs are listed in: https://docs.python.org/3/library/struct.html
from dataclasses import dataclass
import array # Packed binary storage of homogeneous data (eg byte array of previews and layers)
@dataclass
class ctbLayerInfo:
Z : float # float32
Exposure : uv3dpExposure
Rle : bytes # []byte
Hash : int # uint64
BitsOn : int # uint
packed : struct
def pack(self):
expP = Exposure.pack()
packed.format = "f" + expP.size() + "s" + len(rle) + "sQI"
packed.pack(
ctbLayerInfo ["Z"],
expP,
rleP,
ctbLayerInfo ["Hash"],
ctbLayerInfo ["BitsOn"]
)
return packed
def size(self):
return packed.size()
The text was updated successfully, but these errors were encountered:
UVtools is all built as a library, but require a C# project, you can import the UVtools.Core.dll
There's also the IronPython but i don't know how it works...
Also it's possible to call a C# script from python but ugly
If you only require ctb format, i have seen some projects in python that you can use to have the file generation
For quick stuff and dependency free a light library like uv3dp can make more sense to you
Would it be possible to code a version of uv3dp as a library so it would be feasible to access from other languanges and build an entire ctb file from scratch by loading it with the header, preview, layer header, raw voxel data, etc.
Much as I prefer languages like Go and C, I'd like to be able to slice and export files directly from Blender or FreeCAD to improve the flexibilty of individual layer control. However the scripting for these are both in Python.
Obviously it would be possible to recode into Python, but then you lose all the multithreading and speed of Go, so it would be a significant step backward.
On the Python side a library would then make it easy to create and send data eg
In Python you can also store binary data using the array module or even pack formated binary data using the struct module (not the same as other languanges' structs) and potentially classes something like the following - although that would probably be overkill as uv3dp is already doing the majority of the heavy lifting required for a really useful library.
The text was updated successfully, but these errors were encountered: