|
8 | 8 |
|
9 | 9 | from compas_rhino import unload_modules # noqa: F401 |
10 | 10 |
|
| 11 | +try: |
| 12 | + import Grasshopper |
| 13 | +except ImportError: |
| 14 | + # We're not running inside Grasshopper, fail silently |
| 15 | + pass |
11 | 16 |
|
12 | 17 | __version__ = "2.14.1" |
13 | 18 |
|
|
16 | 21 | "get_grasshopper_library_path", |
17 | 22 | "get_grasshopper_userobjects_path", |
18 | 23 | "fetch_ghio_lib", |
| 24 | + "create_id", |
| 25 | + "warning", |
| 26 | + "error", |
| 27 | + "remark", |
| 28 | + "message", |
19 | 29 | ] |
20 | 30 | __all_plugins__ = [ |
21 | 31 | "compas_ghpython.install", |
@@ -56,6 +66,58 @@ def create_id(component, name): |
56 | 66 | return "{}_{}".format(name, component.InstanceGuid) |
57 | 67 |
|
58 | 68 |
|
| 69 | +def warning(component, message): |
| 70 | + """Add a warning message to the component. |
| 71 | +
|
| 72 | + Parameters |
| 73 | + ---------- |
| 74 | + component : Grasshopper.Kernel.IGH_Component |
| 75 | + The component instance. Pre-Rhino8 use `self`. Post-Rhino8 use `ghenv.Component`. |
| 76 | + message : str |
| 77 | + The message to display. |
| 78 | + """ |
| 79 | + component.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Warning, message) |
| 80 | + |
| 81 | + |
| 82 | +def error(component, message): |
| 83 | + """Add an error message to the component. |
| 84 | +
|
| 85 | + Parameters |
| 86 | + ---------- |
| 87 | + component : Grasshopper.Kernel.IGH_Component |
| 88 | + The component instance. Pre-Rhino8 use `self`. Post-Rhino8 use `ghenv.Component`. |
| 89 | + message : str |
| 90 | + The message to display. |
| 91 | + """ |
| 92 | + component.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, message) |
| 93 | + |
| 94 | + |
| 95 | +def remark(component, message): |
| 96 | + """Add a remark message to the component. |
| 97 | +
|
| 98 | + Parameters |
| 99 | + ---------- |
| 100 | + component : Grasshopper.Kernel.IGH_Component |
| 101 | + The component instance. Pre-Rhino8 use `self`. Post-Rhino8 use `ghenv.Component`. |
| 102 | + message : str |
| 103 | + The message to display. |
| 104 | + """ |
| 105 | + component.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Remark, message) |
| 106 | + |
| 107 | + |
| 108 | +def message(component, message): |
| 109 | + """Add a text that will appear under the component. |
| 110 | +
|
| 111 | + Parameters |
| 112 | + ---------- |
| 113 | + component : Grasshopper.Kernel.IGH_Component |
| 114 | + The component instance. Pre-Rhino8 use `self`. Post-Rhino8 use `ghenv.Component`. |
| 115 | + message : str |
| 116 | + The message to display. |
| 117 | + """ |
| 118 | + component.Message = message |
| 119 | + |
| 120 | + |
59 | 121 | # ============================================================================= |
60 | 122 | # Managed Plugin |
61 | 123 | # ============================================================================= |
|
0 commit comments