99import Grasshopper as gh
1010from Grasshopper .Kernel import GH_RuntimeMessageLevel as RML
1111
12- import diffCheck
1312from diffCheck import diffcheck_bindings
14- import diffCheck .df_geometries
15- import diffCheck .df_cvt_bindings
16-
13+ from diffCheck import df_cvt_bindings
1714
1815class 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 ,
53- i_scalef
54- )
39+ # if __name__ == "__main__":
40+ # com = DFLoadMeshFromFile()
41+ # o_rh_mesh = com.RunScript(i_path, i_scalef)
0 commit comments