https://github.com/arup-group/oasysgh
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.8%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: arup-group
- License: mit
- Language: C#
- Default Branch: main
- Size: 4.92 MB
Statistics
- Stars: 5
- Watchers: 0
- Forks: 1
- Open Issues: 1
- Releases: 47
Metadata Files
README.md
OasysGH
A library with shared content for Oasys Grasshopper plugins.
| Latest | CI Pipeline | Deployment | Dependencies |
| ------ | ----------- | ---------- | ------------ |
|
|
|
|
|
Contents
Introduction
OasysGH is a library with shared content for Oasys Grasshopper plugins.
You can use this library for: - Units shared by multiple plugins, with form to set defaults. - GH_UnitNumber parameter to pass OasysUnits (fork of UnitsNet) based objects around between components. - Custom component UI (dropdown, sliders, buttons, etc), also known s "Component Attributes". - Abstract classes for parameters to help handle wrapping an object oriented API. - Abstract classes for components to help implement custom component UI. - Helper methods for input/output of various custom parameters
How to use
Reference this library as a NuGet package in your project.
Setup a OasysPluginInfo PluginInfo singleton like this for your plugin:
cs
internal sealed class PluginInfo
{
private static readonly Lazy<OasysPluginInfo> lazy =
new Lazy<OasysPluginInfo>(() => new OasysPluginInfo(
"Oasys Shared Grasshopper", "OasysGH", "1.0.0.0", false, "phc_alOp3OccDM3D18xJTWDoW44Y1cJvbEScm5LJSX8qnhs"
));
public static OasysPluginInfo Instance { get { return lazy.Value; } }
private PluginInfo()
{
}
}
Shared units
To initialise shared default units along with the Windows Form to allow user to set their default units, simply call the method:
cs
OasysGH.Utility.InitialiseMainMenuAndDefaultUnits();
This will also automatically download the latest version of the UnitNumber plugin, which is a separate project in this repository.
Content overview
Units
This library contains:
- A shared class with default units for typical engineering units.
- Filters to get relevant engineering units (UnitsNet contains many units unrelated to engineering, for instance lengths in lightyears or printer points)
- Helper methods to get for instance a moment unit from length and force units.
- A custom grasshopper parameter called GH_UnitNumber which wraps OasysUnits.IQuantity which will allow you to pass numbers with units around between components.
- Input helpers for GH_UnitNumber which will allow users to input:
- another GH_UnitNumber,
- a number (for instance from a slider) which will be converted into a Quantity with the selected unit (can be combined with dropdown UI component to allow users to select the unit)
- a text string, for instance 15 kNm which will be parsed into a OasysUnits.Moment.
Component Attributes
Attributes for components is a custom way to override the drawing methods creating the UI of a component on the Grasshopper canvas.
It is used to set the m_attributes field in a Grasshopper component:
cs
public override void CreateAttributes()
{
m_attributes = new UI.DropDownComponentAttributes(this, SetSelected, _dropDownItems, _selectedItems, _spacerDescriptions);
}
OasysGH contains component Attribute methods to create:
- Bool6 component (six check boxes)
- Button component (single button for 'Open' components)
- Dropdown(s) with check boxes
- Dropdown(s) component
- Dropdown(s) with slider (for scaling results)
- Releases component (12 check boxes)
- Support component (three buttons with six check boxes)
- Three button component (for 'Save' components, buttons for 'Save', 'Save As' and 'Open in X')
Feel free to add your own custom components UI.
Abstract component classes
Inherit from GH_OasysComponent, GH_OasysDropDownComponent or GH_OasysTaskCapableComponent<T> to:
- Track usage with posthog
- Use simple scaffolding code to create, for instance, complex dropdown menus components. The abstract base classes take care of most things for you.
- By default, the GH_OasysDropDownComponent will use DropDownComponentAttributes so you do not have to override the CreateAttributes() method unless you want to use one of the other component attributes.
GH_OasysComponent
Inherit from this class if you have a simple, normal component with nothing fancy happening. This will simply add posthog tracking to your components.
GH_OasysDropDownComponent
Inherit from this class to use the custom UI. As mentioned above, the default behaviour is for GH_OasysDropDownComponent to use DropDownComponentAttributes but if you want to use one of the other attributes just override the CreateAttributes() method.
A good example for simple implementation of the abstract/virtual methods in GH_OasysDropDownComponent is shown below, this is taken from the ComposGH repo
This example will create a component with a dropdown menu to set a length unit. It will take the initial unit from the default units, but then afterwards save the selected unit in the component so that the settings is stored when users reopen their Grasshopper document.
First, we need to initialise the dropdown lists ```cs private LengthUnit LengthUnit = DefaultUnits.LengthUnitSection; // get default length unit
public override void InitialiseDropdowns()
{
_spacerDescriptions = new List
_dropDownItems = new List>();
_selectedItems = new List
// add length _dropDownItems.Add(Units.FilteredLengthUnits); _selectedItems.Add(LengthUnit.ToString());
_isInitialised = true; } ```
Secondly, we need to implement what happens when users make a selection in the dropdown: ```cs public override void SetSelected(int i, int j) { // change selected item _selectedItems[i] = _dropDownItems[i][j]; if (LengthUnit.ToString() == _selectedItems[i]) return;
LengthUnit = (LengthUnit)Enum.Parse(typeof(LengthUnit), _selectedItems[i]);
base.UpdateUI(); } ```
Then we need to handle what happens when the component is recreated when a saved document is opened again (or when the component is copied).
The contents of selectedItems and _dropDownItems are both stored and recreated automatically by `GHOasysDropDownComponentbase.
``cs
public override void UpdateUIFromSelectedItems()
{
LengthUnit = (LengthUnit)Enum.Parse(typeof(LengthUnit), _selectedItems[0]);
base.UpdateUIFromSelectedItems(); } ```
Finally, and optionally, we may want to change the name of the input parameters to display the selected unit on for instance sliders:
cs
public override void VariableParameterMaintenance()
{
string unitAbbreviation = Length.GetAbbreviation(LengthUnit);
Params.Input[0].Name = "Pos x [" + unitAbbreviation + "]";
Params.Input[3].Name = "Spacing [" + unitAbbreviation + "]";
}

Abstract parameter classes
The abstract parameter classes makes it easy to implement a custom Grasshopper parameter by wrapping another API object.
GH_OasysGoo
An example of how easy it is to inherit from GH_OasysGoo<T> is the GHUnitNumber Goo wrapper class, that makes sure s OasysUnits IQuantity can be used in Grasshopper and passed around between components.
```cs
public class GHUnitNumber : GHOasysGoo
public GHUnitNumber(IQuantity item) : base(item) { }
public override IGHGoo Duplicate() => new GH_UnitNumber(Value);
}
```
GH_OasysGeometryGoo
This class is still to be implemented, but is in the making...
Input helpers
OasysGH provides helper methods to get generic input parameters. This enables a single line of code in SolveInstance to retreive custom input parameters in a coherent way that will act similar to how Grasshopper acts to build-in parameters (same type of errors/warnings). For instance a UnitNumber length input can be retrieved like this:
cs
Length inputLength = (Length)Input.UnitNumber(this, DA, 0, _lengthUnit);
The helpers include methods for getting:
- GenericGoo<T> (item input)
- List<GenericGoo<T>> (list input)
- UnitNumber (item input)
- List<UnitNumber> (list input)
The UnitNumber inputs are special in the sense that they include additional helpers to cast from string (text) and double (number) inputs, allowing users to input IQuanity as either a:
- UnitNumber
- Number (unit will be taken from the dropdown or you can implement a static unit like Hertz for FrequencyUnit)
- Text (for instance 15 kNm or 130mm)

In the image above, the unit for the Height input (cm) is taken from dropdown. Note that the text inputs can be either with or without space between value and unit. Not shown is the example of inputting another UnitNumber.
Output helpers
In order to prevent the dropdown components to continuously expire downstream components, OasysGH provides helper functions to set outputs as item, list or tree which will only expire the output if the output has actually been changed. This allows the user to toggle the dropdown lists without the entire Grasshopper script having to recalculate.
License
Owner
- Name: Arup
- Login: arup-group
- Kind: organization
- Email: media@arup.com
- Website: https://www.arup.com/
- Repositories: 168
- Profile: https://github.com/arup-group
We Shape a Better World
GitHub Events
Total
- Watch event: 1
- Issue comment event: 1
- Pull request event: 1
- Create event: 1
Last Year
- Watch event: 1
- Issue comment event: 1
- Pull request event: 1
- Create event: 1
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 1
- Total pull requests: 119
- Average time to close issues: 2 months
- Average time to close pull requests: 3 days
- Total issue authors: 1
- Total pull request authors: 5
- Average comments per issue: 0.0
- Average comments per pull request: 0.54
- Merged pull requests: 110
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 8
- Average time to close issues: N/A
- Average time to close pull requests: 2 days
- Issue authors: 0
- Pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 1.13
- Merged pull requests: 5
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- tlmnrnhrdt (1)
Pull Request Authors
- tlmnrnhrdt (70)
- kpne (44)
- SandeepArup (11)
- psarras (3)
- DominikaLos (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- nuget 13,460 total
- Total dependent packages: 3
- Total dependent repositories: 0
- Total versions: 46
- Total maintainers: 1
nuget.org: oasysgh
OasysGH is a library with shared content for Oasys Grasshopper plugins.
- Homepage: https://github.com/arup-group/OasysGH
- License: MIT
-
Latest release: 1.2.4
published almost 2 years ago
Rankings
Maintainers (1)
Dependencies
- i3h/download-release-asset v1 composite
- i3h/download-release-asset v1 composite
- Grasshopper 6.27.20176.5001 development
- RhinoCommon 6.27.20176.5001 development
- OasysUnits 1.0.0
- System.ValueTuple 4.5.0
- Rhino.Inside 7.0.0
- coverlet.collector 3.1.2
- xunit 2.4.2
- xunit.runner.visualstudio 2.4.5
- Grasshopper 6.27.20176.5001 development
- RhinoCommon 6.27.20176.5001 development
- Newtonsoft.Json 13.0.1
- OasysUnits 1.0.0
- OasysUnits.Serialization.JsonNet 1.0.0
- System.DirectoryServices.AccountManagement 5.0.0
- coverlet.collector 3.1.2 development
- xunit.runner.visualstudio 2.4.5 development
- Rhino.Inside 7.0.0
- xunit 2.4.2
- Microsoft.Data.Sqlite 7.0.3
- Rhino.Inside 7.0.0
- coverlet.collector 6.0.0
- xunit 2.5.1
- xunit.runner.visualstudio 2.5.1
- Grasshopper 6.27.20176.5001 development
- RhinoCommon 6.27.20176.5001 development
- arup-group/actions-composite-oasys-jira-check/branch main composite
- arup-group/action-pr-title-jira-check main composite