public JObject ConvertToDTO(Autodesk.Revit.DB.Wall source) { Autodesk.Revit.DB.Curve curve = (source.Location as LocationCurve).Curve; Autodesk.Revit.DB.Line line = curve as Autodesk.Revit.DB.Line; if (line == null) { return(null); } BoundingBoxXYZ bb = source.get_BoundingBox(null); Autodesk.Revit.DB.XYZ origin = line.Tessellate().First(); Autodesk.Revit.DB.XYZ endpoint = line.Tessellate().Last(); /// origin + line.Direction * line.Length; List <LMAStudio.StreamVR.Common.Models.Face> wallFaces = new List <LMAStudio.StreamVR.Common.Models.Face>(); Autodesk.Revit.DB.GeometryElement defaultGeometry = source.get_Geometry(new Options()); if (defaultGeometry != null) { Solid solidGeometry = defaultGeometry.FirstOrDefault() as Solid; if (solidGeometry != null) { wallFaces = GeometryConversion.ConvertToDTO(source, solidGeometry); } } LMAStudio.StreamVR.Common.Models.Wall dest = new LMAStudio.StreamVR.Common.Models.Wall { Id = source.Id.ToString(), Name = source.Name, Depth = source.Width, Orientation = new LMAStudio.StreamVR.Common.Models.XYZ { X = source.Orientation.X, Y = source.Orientation.Y, Z = source.Orientation.Z, }, Endpoint0 = new LMAStudio.StreamVR.Common.Models.XYZ { X = origin.X, Y = origin.Y, Z = bb.Min.Z, }, Endpoint1 = new LMAStudio.StreamVR.Common.Models.XYZ { X = endpoint.X, Y = endpoint.Y, Z = bb.Max.Z, }, Faces = wallFaces }; return(JObject.FromObject(dest)); }
public void MapFromDTO(JObject sourceJSON, Autodesk.Revit.DB.Wall dest) { LMAStudio.StreamVR.Common.Models.Wall source = sourceJSON.ToObject <LMAStudio.StreamVR.Common.Models.Wall>(); LocationCurve curve = (dest.Location) as LocationCurve; curve.Curve = Line.CreateBound( new Autodesk.Revit.DB.XYZ( source.Endpoint0.X, source.Endpoint0.Y, source.Endpoint0.Z ), new Autodesk.Revit.DB.XYZ( source.Endpoint1.X, source.Endpoint1.Y, source.Endpoint1.Z ) ); }