Project OOP refactorisation.
This commit is contained in:
71
model_gen/utils_system.py
Normal file
71
model_gen/utils_system.py
Normal file
@@ -0,0 +1,71 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Thu Apr 27 16:47:54 2023
|
||||
|
||||
@author: Edward Middleton-Smith
|
||||
|
||||
File Operations OpenSCAD, Cura Engine
|
||||
|
||||
"""
|
||||
|
||||
# CLASSES
|
||||
# ATTRIBUTE DECLARATION
|
||||
# METHODS
|
||||
# FUNCTION
|
||||
# ARGUMENTS
|
||||
# ARGUMENT VALIDATION
|
||||
# ATTRIBUTE + VARIABLE INSTANTIATION
|
||||
# METHODS
|
||||
# RETURNS
|
||||
|
||||
# NORMAL METHODS
|
||||
# FUNCTION
|
||||
# ARGUMENTS
|
||||
# ARGUMENT VALIDATION
|
||||
# VARIABLE INSTANTIATION
|
||||
# METHODS
|
||||
# RETURNS
|
||||
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def render_openscad(path_scad, path_stl, path_cmd = 'C:\\"Program Files"\\openscad\\openscad'): # 'C:\\"Program Files (x86)"\\OpenSCAD\\openscad'
|
||||
# render openscad file and store as file type defined by path_stl
|
||||
cmd = f'{path_cmd} -o "{path_stl}" "{path_scad}"'
|
||||
# METHODS
|
||||
print(os.path.exists(path_scad))
|
||||
exec_oscmd(cmd)
|
||||
|
||||
def exec_oscmd(cmd):
|
||||
# execute os system command
|
||||
# - validation conducted by os system following python execution - NOT SAFE
|
||||
print()
|
||||
print('command')
|
||||
print(cmd)
|
||||
# METHODS
|
||||
# os.system('cd C:\\"Program Files (x86)"\\OpenSCAD\\') # pre-command for openscad commands, alt: os.system('C:\\"Program Files (x86)"\\OpenSCAD\\openscad ...')
|
||||
os.system(cmd)
|
||||
|
||||
def make_openscad(path_scad, path_cmd = 'C:\\"Program Files (x86)"\\OpenSCAD\\openscad'):
|
||||
# FUNCTION
|
||||
# render openscad file and store as file type defined by path_stl
|
||||
# ARGUMENTS
|
||||
# str path_scad - filepath of openscad model
|
||||
# str path_stl - filepath to store (stl)
|
||||
# VARIABLE INSTANTIATION
|
||||
cmd = f'{path_cmd} "{path_scad}"'
|
||||
# METHODS
|
||||
exec_oscmd(cmd)
|
||||
|
||||
|
||||
def slice_model(path_stl, path_gcode):
|
||||
# FUNCTION
|
||||
# slice stl file using Cura Engine
|
||||
# ARGUMENTS
|
||||
# str path_stl - filepath for input stl
|
||||
# str path_stl - filepath to store gcode
|
||||
# VARIABLE INSTANTIATION
|
||||
cmd = f'C:\\"Program Files\\Ultimaker Cura 4.11.0\\CuraEngine ' # ToDo FINISH THIS
|
||||
# METHODS
|
||||
exec_oscmd(cmd)
|
||||
Reference in New Issue
Block a user