public static TBD.Perimeter ToTBD_Perimeter(this Polygon3D polygon3D) { if (polygon3D == null) { return(null); } TBD.Perimeter result = new TBD.Perimeter(); TBD.Polygon polygon = result.CreateFace(); List <Point3D> point3Ds = polygon3D.GetPoints(); if (point3Ds != null) { foreach (Point3D point3D in point3Ds) { if (point3D == null) { continue; } polygon.AddCoordinate(System.Convert.ToSingle(point3D.X), System.Convert.ToSingle(point3D.Y), System.Convert.ToSingle(point3D.Z)); } } return(result); }
public static TBD.Polygon ToTBD(this Polygon3D polygon3D) { if (polygon3D == null) { return(null); } TBD.Polygon result = new TBD.Polygon(); List <Point3D> point3Ds = polygon3D.GetPoints(); if (point3Ds != null) { foreach (Point3D point3D in point3Ds) { if (point3D == null) { continue; } result.AddCoordinate(System.Convert.ToSingle(point3D.X), System.Convert.ToSingle(point3D.Y), System.Convert.ToSingle(point3D.Z)); } } return(result); }
public static Polygon3D Transform(this Transform transform, Polygon3D polygon3D, bool convertUnits = true) { if (transform == null || polygon3D == null) return null; if (transform.IsIdentity) return new Polygon3D(polygon3D); Vector3D normal = polygon3D.GetPlane()?.Normal; if (normal == null) return null; List<Point3D> point3Ds = polygon3D.GetPoints(); if (point3Ds == null) return null; return Spatial.Create.Polygon3D(Transform(transform, normal, convertUnits), Transform(transform, point3Ds, convertUnits)); }
public static Panel ToSAM(this EnergyAnalysisSurface energyAnalysisSurface, Core.Revit.ConvertSettings convertSettings, Shell shell = null, double silverSpacing = Core.Tolerance.MacroDistance, double tolerance = Core.Tolerance.Distance) { if (energyAnalysisSurface == null) { return(null); } Panel result = convertSettings?.GetObject <Panel>(energyAnalysisSurface.Id); if (result != null) { return(result); } Document document = energyAnalysisSurface.Document; Polygon3D polygon3D = energyAnalysisSurface.GetPolyloop().ToSAM(); if (polygon3D == null) { return(null); } if (shell != null) { Geometry.Spatial.Plane plane = polygon3D.GetPlane(); if (plane != null) { Point3D point3D = polygon3D.InternalPoint3D(); if (point3D != null) { Vector3D normal = shell.Normal(polygon3D.InternalPoint3D(), true, silverSpacing, tolerance); if (!normal.SameHalf(plane.AxisZ)) { plane.FlipZ(); polygon3D = new Polygon3D(plane, polygon3D.GetPoints().ConvertAll(x => plane.Convert(x))); } } } } HostObject hostObject = Core.Revit.Query.Element(document, energyAnalysisSurface.CADObjectUniqueId, energyAnalysisSurface.CADLinkUniqueId) as HostObject; if (hostObject == null) { return(new Panel(null, PanelType.Air, new Face3D(polygon3D))); } ElementId elementId_Type = hostObject.GetTypeId(); if (elementId_Type == null || elementId_Type == ElementId.InvalidElementId) { return(null); } PanelType panelType = Query.PanelType(hostObject); Construction construction = ((HostObjAttributes)hostObject.Document.GetElement(elementId_Type)).ToSAM(convertSettings); if (construction == null) { construction = Analytical.Query.DefaultConstruction(panelType); //Default Construction } PanelType panelType_Temp = Query.PanelType(construction); if (panelType_Temp != PanelType.Undefined) { panelType = panelType_Temp; } Face3D face3D = new Face3D(polygon3D); result = new Panel(construction, panelType, face3D); IEnumerable <EnergyAnalysisOpening> energyAnalysisOpenings = energyAnalysisSurface.GetAnalyticalOpenings(); if (energyAnalysisOpenings != null && energyAnalysisOpenings.Count() != 0) { foreach (EnergyAnalysisOpening energyAnalysisOpening in energyAnalysisOpenings) { Aperture aperture = energyAnalysisOpening.ToSAM(convertSettings); if (aperture != null) { result.AddAperture(aperture); } } } result.UpdateParameterSets(energyAnalysisSurface, ActiveSetting.Setting.GetValue <Core.TypeMap>(Core.Revit.ActiveSetting.Name.ParameterMap)); convertSettings?.Add(energyAnalysisSurface.Id, result); return(result); }