Модуль генерации PDDL подключен к верстаку
This commit is contained in:
parent
19b8eeb441
commit
8971bb13df
7 changed files with 324 additions and 308 deletions
|
@ -108,83 +108,80 @@ def run_BoM_list():
|
|||
sortedParts = uniquePartsSort(labelParts)
|
||||
countedParts = countForUniques(sortedParts)
|
||||
fillInBoMList(sheet, countedParts)
|
||||
<<<<<<< HEAD
|
||||
|
||||
|
||||
def printETACounter(partLabel):
|
||||
# def printETACounter(partLabel):
|
||||
|
||||
|
||||
|
||||
|
||||
import os
|
||||
import requests
|
||||
import time
|
||||
# import os
|
||||
# import requests
|
||||
# import time
|
||||
|
||||
import FreeCAD
|
||||
from FreeCAD import Base
|
||||
# import FreeCAD
|
||||
# from FreeCAD import Base
|
||||
|
||||
def export_to_stl(doc, filename):
|
||||
mesh = doc.getObjectsByType("Mesh")[0]
|
||||
mesh.exportStl(filename)
|
||||
# def export_to_stl(doc, filename):
|
||||
# mesh = doc.getObjectsByType("Mesh")[0]
|
||||
# mesh.exportStl(filename)
|
||||
|
||||
def upload_to_octoprint(file_path, api_key, octoprint_url):
|
||||
headers = {
|
||||
"X-Api-Key": api_key
|
||||
}
|
||||
files = {
|
||||
"file": open(file_path, "rb")
|
||||
}
|
||||
response = requests.post(octoprint_url + "/api/files/local", headers=headers, files=files)
|
||||
if response.status_code == 201:
|
||||
print("Файл успешно загружен в OctoPrint.")
|
||||
return response.json()["name"]
|
||||
else:
|
||||
print("Ошибка при загрузке файла в OctoPrint:", response.text)
|
||||
return None
|
||||
# def upload_to_octoprint(file_path, api_key, octoprint_url):
|
||||
# headers = {
|
||||
# "X-Api-Key": api_key
|
||||
# }
|
||||
# files = {
|
||||
# "file": open(file_path, "rb")
|
||||
# }
|
||||
# response = requests.post(octoprint_url + "/api/files/local", headers=headers, files=files)
|
||||
# if response.status_code == 201:
|
||||
# print("Файл успешно загружен в OctoPrint.")
|
||||
# return response.json()["name"]
|
||||
# else:
|
||||
# print("Ошибка при загрузке файла в OctoPrint:", response.text)
|
||||
# return None
|
||||
|
||||
def get_print_duration(file_name, api_key, octoprint_url):
|
||||
headers = {
|
||||
"X-Api-Key": api_key
|
||||
}
|
||||
response = requests.get(octoprint_url + "/api/files/local/" + file_name, headers=headers)
|
||||
if response.status_code == 200:
|
||||
return response.json()["gcodeAnalysis"]["estimatedPrintTime"]
|
||||
else:
|
||||
print("Ошибка при получении информации о файле из OctoPrint:", response.text)
|
||||
return None
|
||||
# def get_print_duration(file_name, api_key, octoprint_url):
|
||||
# headers = {
|
||||
# "X-Api-Key": api_key
|
||||
# }
|
||||
# response = requests.get(octoprint_url + "/api/files/local/" + file_name, headers=headers)
|
||||
# if response.status_code == 200:
|
||||
# return response.json()["gcodeAnalysis"]["estimatedPrintTime"]
|
||||
# else:
|
||||
# print("Ошибка при получении информации о файле из OctoPrint:", response.text)
|
||||
# return None
|
||||
|
||||
# Путь к документу FreeCAD
|
||||
doc_path = "/path/to/your/file.FCStd"
|
||||
# # Путь к документу FreeCAD
|
||||
# doc_path = "/path/to/your/file.FCStd"
|
||||
|
||||
# Путь для сохранения STL-файла
|
||||
stl_path = "/path/to/your/output.stl"
|
||||
# # Путь для сохранения STL-файла
|
||||
# stl_path = "/path/to/your/output.stl"
|
||||
|
||||
# Настройки OctoPrint
|
||||
octoprint_api_key = "your_octoprint_api_key"
|
||||
octoprint_url = "http://localhost:5000"
|
||||
# # Настройки OctoPrint
|
||||
# octoprint_api_key = "your_octoprint_api_key"
|
||||
# octoprint_url = "http://localhost:5000"
|
||||
|
||||
# Открываем документ FreeCAD
|
||||
doc = FreeCAD.open(doc_path)
|
||||
# # Открываем документ FreeCAD
|
||||
# doc = FreeCAD.open(doc_path)
|
||||
|
||||
# Экспортируем модель в STL-файл
|
||||
export_to_stl(doc, stl_path)
|
||||
print("STL-файл успешно создан.")
|
||||
# # Экспортируем модель в STL-файл
|
||||
# export_to_stl(doc, stl_path)
|
||||
# print("STL-файл успешно создан.")
|
||||
|
||||
# Загружаем STL-файл в OctoPrint
|
||||
uploaded_file_name = upload_to_octoprint(stl_path, octoprint_api_key, octoprint_url)
|
||||
if uploaded_file_name is not None:
|
||||
# Получаем информацию о длительности печати
|
||||
print_duration = get_print_duration(uploaded_file_name, octoprint_api_key, octoprint_url)
|
||||
if print_duration is not None:
|
||||
print("Оценочная длительность печати: {} секунд.".format(print_duration))
|
||||
else:
|
||||
print("Не удалось получить информацию о длительности печати.")
|
||||
else:
|
||||
print("Загрузка файла в OctoPrint не удалась.")
|
||||
# # Загружаем STL-файл в OctoPrint
|
||||
# uploaded_file_name = upload_to_octoprint(stl_path, octoprint_api_key, octoprint_url)
|
||||
# if uploaded_file_name is not None:
|
||||
# # Получаем информацию о длительности печати
|
||||
# print_duration = get_print_duration(uploaded_file_name, octoprint_api_key, octoprint_url)
|
||||
# if print_duration is not None:
|
||||
# print("Оценочная длительность печати: {} секунд.".format(print_duration))
|
||||
# else:
|
||||
# print("Не удалось получить информацию о длительности печати.")
|
||||
# else:
|
||||
# print("Загрузка файла в OctoPrint не удалась.")
|
||||
|
||||
# Закрываем документ FreeCAD
|
||||
FreeCAD.closeDocument(doc)
|
||||
# # Закрываем документ FreeCAD
|
||||
# FreeCAD.closeDocument(doc)
|
||||
|
||||
|
||||
=======
|
||||
>>>>>>> 839ce36c70e0a48d82c32c5b6fe17c5634c8ee07
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue