-
Notifications
You must be signed in to change notification settings - Fork 114
added some UI helpers for GH components #1501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,11 @@ | |
|
|
||
| from compas_rhino import unload_modules # noqa: F401 | ||
|
|
||
| try: | ||
| import Grasshopper | ||
| except ImportError: | ||
| # We're not running inside Grasshopper, fail silently | ||
| pass | ||
|
|
||
| __version__ = "2.14.1" | ||
|
|
||
|
|
@@ -16,6 +21,11 @@ | |
| "get_grasshopper_library_path", | ||
| "get_grasshopper_userobjects_path", | ||
| "fetch_ghio_lib", | ||
| "create_id", | ||
| "warning", | ||
| "error", | ||
| "remark", | ||
| "message", | ||
| ] | ||
| __all_plugins__ = [ | ||
| "compas_ghpython.install", | ||
|
|
@@ -56,6 +66,58 @@ def create_id(component, name): | |
| return "{}_{}".format(name, component.InstanceGuid) | ||
|
|
||
|
|
||
| def warning(component, message): | ||
| """Add a warning message to the component. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| component : Grasshopper.Kernel.IGH_Component | ||
| The component instance. Pre-Rhino8 use `self`. Post-Rhino8 use `ghenv.Component`. | ||
| message : str | ||
| The message to display. | ||
| """ | ||
| component.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Warning, message) | ||
|
||
|
|
||
|
|
||
| def error(component, message): | ||
| """Add an error message to the component. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| component : Grasshopper.Kernel.IGH_Component | ||
| The component instance. Pre-Rhino8 use `self`. Post-Rhino8 use `ghenv.Component`. | ||
| message : str | ||
| The message to display. | ||
| """ | ||
| component.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, message) | ||
|
||
|
|
||
|
|
||
| def remark(component, message): | ||
| """Add a remark message to the component. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| component : Grasshopper.Kernel.IGH_Component | ||
| The component instance. Pre-Rhino8 use `self`. Post-Rhino8 use `ghenv.Component`. | ||
| message : str | ||
| The message to display. | ||
| """ | ||
| component.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Remark, message) | ||
|
||
|
|
||
|
|
||
| def message(component, message): | ||
| """Add a text that will appear under the component. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| component : Grasshopper.Kernel.IGH_Component | ||
| The component instance. Pre-Rhino8 use `self`. Post-Rhino8 use `ghenv.Component`. | ||
| message : str | ||
| The message to display. | ||
| """ | ||
| component.Message = message | ||
|
|
||
|
|
||
| # ============================================================================= | ||
| # Managed Plugin | ||
| # ============================================================================= | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'except' clause does nothing but pass and there is no explanatory comment.