Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. import clr
  2.  
  3. clr.AddReference("RevitNodes")
  4. import Revit
  5.  
  6. from Revit.Elements import *
  7.  
  8. clr.AddReference('ProtoGeometry')
  9.  
  10. clr.AddReference('RevitAPI')
  11. from Autodesk.Revit.DB import *
  12. import Autodesk
  13. from Autodesk.DesignScript.Geometry import *
  14.  
  15. clr.AddReference("RevitServices")
  16. import RevitServices
  17. from RevitServices.Persistence import DocumentManager
  18.  
  19. import sys
  20.  
  21. sys.path.append("C:Program Files (x86)IronPython 2.7Lib")
  22. import os
  23. import xml.etree.ElementTree as ET
  24.  
  25.  
  26. meterToFeed = 1.0/0.3048
  27.  
  28. doc = DocumentManager.Instance.CurrentDBDocument
  29. projloc = doc.ActiveProjectLocation
  30. position_data = projloc.ProjectPosition[XYZ.Zero]
  31. angle = position_data.Angle
  32. elevation = position_data.Elevation
  33. easting = position_data.EastWest
  34. northing = position_data.NorthSouth
  35.  
  36.  
  37. cs_ins = CoordinateSystem.Identity()
  38. origin = Point.ByCoordinates(easting, northing, elevation);
  39.  
  40. cs_rot = CoordinateSystem.Identity().Rotate(Point.ByCoordinates(0, 0),Vector.ByCoordinates(0,0,1),angle)
  41.  
  42. cs_geo = CoordinateSystem.ByOriginVectors(origin, cs_rot.XAxis, cs_rot.YAxis, cs_rot.ZAxis)
  43.  
  44. XMLDoc = ET.parse(IN[0])
  45. root = XMLDoc.getroot()
  46.  
  47. ns = {'lxml': 'http://www.landxml.org/schema/LandXML-1.2'}
  48.  
  49. RevitMeshes = []
  50. RevitTopos = []
  51.  
  52. landXMLSurfaces = root.findall('lxml:Surfaces/lxml:Surface',ns)
  53. for landXMLSurface in landXMLSurfaces:
  54. RevitFaces = []
  55. RevitPoints = []
  56. out_list = []
  57. IndexPoints = {}
  58.  
  59. landXMLPoints = landXMLSurface.findall('lxml:Definition/lxml:Pnts/lxml:P',ns)
  60. landXMLFaces = landXMLSurface.findall('lxml:Definition/lxml:Faces/lxml:F',ns)
  61.  
  62. i = 0
  63.  
  64. for landXMLPoint in landXMLPoints:
  65. id = int(landXMLPoint.get("id"))
  66. strPoint = str.split(landXMLPoint.text," ")
  67. x = float(strPoint[1]) * meterToFeed
  68. y = float(strPoint[0]) * meterToFeed
  69. z = float(strPoint[2]) * meterToFeed
  70.  
  71. P = Geometry.Transform(Point.ByCoordinates(x, y, z),cs_geo, cs_ins)
  72.  
  73. RevitPoints.append(Geometry.Transform(Point.ByCoordinates(x, y, z), cs_geo, cs_ins))
  74. IndexPoints[id] = i
  75. i = i + 1
  76.  
  77. for landXMLFace in landXMLFaces:
  78. F = [0,0,0]
  79. strF = str.split(landXMLFace.text," ")
  80. F[0] = IndexPoints[int(strF[0])]
  81. F[1] = IndexPoints[int(strF[1])]
  82. F[2] = IndexPoints[int(strF[2])]
  83.  
  84. RevitFaces.append(IndexGroup.ByIndices(F[0],F[1],F[2]))
  85.  
  86. #mesh = Mesh.ByPointsFaceIndices(RevitPoints, RevitFaces)
  87. #RevitMeshes.append(mesh)
  88. RevitTopo = Topography.ByPoints(RevitPoints)
  89. RevitTopos.append(RevitTopo)
  90. #OUT = RevitMeshes
  91. #OUT = mesh
  92. OUT = RevitTopos
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement