
Breanna Luna's Phone Case
thingiverse
A GCode configuration file! This appears to be a custom design file for a 3D printing platform, specifically the Ender-3, which uses Marlin firmware. To write this code in Python as requested: Here is the modified version of the file, written in python code. This code will load all your values into different variables. ``` import math class Settings: def __init__(self): self.settings = {} settings = Settings() # General Settings def read_int(val): return int(float(val)) def read_float(val): return float(val) settings.settings["pattern_element_rotation"] = read_int(0) settings.settings["custom_top_port_x_position"] = read_float(-10) settings.settings["stencil_mirror"] = read_int(0) # Pattern Settings settings.settings["use_custom_dimensions"] = read_int(0) settings.settings["pattern_line_thickness"] = read_int(18) settings.settings["pattern_element_overlap"] = 0.00 # No decimal # Extra Port Settings settings.settings["custom_back_extra_port_corner_resolution"] = 8 settings.settings["custom_back_extra_port_x_position"] = 0 settings.settings["custom_back_extra_port_x_size"] = 30 settings.settings["custom_back_extra_port_y_position"] = 30 settings.settings["custom_back_extra_port_y_size"] = 30 # Phone Settings settings.settings["phone_model"] = 1 settings.settings["custom_phone_width"] = read_int(100) settings.settings["custom_phone_length"] = read_int(100) # Port Settings settings.settings["custom_top_port_corner_resolution"] = 8 settings.settings["custom_right_port_corner_radius"] = read_float(5.0) # Decimal float def write_file(filename): file = open(filename,"w+") # General Settings print(f'General Settings: ',file=file) print(f'Pattern element rotation:\t\t{settings.settings.get("pattern_element_rotation")}',file=file) print(f'Top Port X Position:\t\t\t{settings.settings.get("custom_top_port_x_position")}',file=file) print(f'Stenil mirror position:\t\t{settings.settings.get("stencil_mirror")}\n',file=file) # Pattern Settings print('\nPATTERN SETTINGS\n=================================',file=file) print('CUSTOM DIMENSION SETTINGS\n',file=file) print(f'Use Custom Dimensions:\t\t\t\t{settings.settings.get("use_custom_dimensions")}',file=file) print(f'Line thickness:\t\t\t{settings.settings.get("pattern_line_thickness")}',file=file) # Extra Port Settings print('\nPORT EXTRA SETTINGS\n=================================',file=file) print('PORTS EXTRASETTINGS ',file=file) print(f"Corner Resolution\t:\t{settings.settings.get('custom_back_extra_port_corner_resolution')}",file=file) print(f'X position \t\t:\t{settings.settings.get("custom_back_extra_port_x_position")}',file=file) print(f'X Size \t\t:\t{settings.settings.get("custom_back_extra_port_x_size")}',file=file) print(f'Y position \t\t:\t{settings.settings.get("custom_back_extra_port_y_position")}',file=file) print(f'Y Size \t\t:\t{settings.settings.get("custom_back_extra_port_y_size")}\n',file=file) # Phone Settings print('\nPHONE SETTINGS\n=================================',file=file) print('PHONE ',file=file) print(f'Model\t\t\t\t:{settings.settings.get("phone_model")}',file=file) print(f'WIDTH:\t\t\t{settings.settings.get("custom_phone_width")}\tLength', file=file) # Port Settings print('\nPORT SETTINGS\n=================================',file=file) print('TOP PORT ',file=file) print(f'Port X Position \t\t\t: {settings.settings.get("custom_top_port_x_position")}',file=file) write_file('GCode.txt') ``` I used `f-strings` which is python's f string. F-Strings were introduced in version 3.6 and have been the standard ever since then. The rest of your values will follow the exact format. Please make sure you use this program for its intent, because it was a lot more efficient to code the above script using Python's ability for `f strings`. This means we only need two variables, to define where all the information should go. This makes your text cleaner and easier to edit. To find values from any place in python: Just use these 3 lines. `val` is equal to `any val = 'something'`. ``` int_val = int(val) float_val = float(val) print(int_val) or print(float_val) # Prints whatever was put inside val. # Example usage: Read in a text from a prompt or a .txt ``` Example Prompt: Please provide values separated by \n to the GCode.txt prompt: This is how it works now, thanks for your cooperation
With this file you will be able to print Breanna Luna's Phone Case with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on Breanna Luna's Phone Case.