Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import clr
- clr.AddReference("RevitNodes")
- import Revit
- from Revit.Elements import *
- clr.AddReference('ProtoGeometry')
- clr.AddReference('RevitAPI')
- from Autodesk.Revit.DB import *
- import Autodesk
- from Autodesk.DesignScript.Geometry import *
- clr.AddReference("RevitServices")
- import RevitServices
- from RevitServices.Persistence import DocumentManager
- import sys
- sys.path.append("C:Program Files (x86)IronPython 2.7Lib")
- import os
- import xml.etree.ElementTree as ET
- meterToFeed = 1.0/0.3048
- doc = DocumentManager.Instance.CurrentDBDocument
- projloc = doc.ActiveProjectLocation
- position_data = projloc.ProjectPosition[XYZ.Zero]
- angle = position_data.Angle
- elevation = position_data.Elevation
- easting = position_data.EastWest
- northing = position_data.NorthSouth
- cs_ins = CoordinateSystem.Identity()
- origin = Point.ByCoordinates(easting, northing, elevation);
- cs_rot = CoordinateSystem.Identity().Rotate(Point.ByCoordinates(0, 0),Vector.ByCoordinates(0,0,1),angle)
- cs_geo = CoordinateSystem.ByOriginVectors(origin, cs_rot.XAxis, cs_rot.YAxis, cs_rot.ZAxis)
- XMLDoc = ET.parse(IN[0])
- root = XMLDoc.getroot()
- ns = {'lxml': 'http://www.landxml.org/schema/LandXML-1.2'}
- RevitMeshes = []
- RevitTopos = []
- landXMLSurfaces = root.findall('lxml:Surfaces/lxml:Surface',ns)
- for landXMLSurface in landXMLSurfaces:
- RevitFaces = []
- RevitPoints = []
- out_list = []
- IndexPoints = {}
- landXMLPoints = landXMLSurface.findall('lxml:Definition/lxml:Pnts/lxml:P',ns)
- landXMLFaces = landXMLSurface.findall('lxml:Definition/lxml:Faces/lxml:F',ns)
- i = 0
- for landXMLPoint in landXMLPoints:
- id = int(landXMLPoint.get("id"))
- strPoint = str.split(landXMLPoint.text," ")
- x = float(strPoint[1]) * meterToFeed
- y = float(strPoint[0]) * meterToFeed
- z = float(strPoint[2]) * meterToFeed
- P = Geometry.Transform(Point.ByCoordinates(x, y, z),cs_geo, cs_ins)
- RevitPoints.append(Geometry.Transform(Point.ByCoordinates(x, y, z), cs_geo, cs_ins))
- IndexPoints[id] = i
- i = i + 1
- for landXMLFace in landXMLFaces:
- F = [0,0,0]
- strF = str.split(landXMLFace.text," ")
- F[0] = IndexPoints[int(strF[0])]
- F[1] = IndexPoints[int(strF[1])]
- F[2] = IndexPoints[int(strF[2])]
- RevitFaces.append(IndexGroup.ByIndices(F[0],F[1],F[2]))
- #mesh = Mesh.ByPointsFaceIndices(RevitPoints, RevitFaces)
- #RevitMeshes.append(mesh)
- RevitTopo = Topography.ByPoints(RevitPoints)
- RevitTopos.append(RevitTopo)
- #OUT = RevitMeshes
- #OUT = mesh
- OUT = RevitTopos
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement