Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 089ecca34e | |||
| 1c09449f19 | |||
| 0e81ac07f0 | |||
| 7d3afe4f9f | |||
| 997b1049aa |
@@ -18,19 +18,19 @@ The Checker function allows you to:
|
||||
|
||||
### 1. Prepare Your Rule Spreadsheet
|
||||
|
||||
1. Access the [template spreadsheet](https://docs.google.com/spreadsheets/d/1hiPSw23eOaqd27QD_YsXvZg9PWm7_XBx/edit) (
|
||||
make a copy to your drive)
|
||||
2. Define your rules using the format explained below
|
||||
3. Publish your rules by clicking "File > Download > Tab-separated values (.tsv)"
|
||||
4. Upload the TSV file to a hosting service (Google Drive, Dropbox, etc.) and get a public URL
|
||||
1. Access
|
||||
the [template spreadsheet](https://docs.google.com/spreadsheets/d/1eB0RVuOXdjLyn4_GAPSahV05p1lqfSGQbH8WWijnkkA/edit?gid=0#gid=0)
|
||||
2. Use the Speckle menu to launch the Speckle sidebar and make a copy.
|
||||
3. Define your rules using the format explained below
|
||||
4. Publish your rules by clicking "Publish Rules". Copy the resultant URL.
|
||||
|
||||
### 2. Create an Automation
|
||||
|
||||
1. Go to [Speckle Automate](https://automate.speckle.dev/)
|
||||
1. Go to your workspace project in [Speckle](https://app.speckle.systems/)
|
||||
2. Create a new Automation
|
||||
3. Select the Checker function
|
||||
4. Configure the function:
|
||||
- Paste your TSV URL
|
||||
- Paste your published rules URL
|
||||
- Set minimum severity level to report
|
||||
- Configure other options as needed
|
||||
5. Save and run your automation
|
||||
@@ -58,20 +58,20 @@ Rules are defined in a spreadsheet with the following columns:
|
||||
|
||||
### Supported Predicates
|
||||
|
||||
| Predicate | Description | Example |
|
||||
|------------------|-----------------------------|------------------------------------|
|
||||
| exists | Checks if a property exists | `height` exists |
|
||||
| equal to | Exact value match | `width` equal to `300` |
|
||||
| not equal to | Value doesn't match | `material` not equal to `Concrete` |
|
||||
| greater than | Value exceeds threshold | `height` greater than `3000` |
|
||||
| less than | Value below threshold | `thickness` less than `50` |
|
||||
| in range | Value within bounds | `elevation` in range `0,10000` |
|
||||
| in list | Value in allowed set | `type` in list `W1,W2,W3` |
|
||||
| contains | Property contains substring | `name` contains `Beam` |
|
||||
| does not contain | Property doesn't contain | `name` does not contain `temp` |
|
||||
| is true | Boolean property is true | `is_structural` is true |
|
||||
| is false | Boolean property is false | `is_placeholder` is false |
|
||||
| is like | Pattern matching | `name` is like `^BR\d+$` |
|
||||
| Predicate | Description | Example |
|
||||
|------------------|-----------------------------|---------------------------------------|
|
||||
| exists | Checks if a property exists | `height` exists |
|
||||
| equal to | Exact value match | `width` equal to `300` |
|
||||
| not equal to | Value doesn't match | `material` not equal to `Concrete` |
|
||||
| greater than | Value exceeds threshold | `height` greater than `3000` |
|
||||
| less than | Value below threshold | `thickness` less than `50` |
|
||||
| in range | Value within bounds | `elevation` in range `0,10000` |
|
||||
| in list | Value in allowed set | `type` in list `W1,W2,W3` |
|
||||
| contains | Property contains substring | `name` contains `Beam` |
|
||||
| does not contain | Property doesn't contain | `name` does not contain `temp` |
|
||||
| is true | Boolean property is true | `is_structural` is true |
|
||||
| is false | Boolean property is false | `is_placeholder` is false |
|
||||
| is like | Loose text matching | `name` is like `Wall` matches `Walls` |
|
||||
|
||||
## Rule Logic
|
||||
|
||||
@@ -118,4 +118,4 @@ Severity: ERROR
|
||||
|
||||
## Support
|
||||
|
||||
For issues or questions, please open a GitHub issue or contact your Speckle support representative.
|
||||
For issues or questions, please let us know on the [Speckle Community Forum](https://speckle.community/).
|
||||
|
||||
@@ -17,4 +17,5 @@ PREDICATE_METHOD_MAP = {
|
||||
"identical to": PropertyRules.is_identical_value.__name__,
|
||||
"contains": PropertyRules.is_parameter_value_containing.__name__,
|
||||
"does not contain": PropertyRules.is_parameter_value_not_containing.__name__,
|
||||
"is set": PropertyRules.is_parameter_value_not_empty.__name__,
|
||||
}
|
||||
|
||||
@@ -890,3 +890,35 @@ class PropertyRules:
|
||||
return PropertyRules.compare_values(
|
||||
parameter_value, value_to_match, case_sensitive=True, tolerance=0, allow_yes_no_bools=False, use_exact=True
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def is_parameter_value_not_empty(speckle_object: Base, parameter_name: str) -> bool:
|
||||
"""Checks if parameter exists and has a non-empty value.
|
||||
|
||||
Args:
|
||||
speckle_object: The Speckle object to check
|
||||
parameter_name: Name of the parameter to check
|
||||
|
||||
Returns:
|
||||
bool: True if parameter exists and has a non-empty value
|
||||
"""
|
||||
# Get the parameter value
|
||||
parameter_value = PropertyRules.get_parameter_value(speckle_object, parameter_name)
|
||||
|
||||
# Check if parameter exists
|
||||
if parameter_value is None:
|
||||
return False
|
||||
|
||||
# Check if value is an empty string
|
||||
if isinstance(parameter_value, str) and parameter_value.strip() == "":
|
||||
return False
|
||||
|
||||
# Check if value is an empty list or collection
|
||||
if hasattr(parameter_value, "__len__") and len(parameter_value) == 0:
|
||||
return False
|
||||
|
||||
# Additional check for "None" string which can sometimes appear in exports
|
||||
if isinstance(parameter_value, str) and parameter_value.lower() == "none":
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
@@ -415,3 +415,20 @@ class TestParameterHandling:
|
||||
"""Test negative substring matching on parameter values."""
|
||||
v2_obj, _ = test_objects
|
||||
assert PropertyRules.is_parameter_value_not_containing(v2_obj, param_name, substring) == expected_result
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"param_name, expected_result",
|
||||
[
|
||||
("category", True), # Parameter exists with non-empty value
|
||||
("family", True), # Parameter exists with non-empty value
|
||||
("non_existent_param", False), # Parameter doesn't exist
|
||||
# The following would require setup with empty values
|
||||
# ("empty_string_param", False), # Parameter exists but has empty string value
|
||||
# ("none_string_param", False), # Parameter exists but has "None" string value
|
||||
],
|
||||
)
|
||||
def test_parameter_not_empty(self, test_objects, param_name, expected_result):
|
||||
"""Test 'not empty' check on parameter values."""
|
||||
v2_obj, _ = test_objects
|
||||
|
||||
assert PropertyRules.is_parameter_value_not_empty(v2_obj, param_name) == expected_result
|
||||
|
||||
Reference in New Issue
Block a user