diff --git a/bambulabs_api/client.py b/bambulabs_api/client.py index 8961bad..7a6104e 100644 --- a/bambulabs_api/client.py +++ b/bambulabs_api/client.py @@ -194,7 +194,9 @@ def upload_file(self, file: BinaryIO, filename: str = "ftp_upload.gcode") -> str def start_print(self, filename: str, plate_number: int, use_ams: bool = True, - ams_mapping: list[int] = [0]) -> bool: + ams_mapping: list[int] = [0], + skip_objects: list[int] | None = None, + ) -> bool: """ Start printing a file. @@ -209,6 +211,8 @@ def start_print(self, filename: str, ams_mapping : list[int], optional The mapping of the filament trays to the plate numbers, by default [0]. + skip_objects (list[int] | None, optional): List of gcode objects to + skip. Defaults to None. Returns ------- @@ -218,7 +222,8 @@ def start_print(self, filename: str, return self.__printerMQTTClient.start_print_3mf(filename, plate_number, use_ams, - ams_mapping) + ams_mapping, + skip_objects) def stop_print(self) -> bool: """ @@ -451,3 +456,26 @@ def get_current_state(self) -> PrintStatus: The current state of the printer. """ return self.__printerMQTTClient.get_current_state() + + def get_skipped_objects(self) -> list[int]: + """ + Get the current state of the printer. + + Returns + ------- + PrintStatus + The current state of the printer. + """ + return self.__printerMQTTClient.get_skipped_objects() + + def skip_objects(self, obj_list: list[int]) -> bool: + """ + Skip Objects during printing. + + Args: + obj_list (list[int]): object list to skip objects. + + Returns: + bool: if publish command is successful + """ + return self.__printerMQTTClient.skip_objects(obj_list=obj_list) diff --git a/bambulabs_api/mqtt_client.py b/bambulabs_api/mqtt_client.py index 97877d8..15de99e 100644 --- a/bambulabs_api/mqtt_client.py +++ b/bambulabs_api/mqtt_client.py @@ -197,7 +197,9 @@ def get_light_state(self) -> str: def start_print_3mf(self, filename: str, plate_number: int, use_ams: bool = True, - ams_mapping: list[int] = [0]) -> bool: + ams_mapping: list[int] = [0], + skip_objects: list[int] | None = None + ) -> bool: """ Start the print @@ -206,10 +208,15 @@ def start_print_3mf(self, filename: str, plate_number (int): The plate number to print to use_ams (bool, optional): Use the AMS system. Defaults to True. ams_mapping (list[int], optional): The AMS mapping. Defaults to [0]. + skip_objects (list[int] | None, optional): List of gcode objects to + skip. Defaults to []. Returns: str: print_status """ + if skip_objects is not None and not skip_objects: + skip_objects = None + return self.__publish_command( { "print": @@ -224,9 +231,40 @@ def start_print_3mf(self, filename: str, "layer_inspect": False, "use_ams": bool(use_ams), "ams_mapping": list(ams_mapping), + "skip_objects": skip_objects, } }) + def skip_objects(self, obj_list: list[int]) -> bool: + """ + Skip Objects during printing. + + Args: + obj_list (list[int]): object list to skip objects. + + Returns: + bool: if publish command is successful + """ + return self.__publish_command( + { + "print": + { + "command": "skip_objects", + "obj_list": obj_list, + } + }) + + def get_skipped_objects(self) -> list[int]: + """ + Get skipped Objects. + + Args: + + Returns: + bool: if publish command is successful + """ + return self.__get("s_obj", []) + def get_current_state(self) -> PrintStatus: """ Get the current printer state from stg_cur