Skip to content

Commit 3837516

Browse files
committed
WIP-ADD CVS exporter
1 parent 1938abd commit 3837516

File tree

6 files changed

+116
-1
lines changed

6 files changed

+116
-1
lines changed

src/gh/components/DF_cloud_to_cloud_distance/code.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import diffCheck.df_util
1919

20+
2021
class CloudToCloudDistance(component):
2122
def RunScript(self,
2223
i_cloud_source: rg.PointCloud,

src/gh/components/DF_cloud_to_cloud_distance/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"subcategory": "Analysis",
66
"description": "Computes the distance between each point in the source point cloud and its nearest neighbour in thr target point cloud.",
77
"exposure": 4,
8-
"instanceGuid": "805911b9-7ea9-4bbf-be34-00f9f225b9b3",
8+
"instanceGuid": "ad21f438-b953-464b-8332-04f4074f3bd0",
99
"ghpython": {
1010
"hideOutput": true,
1111
"hideInput": true,

src/gh/components/DF_cloud_to_mesh_distance/code.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from diffCheck import df_cvt_bindings
1616
from diffCheck import df_error_estimation
1717

18+
1819
class CloudToMeshDistance(component):
1920
def RunScript(self,
2021
i_cloud_source: rg.PointCloud,
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#! python3
2+
3+
import System
4+
import typing
5+
6+
import Rhino
7+
import Rhino.Geometry as rg
8+
from ghpythonlib.componentbase import executingcomponent as component
9+
10+
import Grasshopper as gh
11+
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
12+
13+
import csv
14+
import os
15+
16+
17+
class CsvExporter(component):
18+
def RunScript(self,
19+
i_dump: bool,
20+
i_export_dir: str,
21+
i_values: System.Collections.Generic.IList[float]):
22+
"""
23+
The csv-exporter component exports a list of values to a .csv file
24+
25+
:param i_dump: A flag indicating whether to perform the export.
26+
:param i_export_dir: The directory where the CSV file will be saved.
27+
:param i_values: A list of values to be exported.
28+
"""
29+
if i_dump:
30+
# Ensure the export directory exists
31+
os.makedirs(i_export_dir, exist_ok=True)
32+
33+
# Define the CSV file path
34+
file_path = os.path.join(i_export_dir, 'exported_values.csv')
35+
36+
# Write the values to the CSV file
37+
with open(file_path, mode='w', newline='') as file:
38+
writer = csv.writer(file)
39+
for value in i_values:
40+
writer.writerow([value])
41+
42+
43+
if __name__ == "__main__":
44+
com = CsvExporter()
45+
o_cvs = com.RunScript(
46+
i_dump,
47+
i_export_dir,
48+
i_values
49+
)
9.56 KB
Loading
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"name": "CsvExporter",
3+
"nickname": "CsvExporter",
4+
"category": "diffCheck",
5+
"subcategory": "Utility",
6+
"description": "Exports distance calculation to csv.",
7+
"exposure": 4,
8+
"instanceGuid": "72ddcab2-af51-42a4-b2b3-4d64602c37e0",
9+
"ghpython": {
10+
"hideOutput": true,
11+
"hideInput": true,
12+
"isAdvancedMode": true,
13+
"marshalOutGuids": true,
14+
"iconDisplay": 2,
15+
"inputParameters": [
16+
{
17+
"name": "i_dump",
18+
"nickname": "i_dump",
19+
"description": "A flag indicating whether to perform the export.",
20+
"optional": true,
21+
"allowTreeAccess": true,
22+
"showTypeHints": true,
23+
"scriptParamAccess": "item",
24+
"wireDisplay": "default",
25+
"sourceCount": 0,
26+
"typeHintID": "bool"
27+
},
28+
{
29+
"name": "i_export_dir",
30+
"nickname": "i_export_dir",
31+
"description": "The directory where the CSV file will be saved.",
32+
"optional": true,
33+
"allowTreeAccess": true,
34+
"showTypeHints": true,
35+
"scriptParamAccess": "item",
36+
"wireDisplay": "default",
37+
"sourceCount": 0,
38+
"typeHintID": "str"
39+
},
40+
{
41+
"name": "i_values",
42+
"nickname": "i_values",
43+
"description": "A list of values to be exported.",
44+
"optional": false,
45+
"allowTreeAccess": true,
46+
"showTypeHints": true,
47+
"scriptParamAccess": "list",
48+
"wireDisplay": "default",
49+
"sourceCount": 0,
50+
"typeHintID": "float"
51+
}
52+
],
53+
"outputParameters": [
54+
{
55+
"name": "o_x_form",
56+
"nickname": "o_x_form",
57+
"description": "The computed transformation.",
58+
"optional": false,
59+
"sourceCount": 0,
60+
"graft": false
61+
}
62+
]
63+
}
64+
}

0 commit comments

Comments
 (0)