Skip to content

Commit 6e301b2

Browse files
committed
FIX code.py for Mesh and PCD Loader
1 parent ec04e06 commit 6e301b2

File tree

8 files changed

+30
-41
lines changed

8 files changed

+30
-41
lines changed

src/gh/components/DF_load_cloud_from_file/code.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,33 @@
99
import Grasshopper as gh
1010
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
1111

12-
import diffCheck
1312
from diffCheck import diffcheck_bindings
14-
import diffCheck.df_cvt_bindings
13+
from diffCheck import df_cvt_bindings
1514

1615
class DFLoadCloudFromFile(component):
1716
def RunScript(self,
1817
i_path: str,
1918
i_scalef: float) -> rg.PointCloud:
2019
"""
21-
Import a cloud from a file and scale it if needed.
20+
This component loads a point cloud from a .ply file.
2221
23-
:param i_path: path to the file
22+
:param i_path: path to the .ply file
2423
:param i_scalef: scale factor
2524
26-
:return o_out: rhino cloud
25+
:return o_rh_cloud: Rhino PointCloud
2726
"""
28-
# import and convert to rhino cloud
27+
# import and convert to Rhino Cloud
2928
df_cloud = diffcheck_bindings.dfb_geometry.DFPointCloud()
3029
df_cloud.load_from_PLY(i_path)
31-
rh_cloud = diffCheck.df_cvt_bindings.cvt_dfcloud_2_rhcloud(df_cloud)
30+
rh_cloud = df_cvt_bindings.cvt_dfcloud_2_rhcloud(df_cloud)
3231

3332
# scale if needed
3433
centroid = rh_cloud.GetBoundingBox(True).Center
3534
x_form_scale = rg.Transform.Scale(centroid, i_scalef)
3635
rh_cloud.Transform(x_form_scale)
37-
38-
return [rh_cloud] # do this to output 'Rhino.Geometry.PointCloud' instead of 'Rhino.Geometry.PointCloudItem'
36+
37+
return [rh_cloud]
38+
39+
if __name__ == "__main__":
40+
com = DFLoadCloudFromFile()
41+
o_rh_cloud = com.RunScript(i_path, i_scalef)

src/gh/components/DF_load_mesh_from_file/code.py

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,33 @@
99
import Grasshopper as gh
1010
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
1111

12-
import diffCheck
1312
from diffCheck import diffcheck_bindings
14-
import diffCheck.df_geometries
15-
import diffCheck.df_cvt_bindings
16-
13+
from diffCheck import df_cvt_bindings
1714

1815
class DFLoadMeshFromFile(component):
1916
def RunScript(self,
20-
i_path : str,
21-
i_scalef : float
22-
) -> rg.PointCloud:
17+
i_path: str,
18+
i_scalef: float) -> rg.Mesh:
2319
"""
24-
This compoonent load a mesh rhino from a ply file.
20+
This compoonent loads a Rhino mesh from a .ply file.
2521
26-
:param i_path: path to the ply file
22+
:param i_path: path to the .ply file
2723
:param i_scalef: scale factor
2824
29-
:return o_mesh: rhino mesh
25+
:return o_mesh: Rhino Mesh
3026
"""
31-
print(f"diffCheck version: {diffCheck.__version__}")
32-
33-
df_cloud = diffcheck_bindings.dfb_geometry.DFPointCloud()
34-
df_cloud.load_from_PLY(i_path)
35-
rgpoints = [rg.Point3d(pt[0], pt[1], pt[2]) for pt in df_cloud.points]
36-
rh_cloud = rg.PointCloud(rgpoints)
27+
# import and convert to Rhino Mesh
28+
df_mesh = diffcheck_bindings.dfb_geometry.DFMesh()
29+
df_mesh.load_from_PLY(i_path)
30+
rh_mesh = df_cvt_bindings.cvt_dfmesh_2_rhmesh(df_mesh)
3731

3832
# scale if needed
39-
centroid = rh_cloud.GetBoundingBox(True).Center
33+
centroid = rh_mesh.GetBoundingBox(True).Center
4034
x_form_scale = rg.Transform.Scale(centroid, i_scalef)
41-
rh_cloud.Transform(x_form_scale)
42-
43-
44-
rh_mesh = rh_cloud
45-
46-
return rh_mesh
35+
rh_mesh.Transform(x_form_scale)
4736

37+
return [rh_mesh]
4838

49-
# if __name__ == "__main__":
50-
# com = DFLoadMeshFromFile()
51-
# o_rh_mesh = com.RunScript(
52-
# i_path,n
53-
# i_scalef
54-
# )
39+
if __name__ == "__main__":
40+
com = DFLoadMeshFromFile()
41+
o_rh_mesh = com.RunScript(i_path, i_scalef)

src/gh/diffCheck/diffCheck.egg-info/PKG-INFO

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ Summary: DiffCheck is a package to check the differences between two timber stru
55
Home-page: https://github.com/diffCheckOrg/diffCheck
66
Author: Andrea Settimi, Damien Gilliard, Eleni Skevaki, Marirena Kladeftira, Julien Gamerro, Stefana Parascho, and Yves Weinand
77
Author-email: andrea.settimi@epfl.ch
8-
License: UNKNOWN
9-
Platform: UNKNOWN
108
Classifier: License :: OSI Approved :: MIT License
119
Classifier: Programming Language :: Python :: 3
1210
Classifier: Programming Language :: Python :: 3.9
1311
Description-Content-Type: text/markdown
12+
Requires-Dist: numpy
13+
Requires-Dist: pybind11>=2.5.0
1414

1515
# DiffCheck Grasshopper Plugin
1616

1717
DiffCheck is a plugin for Rhino/Grasshopper that allows the user to compare a 3D model with its scan.
1818

1919
More information to come
20-
31 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
31 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)