Dear All
I would like to share how insert/import Point Cloud in Family Editor.
-
the script must run inside family editor
-
you need Python3 and install Open3d python package
"""
This code write by Ramiz Mohareb
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
point_cloud= np.loadtxt(filepath,skiprows=1)
#Format to open3d usable objects
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(point_cloud[:,:3])
#pcd.colors = o3d.utility.Vector3dVector(point_cloud[:,3:6]/255)
#pcd.normals = o3d.utility.Vector3dVector(point_cloud[:,6:9])
source=pcd.voxel_down_sample(voxel_size=0.01)
OUT =source
"""
This code write by Ramiz Mohareb
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
import copy
#libraries used
import numpy as np
import open3d as o3d
import trimesh
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import matplotlib.pyplot as plt
source = IN[0]
OUT =np.asarray(source.points).tolist()
#This code write by Ramiz Mohareb
# enramiz@yahoo.com
# Enable Python support and load DesignScript library
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import clr
clr.AddReference('RevitAPIUI')
import clr
from System.Collections.Generic import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import Autodesk
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
app = doc.Application
X=IN[0]
Y=IN[1]
Z=IN[2]
t = Transaction(doc, 'create a single reference point')
t.Start()
#define x, y, and z variables
j=0
for item in X:
x=X[j]
y=Y[j]
z=Z[j]
myXYZ = XYZ(x,y,z)
p = doc.FamilyCreate.NewReferencePoint(myXYZ)
#AdaptiveComponentFamilyUtils.MakeAdaptivePoint(doc, p.Id, AdaptivePointType.PlacementPoint)
#p.CoordinatePlaneVisibility = CoordinatePlaneVisibility.Always
j=j+1
#declare a XYZ variable
#use XYZ to define a reference point
t.Commit()
# Place your code below this line
# Assign your output to the OUT variable.
OUT = 0