Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e1288427bb | |||
| ac62d6373a | |||
| b88c956583 | |||
| e2bfdefc6d | |||
| ce0299bccf | |||
| 0d2c827297 | |||
| 98c4a119c7 | |||
| 61cb8d54f5 | |||
| 24400bfb9b | |||
| 5978a90c72 |
@@ -11,8 +11,8 @@ jobs:
|
||||
FUNCTION_SCHEMA_FILE_NAME: functionSchema.json
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.4.0
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/checkout@v4.2.2
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- name: Install and configure Poetry
|
||||
@@ -29,12 +29,12 @@ jobs:
|
||||
run: |
|
||||
python main.py generate_schema ${HOME}/${{ env.FUNCTION_SCHEMA_FILE_NAME }}
|
||||
- name: Speckle Automate Function - Build and Publish
|
||||
uses: specklesystems/speckle-automate-github-composite-action@0.7.4
|
||||
uses: specklesystems/speckle-automate-github-composite-action@0.8.1
|
||||
with:
|
||||
speckle_automate_url: ${{ env.SPECKLE_AUTOMATE_URL || 'https://automate.speckle.dev' }}
|
||||
speckle_token: ${{ secrets.SPECKLE_FUNCTION_TOKEN }}
|
||||
speckle_function_id: ${{ secrets.SPECKLE_FUNCTION_ID }}
|
||||
speckle_function_input_schema_file_path: ${{ env.FUNCTION_SCHEMA_FILE_NAME }}
|
||||
speckle_function_command: 'python -u main.py run'
|
||||
speckle_function_recommended_cpu_m: 4000
|
||||
speckle_function_recommended_memory_mi: 4000
|
||||
speckle_function_recommended_cpu_m: 8000
|
||||
speckle_function_recommended_memory_mi: 8000
|
||||
|
||||
+8
-3
@@ -88,8 +88,13 @@ def speckle_mesh_to_trimesh(input_mesh: SpeckleMesh) -> trimesh.Trimesh:
|
||||
|
||||
t_mesh = trimesh.Trimesh(vertices=vertices, faces=np.array(faces))
|
||||
|
||||
obbox = t_mesh.bounding_box_oriented
|
||||
return t_mesh
|
||||
|
||||
obbox_mesh = obbox.to_mesh()
|
||||
# code below speeds up the process but is not used in the current implementation.
|
||||
# Bounding boxes could be used for a 2-pass approach to speed up the process.
|
||||
|
||||
return obbox_mesh
|
||||
# obbox = t_mesh.bounding_box_oriented
|
||||
|
||||
# obbox_mesh = obbox.to_mesh()
|
||||
|
||||
# return obbox_mesh
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use the automation_context module to wrap your function in an Automate context helper
|
||||
"""
|
||||
|
||||
from collections import defaultdict
|
||||
from typing import Optional
|
||||
|
||||
@@ -44,19 +45,22 @@ class FunctionInputs(AutomateBase):
|
||||
Negative values relaxes the test, positive values make it more strict.",
|
||||
json_schema_extra={
|
||||
"readOnly": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
tolerance_unit: str = Field( # Using the SpecklePy Units enum here
|
||||
default=Units.mm,
|
||||
json_schema_extra={"examples": ["mm", "cm", "m"], "readOnly": True},
|
||||
title="Tolerance Unit",
|
||||
description="Unit of the tolerance value.",
|
||||
json_schema_extra={
|
||||
"examples": ["mm", "cm", "m"],
|
||||
"readOnly": True
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def automate_function(
|
||||
automate_context: AutomationContext,
|
||||
function_inputs: FunctionInputs,
|
||||
automate_context: AutomationContext,
|
||||
function_inputs: FunctionInputs,
|
||||
) -> None:
|
||||
"""This is an example Speckle Automate function.
|
||||
|
||||
@@ -71,10 +75,12 @@ def automate_function(
|
||||
changed_model_version = automate_context.receive_version()
|
||||
|
||||
try:
|
||||
reference_model_version, reference_model_id, reference_model_version_id = get_reference_model(
|
||||
automate_context, function_inputs.static_model_name
|
||||
reference_model_version, reference_model_id, reference_model_version_id = (
|
||||
get_reference_model(automate_context, function_inputs.static_model_name)
|
||||
)
|
||||
print(
|
||||
f"Reference model id: {reference_model_id}, version id: {reference_model_version_id}"
|
||||
)
|
||||
print(f"Reference model id: {reference_model_id}, version id: {reference_model_version_id}")
|
||||
|
||||
except Exception as ex:
|
||||
automate_context.mark_run_failed(status_message=str(ex))
|
||||
@@ -100,6 +106,8 @@ def automate_function(
|
||||
"Objects.BuiltElements.Duct",
|
||||
"Objects.BuiltElements.Duct:Objects.BuiltElements.Revit.RevitDuct",
|
||||
"Objects.BuiltElements.Duct:Objects.BuiltElements.Revit.RevitDuct:Objects.BuiltElements.Revit.RevitFlexDuct",
|
||||
"Objects.Other.Revit.RevitInstance:Objects.BuiltElements.Revit.RevitMEPFamilyInstance",
|
||||
"Objects.BuiltElements.Revit.RevitElementType:Objects.BuiltElements.Revit.RevitSymbolElementType"
|
||||
]
|
||||
|
||||
visible_beams_rule = element_rules.rule_combiner(
|
||||
@@ -138,20 +146,20 @@ def automate_function(
|
||||
status_message="Clash detection failed. No objects to compare."
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
clashes = detect_and_report_clashes(
|
||||
reference_mesh_elements, latest_mesh_elements, tolerance, automate_context
|
||||
)
|
||||
|
||||
|
||||
percentage_reference_objects_clashing = (
|
||||
len(set([ref_id for ref_id, latest_id in clashes]))
|
||||
/ len(reference_mesh_elements)
|
||||
* 100
|
||||
len(set([ref_id for ref_id, latest_id in clashes]))
|
||||
/ len(reference_mesh_elements)
|
||||
* 100
|
||||
)
|
||||
percentage_latest_objects_clashing = (
|
||||
len(set([latest_id for ref_id, latest_id in clashes]))
|
||||
/ len(latest_mesh_elements)
|
||||
* 100
|
||||
len(set([latest_id for ref_id, latest_id in clashes]))
|
||||
/ len(latest_mesh_elements)
|
||||
* 100
|
||||
)
|
||||
|
||||
# all clashes count
|
||||
@@ -177,7 +185,7 @@ def automate_function(
|
||||
|
||||
|
||||
def get_reference_model(
|
||||
automate_context: AutomationContext, static_model_name: str
|
||||
automate_context: AutomationContext, static_model_name: str
|
||||
) -> tuple[Base, Optional[str], Optional[str]]:
|
||||
# the static reference model will be retrieved from the project using model name stored in the inputs
|
||||
speckle_client = automate_context.speckle_client
|
||||
|
||||
Generated
+578
-560
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -7,7 +7,7 @@ readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.10"
|
||||
specklepy = "2.17.11"
|
||||
specklepy = "2.17.17"
|
||||
trimesh = "^4.0.4"
|
||||
pytest = "^7.4.2"
|
||||
python-dotenv = "^1.0.0"
|
||||
|
||||
Reference in New Issue
Block a user