-
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1501 +/- ##
==========================================
- Coverage 62.26% 62.25% -0.01%
==========================================
Files 208 208
Lines 22452 22452
==========================================
- Hits 13979 13977 -2
- Misses 8473 8475 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR adds utility functions for displaying messages in Grasshopper components. These functions provide a convenient API for adding warnings, errors, remarks, and custom messages to GH components across different Rhino versions.
- Adds four new helper functions:
warning,error,remark, andmessagetocompas_ghpython - Imports the Grasshopper module at the package level in a try-except block
- Updates the CHANGELOG to document the new additions
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/compas_ghpython/init.py | Adds Grasshopper import and four new message helper functions with documentation |
| CHANGELOG.md | Documents the addition of the new message functions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| message : str | ||
| The message to display. | ||
| """ | ||
| component.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Warning, message) |
Copilot
AI
Nov 4, 2025
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.
The function uses Grasshopper.Kernel.GH_RuntimeMessageLevel directly, but Grasshopper may be undefined if the import at line 12 failed. This will cause a NameError at runtime. Consider adding a check or raising a more informative error if Grasshopper is not available, or ensure these functions are only callable in Grasshopper contexts.
| message : str | ||
| The message to display. | ||
| """ | ||
| component.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, message) |
Copilot
AI
Nov 4, 2025
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.
The function uses Grasshopper.Kernel.GH_RuntimeMessageLevel directly, but Grasshopper may be undefined if the import at line 12 failed. This will cause a NameError at runtime. Consider adding a check or raising a more informative error if Grasshopper is not available, or ensure these functions are only callable in Grasshopper contexts.
| message : str | ||
| The message to display. | ||
| """ | ||
| component.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Remark, message) |
Copilot
AI
Nov 4, 2025
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.
The function uses Grasshopper.Kernel.GH_RuntimeMessageLevel directly, but Grasshopper may be undefined if the import at line 12 failed. This will cause a NameError at runtime. Consider adding a check or raising a more informative error if Grasshopper is not available, or ensure these functions are only callable in Grasshopper contexts.
|
|
||
| try: | ||
| import Grasshopper | ||
| except ImportError: |
Copilot
AI
Nov 4, 2025
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.
| except ImportError: | |
| except ImportError: | |
| # Grasshopper is not available in this environment; safe to ignore. |
|
@chenkasirer what about the copilot suggestions? |
I added a comment in the |
gonzalocasas
left a comment
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.
LGTM
warning,message,errorandremarktocompas_ghpython.What type of change is this?
Checklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.CHANGELOG.mdfile in theUnreleasedsection under the most fitting heading (e.g.Added,Changed,Removed).invoke test).invoke lint).compas.datastructures.Mesh.