Nefertiti Bust Revit element

Hello Dynamo user

this post for fun. :partying_face: :partying_face: :partying_face: :partying_face: :partying_face:
in the below dynamo script i convert 3D scane for Nefertiti “the Great Royal Wife of Egyptian pharaoh Akhenaten” to Revit mesh element

3D scane download from the below link.

Used unsupervised ML (open3d)
http://www.open3d.org/
nefertity.dyn (56.8 KB)

"""
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




10 Likes

Out of my curiosity, here is a variant that draws mesh triangles (surfaces) only in Dynamo
nearly 96,000 surfaces to display, my laptop suffered a bit :sweat_smile:

"""
original author Ramiz Mohareb modify by Cyril Poupin
25.03.2022
enramiz@yahoo.com
"""
import clr
import sys
import re
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

reDir = System.IO.DirectoryInfo(re.__file__)
path_py3_lib = reDir.Parent.Parent.FullName
sys.path.append(path_py3_lib + r'\Lib\site-packages')
import random
import numpy as np
import numpy as np
import open3d as o3d
import matplotlib.pyplot as plt


def computePoint(a):
    if np.isnan(a[0]):
        return None
    else:
        return Point.ByCoordinates(a[0], a[1], a[2])

def computeTriangleSurface(a, DS_ptarr):
    lstPt = [DS_ptarr[a[i]] for i in range(3)]
    if all(isinstance(x, Point) for x in lstPt):
        try:
            return Surface.ByPerimeterPoints(lstPt)
        except:
            return None
    else:
        return None

filepath=IN[0]

pcd = o3d.io.read_point_cloud(filepath)
distances = pcd.compute_nearest_neighbor_distance()
avg_dist = np.mean(distances)
radius = 1.5 * avg_dist

#computing the mehs
bpa_mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(pcd,o3d.utility.DoubleVector([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_mesh1 = bpa_mesh.simplify_quadric_decimation(100000)

dec_mesh1.remove_degenerate_triangles()
dec_mesh1.remove_duplicated_triangles()
dec_mesh1.remove_duplicated_vertices()
dec_mesh1.remove_non_manifold_edges()

arr_vertices = np.array(dec_mesh1.vertices)
arr_triangles = np.array(dec_mesh1.triangles)
DS_ptarr = np.apply_along_axis(computePoint, 1, arr_vertices)
DS_surface_arr = np.apply_along_axis(computeTriangleSurface, 1, arr_triangles, DS_ptarr)
#
OUT = DS_surface_arr

download and rename nefertiti_HQ2.txt to nefertiti_HQ2.ply
nefertiti_HQ2.txt (6.2 MB)

2 Likes

If you ever want to look good as BIM model manager hide one of these in the file, then do an audit and remove it. What a performance improvement!

1 Like

Nice, i alway Clear point and surface cloud use CloudCompare before import to revit use rcs format or modify in recap pro, let explode :sweat_smile: ,


image

3 Likes