- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Greetings to all, I want to let you know a small issue I am facing when writing a set of points from a pointcloud into a text file, performing some operations between them, and later when I'm reading this data and placing some generic models at their location, the items appear close to the location they are suppose to be but not at the exact position.
1°Script to export the set of points projected onto the XY plane
"1) get the point cloud instance"
ptCloud=doc.GetElement(ElementId(297061))
bb=ptCloud.get_BoundingBox(doc.ActiveView)
planes=[]
"2) Get the points that visible fromt he active view"
#X boundaries
planes.append(Plane.CreateByNormalAndOrigin(XYZ.BasisX,bb.Min))
planes.append(Plane.CreateByNormalAndOrigin(-XYZ.BasisX,bb.Max))
#Y boundaries
planes.append(Plane.CreateByNormalAndOrigin(XYZ.BasisY,bb.Min))
planes.append(Plane.CreateByNormalAndOrigin(-XYZ.BasisY,bb.Max))
#Z boundaries
planes.append(Plane.CreateByNormalAndOrigin(XYZ.BasisZ,bb.Min))
planes.append(Plane.CreateByNormalAndOrigin(-XYZ.BasisZ,bb.Max))
filter=PointClouds.PointCloudFilterFactory.CreateMultiPlaneFilter(planes)
points=ptCloud.GetPoints(filter,0.001,999999) #Enumerator
OUT= points.Count
pointList=[]
for pt in points:
pointList.append(XYZ(pt.X,pt.Y,0))
import System
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import OpenFileDialog, SaveFileDialog
"3). Create a new Text File and get its path: SaveFileDialog()"
dialogSave=System.Windows.Forms.SaveFileDialog()
dialogSave.Filter="File TXT|*.txt" #dialog.Filter="Archivos TXT|*.txt |Archivos CSV|*.csv"
dialogSave.Title= "Select a Text file"
dialogSave.OverwritePrompt= False #You are not overwritting a new file because it is just new!
result =dialogSave.ShowDialog()
if result== System.Windows.Forms.DialogResult.Cancel: #In case you choose to not open any file, Let the system know to do nothing
pass
#3.1) Write the data:
string=[]
#string.append("Xcoord,Ycoord,Zcoord")
for i in range(0,len(pointList),1):
a=str(i) + "," + str(pointList[i][0])+","+str(pointList[i][1]) +","+str(pointList[i][2])
string.append(a)
path=dialogSave.FileName
"4) A Method to write data"
System.IO.File.WriteAllLines(path,string,System.Text.Encoding.UTF8)
2°Script to get the boundary by using alphashape algorithm
...Using Open3D library among others...
3°Importing the data into Revit
"2) 1°method to Read the file "
list=System.IO.File.ReadAllLines(path) #read all the lines and keeps it in a list
"2)Place ball element"
boundaryCoord=[]
for line in list:
listI=map(lambda X: float(X)*3.28084,line.split(","))
boundaryCoord.append(listI)
famylies=FilteredElementCollector(doc).OfClass(FamilySymbol).ToElements()
ball=None
for f in famylies:
if f.get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM).AsString() == "ballXYZ":
ball=f
tr=Transaction(doc,"placing families")
tr.Start()
for coord in boundaryCoord:
Loc=XYZ(coord[0],coord[1],0)
doc.Create.NewFamilyInstance(Loc,ball,StructuralType.NonStructural)
tr.Commit()
4). Here is the deviation between the boundaries.
The same deal occurred in a previous task that has to be with surface reconstruction. The mesh was placed 30 feet away from the original point cloud data (PCD) location.
We do also deployed the ConvertToInternalUnits method at step (3) to perform units conversion. Any thoughts on this one that heads me into the right direction to import my data correctly?
Best Regards,
Miguel G.
Solved! Go to Solution.