[Kr...] Posted January 31, 2023 Share Posted January 31, 2023 Hello, Is there a way to add console print results to the end of a script dialogue box? I've got a simple script (trying to learn by playing around) that exports a mesh if the box is checked on a pop up. If there is an error (no mesh in project) then the script is ignored and the console prints "Mesh Output Failed". I've got a dialogue that pops up at the end to tell you the exports are complete. Is there a way to get the final dialogue box display any errors that were in the console. For example if the mesh output failed. The dialogue box will show this information instead of saying all exports complete. Hopefully that makes sense DIALOG=gom.script.sys.create_user_defined_dialog (dialog={ "content": [ [ { "columns": 1, "name": "CBMesh_Out", "rows": 1, "title": { "id": "", "text": "Mesh", "translatable": True }, "tooltip": { "id": "", "text": "", "translatable": True }, "type": "input::checkbox", "value": False } ] ], "control": { "id": "OkCancel" }, "embedding": "", "position": "", "size": { "height": 112, "width": 214 }, "sizemode": "", "style": "", "title": { "id": "", "text": "Dialog Title", "translatable": True } }) # # Event handler function called if anything happens inside of the dialog # def dialog_event_handler (widget): pass DIALOG.handler = dialog_event_handler RESULT=gom.script.sys.show_user_defined_dialog (dialog=DIALOG) try: if DIALOG.CBMesh_Out.value: gom.script.sys.export_stl ( bgr_coding=False, binary=True, color=False, elements=gom.ElementSelection ({'category': ['key', 'elements', 'part', gom.app.project.parts['Part'], 'explorer_category', 'actual_part']}), export_in_one_file=True, export_stages_mode='current', file='C:/Users/kwain1/Desktop/Part.Less details.stl', length_unit='default', set_stl_color_bit=False) else: print ("No Mesh Output") except Exception: print ('Mesh Output Failed') pass DIALOG=gom.script.sys.create_user_defined_dialog (dialog={ "content": [ [ { "columns": 1, "default_font_family": "", "default_font_size": 0, "name": "text", "rows": 1, "text": { "id": "", "text": "<html><p><span style=\"vertical-align:;\">All outputs have been exported. </span></p></html>", "translatable": True }, "tooltip": { "id": "", "text": "", "translatable": True }, "type": "display::text", "wordwrap": False } ] ], "control": { "id": "OkCancel" }, "embedding": "always_toplevel", "position": "automatic", "size": { "height": 169, "width": 242 }, "sizemode": "automatic", "style": "", "title": { "id": "", "text": "Message", "translatable": True } }) # # Event handler function called if anything happens inside of the dialog # def dialog_event_handler (widget): pass DIALOG.handler = dialog_event_handler RESULT=gom.script.sys.show_user_defined_dialog (dialog=DIALOG) Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in