mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-08 17:42:31 +02:00
Python docs
This commit is contained in:
+1
-1
@@ -359,4 +359,4 @@ MigrationBackup/
|
||||
|
||||
build/secret/
|
||||
manifests/
|
||||
|
||||
.idea/
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# UVtools Python Scripting
|
||||
|
||||

|
||||
|
||||
## Requirements
|
||||
|
||||
- [Python 3.x](https://www.python.org/downloads)
|
||||
- [Pythonnet 3.x](https://github.com/pythonnet/pythonnet)
|
||||
- `pip install git+https://github.com/pythonnet/pythonnet`
|
||||
- [.NET 6.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
|
||||
- [UVtools](https://github.com/sn4k3/UVtools/releases/latest):
|
||||
- Windows: Must install MSI
|
||||
- Linux and macOS: Need to register `UVTOOLS_PATH` (Environment Variable)
|
||||
- Near your .py script:
|
||||
- [UVtoolsBootstrap.py](https://github.com/sn4k3/UVtools/blob/master/Scripts/UVtools.Python/UVtoolsBootstrap.py)
|
||||
`wget https://github.com/sn4k3/UVtools/blob/master/Scripts/UVtools.Python/UVtoolsBootstrap.py`
|
||||
- [UVtools.runtimeconfig.json](https://github.com/sn4k3/UVtools/blob/master/Scripts/UVtools.Python/UVtools.runtimeconfig.json)
|
||||
`wget https://github.com/sn4k3/UVtools/blob/master/Scripts/UVtools.Python/UVtools.runtimeconfig.json`
|
||||
|
||||
## Bootstrap
|
||||
|
||||
```python
|
||||
#!/usr/bin/env python
|
||||
"""print_layers.py: Print all layers from a file."""
|
||||
__author__ = "Someone"
|
||||
__copyright__ = "Copyright 2022, Planet Earth"
|
||||
from UVToolsBootstrap import *
|
||||
|
||||
# Your code here
|
||||
```
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
- Must explore [UVtools.Core](https://github.com/sn4k3/UVtools/tree/master/UVtools.Core) code, functions and arguments
|
||||
are the same as source.
|
||||
- See [code samples](https://github.com/sn4k3/UVtools/tree/master/Scripts/UVtools.Python)
|
||||
|
||||
## Support
|
||||
https://github.com/sn4k3/UVtools/discussions/categories/scripts
|
||||
|
||||
## Contribute with your scripts
|
||||
If you make a usefull script and want to contribute you can share and publish your script under
|
||||
[Github - Discussions - Scripts](https://github.com/sn4k3/UVtools/discussions/categories/scripts).
|
||||
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
"""
|
||||
from clr_loader import get_coreclr
|
||||
from pythonnet import set_runtime
|
||||
import sys
|
||||
import platform
|
||||
import os
|
||||
|
||||
UVTOOLS_PATH = None
|
||||
if platform.system() == 'Windows':
|
||||
try:
|
||||
import winreg
|
||||
|
||||
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r'Software\UVtools', 0, winreg.KEY_READ)
|
||||
UVTOOLS_PATH = winreg.QueryValueEx(key, 'InstallDir')[0]
|
||||
if key:
|
||||
winreg.CloseKey(key)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
UVTOOLS_PATH = os.getenv('UVTOOLS_PATH')
|
||||
|
||||
if UVTOOLS_PATH is None or not os.path.exists(UVTOOLS_PATH):
|
||||
print("Unable to find UVtools path, please install and register the path with a Environment Variable (UVTOOLS_PATH)")
|
||||
exit(-1)
|
||||
|
||||
# Don't touch
|
||||
# Set runtime
|
||||
sys.path.append(UVTOOLS_PATH)
|
||||
rt = get_coreclr(r"UVtools.runtimeconfig.json")
|
||||
set_runtime(rt)
|
||||
import clr
|
||||
|
||||
clr.AddReference(r"UVtools.Core")
|
||||
from UVtools.Core import *
|
||||
from UVtools.Core.EmguCV import *
|
||||
from UVtools.Core.Extensions import *
|
||||
from UVtools.Core.FileFormats import *
|
||||
from UVtools.Core.GCode import *
|
||||
from UVtools.Core.Layers import *
|
||||
from UVtools.Core.Managers import *
|
||||
from UVtools.Core.MeshFormats import *
|
||||
from UVtools.Core.Network import *
|
||||
from UVtools.Core.Objects import *
|
||||
from UVtools.Core.Operations import *
|
||||
from UVtools.Core.PixelEditor import *
|
||||
from UVtools.Core.Printer import *
|
||||
from UVtools.Core.Scripting import *
|
||||
from UVtools.Core.Suggestions import *
|
||||
from UVtools.Core.SystemOS import *
|
||||
|
||||
print(f'{About.SoftwareWithVersionArch}')
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net6.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "6.0.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python
|
||||
"""print_layers.py: Print all layers from a file."""
|
||||
__author__ = "Someone"
|
||||
__copyright__ = "Copyright 2022, Planet Earth"
|
||||
from UVToolsBootstrap import *
|
||||
|
||||
file = input('Input the file path: ')
|
||||
|
||||
slicerFile = None
|
||||
try:
|
||||
slicerFile = FileFormat.Open(file)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
exit(-1)
|
||||
|
||||
if slicerFile is None:
|
||||
print(f'Unable to find {file} or it\'s invalid file')
|
||||
exit(-1)
|
||||
|
||||
for layer in slicerFile:
|
||||
print(layer)
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
Reference in New Issue
Block a user