Open dgm3333 opened 3 years ago
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
Full Example:
var slicerFile = new ChituboxFile();
slicerFile.BottomLayerCount = BottomLayerCount;
slicerFile.LayerHeight = LayerHeight;
slicerFile.ResolutionX = ResolutionX;
slicerFile.ResolutionY = ResolutionY;
slicerFile.DisplayWidth = DisplayWidth;
slicerFile.DisplayHeight = DisplayHeight;
slicerFile.MachineZ = MachineZ;
slicerFile.MirrorDisplay = MirrorDisplay;
slicerFile.BottomExposureTime = BottomExposureTime;
slicerFile.ExposureTime = ExposureTime;
slicerFile.BottomLiftHeight = BottomLiftHeight;
slicerFile.LiftHeight = LiftHeight;
slicerFile.BottomLiftSpeed = BottomLiftSpeed;
slicerFile.LiftSpeed = LiftSpeed;
slicerFile.RetractSpeed = RetractSpeed;
slicerFile.BottomLightOffDelay = BottomLightOffDelay;
slicerFile.LightOffDelay = LightOffDelay;
slicerFile.BottomLightPWM = BottomLightPWM;
slicerFile.LightPWM = LightPWM;
slicerFile.MachineName = MachineName;
slicerFile.MaterialName = MaterialName;
slicerFile.MaterialMilliliters = MaterialMilliliters;
slicerFile.MaterialGrams = MaterialGrams;
slicerFile.MaterialCost = MaterialCost;
slicerFile.SetThumbnails(Thumbnails);
slicerFile.LayerManager.Layers = Layers;
slicerFile.Encode("filepath.ctb");
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.