def update_edge_attributes(assembly, keys, names=None): if not names: names = assembly.default_edge_attributes.keys() names = sorted(names) key = keys[0] values = assembly.get_edge_attributes(key, names) if len(keys) > 1: for i, name in enumerate(names): for key in keys[1:]: if values[i] != assembly.get_edge_attribute(key, name): values[i] = '-' break dialog = PropertyListForm(names, values) if dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow): values = dialog.values else: values = None if values: for name, value in zip(names, values): if value != '-': for key in keys: try: value = literal_eval(value) except (SyntaxError, ValueError, TypeError): pass assembly.set_edge_attribute(key, name, value) return True return False
def update_named_values(names, values, message='', title='Update named values', evaluate=False): try: dialog = PropertyListForm(names, values) except Exception: values = ShowPropertyListBox(message, title, names, values) else: if dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow): values = dialog.values else: values = None if evaluate: if values: values = list(values) for i in range(len(values)): value = values[i] try: value = ast.literal_eval(value) except (TypeError, ValueError, SyntaxError): pass values[i] = value return values
def _update_named_values(names, values, message='', title='Update named values'): try: dialog = PropertyListForm(names, values) except Exception: values = ShowPropertyListBox(message, title, names, values) else: if dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow): values = dialog.values else: values = None return values