this post for fun.
in the below dynamo script i convert 3D scane for Nefertiti “the Great Royal Wife of Egyptian pharaoh Akhenaten” to Revit mesh element
"""
This code write by Ramiz Mohareb
25.03.2022
enramiz@yahoo.com
Important! This code will only work with Dynamo versions
that are able to run cPython3 and have the following additional
python packages installed.
Packages required:
numpy
"""
import random
import numpy as np
import clr
import open3d
#libraries used
import numpy as np
import open3d as o3d
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import matplotlib.pyplot as plt
filepath=IN[0]
import numpy as np
import open3d as o3d
filepath=IN[0]
segment_models={}
segments={}
inliers={}
inlier_cloud={}
Outt=[]
Outt2=[]
Outt3=[]
dec_meshL=[]
max_plane_idx=1
pcd = o3d.io.read_point_cloud(filepath)
distances = pcd.compute_nearest_neighbor_distance()
avg_dist = np.mean(distances)
radius = 1 * avg_dist
#computing the mehs
bpa_mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(pcd,o3d.utility.DoubleVector([1*radius, radius*2]))
#dec_mesh1 = bpa_mesh.filter_smooth_simple(number_of_iterations=1)
dec_mesh1 = bpa_mesh.filter_smooth_taubin(number_of_iterations=10)
dec_mesh3=dec_mesh1
dec_mesh3.remove_degenerate_triangles()
dec_mesh3.remove_duplicated_triangles()
dec_mesh3.remove_duplicated_vertices()
dec_mesh3.remove_non_manifold_edges()
# Outt.append(np.asarray(segments[i].Points).tolist())
Outt2.append(np.asarray(dec_mesh3.triangles).tolist())
Outt3.append(np.asarray(dec_mesh3.vertices).tolist())
#o3d.visualization.draw_geometries([segments[i] for i in range(max_plane_idx)]+[rest])
#
OUT = Outt2,Outt3