def task_dialog(type_mes, msg, data=None): """ For create task dialog with error and message :param type_mes: info or error :type type_mes: str :param msg: Message for window :type msg: str :param data: Text for expanded content :type data: list """ window = UI.TaskDialog('Заполнение MCP параметров') window.TitleAutoPrefix = False if type_mes == 'info': window.MainIcon = UI.TaskDialogIcon.TaskDialogIconInformation window.MainInstruction = 'Info' window.MainContent = msg else: window.MainIcon = UI.TaskDialogIcon.TaskDialogIconWarning window.MainInstruction = 'Error' window.MainContent = msg window.FooterText = ("<a href=\"{}\"> ".format(URL_TO_DOCUMENTATION) + "Нажмите сюда, чтобы открыть документацию</a>") logger.error(msg) if data: window.ExpandedContent = data if isinstance(data, str) else '\n'.join(data) window.CommonButtons = UI.TaskDialogCommonButtons.Ok window.Show()
def create_dim_for_column(column, view, k_offset=4, k_space=1, k_shift_space=0.8): try: grids = AxlesColumn(column).get_axles() dims = [] for grid in grids[:1]: try: dim = create_dim_for_column_and_grid(column, grid, view, k_offset) except FacesNotOrto: logger.error('Problem with face for {} in {}-{} '.format( grid.Name, grids[0].Name, grids[1].Name)) continue dims.append(dim) # TODO add 1 segment if dim.Segments.Size == 2: text_position = Dim2TextPosition(dim, k_space, k_shift_space) text_position.update() else: logger.error('Dim for column at axles {}-{} have 1 segments for {}'.format( grids[0].Name, grids[1].Name, grid.Name)) logger.debug('#{} Column. Create {} dimension'.format(column.Id, len(dims))) except Exception: raise ScriptError('Can not create dim') return dims[0]
def main(): columns = get_columns() for column in columns: try: # TODO Переписать нормально. Без try или не в этом месте create_dim_for_column(column, doc.ActiveView, K_OFFSET, K_SPACE, K_SHIFT_SPACE) except Exception as err: logger.error(err) logger.info('Create dimension for {} columns '.format(len(columns)))
def _get_axis(self): axles_names = self._get_axles_name() axles = [] for axis_name in axles_names: try: axis = self.get_axis_by_name(axis_name) logger.debug('Axis with name {} selected'.format(axis.Name)) axles.append(axis) except ElemNotFound: logger.error('Can not found axles with name: "{}"'.format(axis_name)) return axles
def get_name_option_from_config_or_none(): try: cfg = get_config() if cfg.has_section('Setup_names'): section = cfg.get_section('Setup_names') file_name = get_file_name_for_config() if section.has_option(file_name): name_from_config = section.get_option(file_name) logger.debug('Get Option name from config: "{}"'.format( name_from_config)) return name_from_config except Exception: logger.error('Get error from export config')
def set_option_to_config(name_option): try: cfg = get_config() if not cfg.has_section('Setup_names'): cfg.add_section('Setup_names') section = cfg.get_section('Setup_names') file_name = get_file_name_for_config() section.set_option(file_name, name_option) cfg.save_changes() logger.debug('Set Option name "{}" from file: "{}"'.format( name_option, file_name)) except Exception: logger.error('Get error from export config')
logger.debug('Get adder number from user [{}]'.format(adder_number)) return adder_number @transaction_with_suppress(msg='Add number of piles', accessor=DuplicateMark()) def main(): selection = ui.Selection() adder_number = get_adder_number_from_user(count=len(selection)) for element in selection: add_number(element, adder_number) logger.debug('End Script') if __name__ == '__main__': # logger.setLevel(10) try: main() except UserCancelOperation: logger.debug('User cancel operation') except RpwException as e: logger.error(e) except Exception as err: logger.error('Critical error') raise