/// <summary> /// Exports a curtain system to IFC curtain system. /// </summary> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="hostElement"> /// The curtain system element to be exported. /// </param> /// <param name="productWrapper"> /// The IFCProductWrapper. /// </param> public static void ExportCurtainSystem(ExporterIFC exporterIFC, CurtainSystem curtainSystem, IFCProductWrapper productWrapper) { CurtainGridSet grids = curtainSystem.CurtainGrids; if (grids == null || grids.Size == 0) { return; } ICollection <ElementId> allSubElements = new HashSet <ElementId>(); foreach (CurtainGrid grid in grids) { foreach (ElementId panelId in grid.GetPanelIds()) { allSubElements.Add(panelId); } foreach (ElementId subElem in grid.GetMullionIds()) { allSubElements.Add(subElem); } } IFCFile file = exporterIFC.GetFile(); using (IFCTransaction transaction = new IFCTransaction(file)) { ExportBase(exporterIFC, allSubElements, curtainSystem, productWrapper); transaction.Commit(); } }
public static CurtainCell CurtainCell(this CurtainSystem curtainSystem, ElementId uGridLineElementId, ElementId vGridLineElementId) { if (uGridLineElementId == null || uGridLineElementId == ElementId.InvalidElementId || vGridLineElementId == null || vGridLineElementId == ElementId.InvalidElementId) { return(null); } CurtainGridSet curtainGridSet = curtainSystem?.CurtainGrids; if (curtainGridSet == null) { return(null); } foreach (CurtainGrid curtainGrid in curtainGridSet) { CurtainCell result = curtainGrid.GetCell(uGridLineElementId, vGridLineElementId); if (result != null) { return(result); } } return(null); }
/// <summary> /// Provides a unified interface to get the curtain grids associated with an element. /// </summary> /// <param name="element">The host element.</param> /// <returns>A CurtainGridSet with 0 or more CurtainGrids, or null if invalid.</returns> public static CurtainGridSet GetCurtainGridSet(Element element) { CurtainGridSet curtainGridSet = null; if (element is Wall) { Wall wall = element as Wall; if (!CurtainSystemExporter.IsLegacyCurtainWall(wall)) { CurtainGrid curtainGrid = wall.CurtainGrid; curtainGridSet = new CurtainGridSet(); if (curtainGrid != null) { curtainGridSet.Insert(curtainGrid); } } } else if (element is FootPrintRoof) { FootPrintRoof footPrintRoof = element as FootPrintRoof; curtainGridSet = footPrintRoof.CurtainGrids; } else if (element is ExtrusionRoof) { ExtrusionRoof extrusionRoof = element as ExtrusionRoof; curtainGridSet = extrusionRoof.CurtainGrids; } else if (element is CurtainSystem) { CurtainSystem curtainSystem = element as CurtainSystem; curtainGridSet = curtainSystem.CurtainGrids; } return(curtainGridSet); }
CurtainSystemToWireframe() { if (m_revitApp.ActiveUIDocument.Selection.GetElementIds().Count == 0) { MessageBox.Show("Please select elements and re-run test.", "No Elements Selected", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } GraphicsStreamRevit grStream = new GraphicsStreamRevit(m_revitApp); grStream.PushView(m_revitApp.ActiveUIDocument.Document.ActiveView); Options opts = m_revitApp.Application.Create.NewGeometryOptions(); opts.ComputeReferences = true; opts.View = m_revitApp.ActiveUIDocument.Document.ActiveView; grStream.PushGeometryOptions(opts); // transform everything by 50 in both the X and Y axes Transform xform = new Transform(Transform.Identity); xform.Origin = new XYZ(50.0, 50.0, 0.0); grStream.PushXform(xform); Document dbDoc = m_revitApp.ActiveUIDocument.Document; var selElementIds = m_revitApp.ActiveUIDocument.Selection.GetElementIds(); foreach (ElementId elemId in selElementIds) { Element elem = dbDoc.GetElement(elemId); if (elem is Wall) { Wall wall = elem as Wall; if (wall.WallType.Kind == WallKind.Curtain) { WriteCurtainCells(wall.CurtainGrid, grStream); // call same function for each } } else if (elem is ExtrusionRoof) { ExtrusionRoof roof = elem as ExtrusionRoof; foreach (CurtainGrid grid in roof.CurtainGrids) { WriteCurtainCells(grid, grStream); } } else if (elem is CurtainSystem) { CurtainSystem curtSys = elem as CurtainSystem; foreach (CurtainGrid grid in curtSys.CurtainGrids) { WriteCurtainCells(grid, grStream); } } } }
/// <summary> /// Exports a curtain system to IFC curtain system. /// </summary> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="hostElement"> /// The curtain system element to be exported. /// </param> /// <param name="productWrapper"> /// The ProductWrapper. /// </param> public static void ExportCurtainSystem(ExporterIFC exporterIFC, CurtainSystem curtainSystem, ProductWrapper productWrapper) { IFCFile file = exporterIFC.GetFile(); using (IFCTransaction transaction = new IFCTransaction(file)) { ExportBaseWithGrids(exporterIFC, curtainSystem, productWrapper); transaction.Commit(); } }
/***************************************************/ public static List <CurtainGrid> CurtainGrids(this CurtainSystem curtainSystem) { List <CurtainGrid> result = new List <CurtainGrid>(); if (curtainSystem.CurtainGrids != null) { foreach (CurtainGrid cg in curtainSystem.CurtainGrids) { result.Add(cg); } } return(result); }
/// <summary> /// Exports a curtain system to IFC curtain system. /// </summary> /// <param name="exporterIFC">The ExporterIFC object.</param> /// <param name="hostElement">The curtain system element to be exported.</param> /// <param name="productWrapper">The ProductWrapper.</param> public static void ExportCurtainSystem(ExporterIFC exporterIFC, CurtainSystem curtainSystem, ProductWrapper productWrapper) { // Check the intended IFC entity or type name is in the exclude list specified in the UI Common.Enums.IFCEntityType elementClassTypeEnum = Common.Enums.IFCEntityType.IfcCurtainWall; if (ExporterCacheManager.ExportOptionsCache.IsElementInExcludeList(elementClassTypeEnum)) { return; } IFCFile file = exporterIFC.GetFile(); using (IFCTransaction transaction = new IFCTransaction(file)) { ExportBaseWithGrids(exporterIFC, curtainSystem, productWrapper); transaction.Commit(); } }
public void Create_Valid() { CurtainSystemType type = CurtainSystemType.ByName("5' x 10'"); Assert.NotNull(type); var mass = Revit.Elements.ElementSelector.ByElementId(205302); Assert.NotNull(mass); var system = CurtainSystem.ByFace(mass.Faces.ElementAt(0), type); Assert.NotNull(system); Assert.NotNull(system.Faces); Assert.NotNull(system.InternalCurtainSystem); }
public static List <Panel> Panels(this CurtainSystem curtainSystem) { CurtainGridSet curtainGridSet = curtainSystem?.CurtainGrids; if (curtainGridSet == null) { return(null); } List <Panel> result = new List <Panel>(); foreach (CurtainGrid curtainGrid in curtainGridSet) { List <Panel> panels = Panels(curtainSystem.Document, curtainGrid); if (panels != null && panels.Count != 0) { result.AddRange(panels); } } return(result); }
/// <summary> /// Exports a curtain system to IFC curtain system. /// </summary> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="hostElement"> /// The curtain system element to be exported. /// </param> /// <param name="productWrapper"> /// The IFCProductWrapper. /// </param> public static void ExportCurtainSystem(ExporterIFC exporterIFC, CurtainSystem curtainSystem, IFCProductWrapper productWrapper) { CurtainGridSet grids = curtainSystem.CurtainGrids; if (grids == null || grids.Size == 0) return; ICollection<ElementId> allSubElements = new HashSet<ElementId>(); foreach (CurtainGrid grid in grids) { foreach (ElementId panelId in grid.GetPanelIds()) allSubElements.Add(panelId); foreach (ElementId subElem in grid.GetMullionIds()) allSubElements.Add(subElem); } IFCFile file = exporterIFC.GetFile(); using (IFCTransaction transaction = new IFCTransaction(file)) { ExportBase(exporterIFC, allSubElements, curtainSystem, productWrapper); transaction.Commit(); } }
protected GCWallCurtain(CurtainSystem elem) : base(elem) { }
private void Stream( ArrayList data, CurtainSystem curtainSys ) { data.Add( new Snoop.Data.ClassSeparator( typeof( CurtainSystem ) ) ); data.Add( new Snoop.Data.Enumerable( "Curtain grids", curtainSys.CurtainGrids ) ); data.Add( new Snoop.Data.Object( "Curtain system type", curtainSys.CurtainSystemType ) ); }
private static List <Face3D> Profiles_CurtainSystem(this CurtainSystem curtainSystem) { Document document = curtainSystem?.Document; if (document == null) { return(null); } CurtainGridSet curtainGridSet = curtainSystem?.CurtainGrids; if (curtainGridSet == null) { return(null); } List <Face3D> result = new List <Face3D>(); foreach (CurtainGrid curtainGrid in curtainGridSet) { IEnumerable <CurtainCell> curtainCells = curtainGrid.GetCurtainCells(); if (curtainCells == null || curtainCells.Count() == 0) { continue; } List <CurveArrArray> curveArrArrays = new List <CurveArrArray>(); foreach (CurtainCell curtainCell in curtainCells) { CurveArrArray curveArrArray = curtainCell?.PlanarizedCurveLoops; if (curveArrArray == null || curveArrArray.Size == 0) { continue; } curveArrArrays.Add(curveArrArray); } List <Segment3D> segment3Ds = new List <Segment3D>(); List <ISegmentable3D> segmentable3Ds_U = new List <ISegmentable3D>(); List <ISegmentable3D> segmentable3Ds_V = new List <ISegmentable3D>(); ICollection <ElementId> elementIds = null; elementIds = curtainGrid.GetUGridLineIds(); if (elementIds != null) { foreach (ElementId elementId in elementIds) { CurtainGridLine curtainGridLine = document.GetElement(elementId) as CurtainGridLine; if (curtainGridLine == null) { continue; } ISegmentable3D segmentable3D = curtainGridLine.FullCurve.ToSAM() as ISegmentable3D; if (segmentable3D == null) { continue; } segmentable3Ds_U.Add(segmentable3D); segment3Ds.AddRange(segmentable3D.GetSegments()); } } elementIds = curtainGrid.GetVGridLineIds(); if (elementIds != null) { foreach (ElementId elementId in elementIds) { CurtainGridLine curtainGridLine = document.GetElement(elementId) as CurtainGridLine; if (curtainGridLine == null) { continue; } ISegmentable3D segmentable3D = curtainGridLine.FullCurve.ToSAM() as ISegmentable3D; if (segmentable3D == null) { continue; } segmentable3Ds_V.Add(segmentable3D); segment3Ds.AddRange(segmentable3D.GetSegments()); } } List <ISegmentable3D> segmentable3Ds = null; segmentable3Ds = ExtremeSegmentable3Ds(segmentable3Ds_U, segmentable3Ds_V); if (segmentable3Ds != null && segmentable3Ds.Count > 0) { foreach (ISegmentable3D segmentable3D in segmentable3Ds) { List <Segment3D> segment3Ds_Temp = segmentable3D?.GetSegments(); if (segment3Ds_Temp != null && segment3Ds_Temp.Count != 0) { segment3Ds.AddRange(segment3Ds_Temp); } } } segmentable3Ds = ExtremeSegmentable3Ds(segmentable3Ds_V, segmentable3Ds_U); if (segmentable3Ds != null && segmentable3Ds.Count > 0) { foreach (ISegmentable3D segmentable3D in segmentable3Ds) { List <Segment3D> segment3Ds_Temp = segmentable3D?.GetSegments(); if (segment3Ds_Temp != null && segment3Ds_Temp.Count != 0) { segment3Ds.AddRange(segment3Ds_Temp); } } } List <List <Face3D> > face3Ds = Enumerable.Repeat <List <Face3D> >(null, curveArrArrays.Count).ToList(); Parallel.For(0, curveArrArrays.Count, (int i) => { CurveArrArray curveArrArray = curveArrArrays[i]; if (curveArrArray == null || curveArrArray.Size == 0) { return; } face3Ds[i] = new List <Face3D>(); foreach (CurveArray curveArray in curveArrArray) { Polygon3D polygon3D = curveArray?.ToSAM_Polygon3D(); if (polygon3D == null && !polygon3D.IsValid()) { continue; } Spatial.Plane plane = polygon3D.GetPlane(); if (plane == null) { continue; } Polygon2D polygon2D = plane.Convert(polygon3D); if (polygon2D != null) { List <Segment2D> segment2Ds = segment3Ds.ConvertAll(x => plane.Convert(plane.Project(x))); segment2Ds.RemoveAll(x => x == null || x.GetLength() < Core.Tolerance.MacroDistance); segment2Ds = segment2Ds.Split(); List <Polygon2D> polygon2Ds = Planar.Create.Polygon2Ds(segment2Ds); if (polygon2Ds != null) { polygon2Ds = polygon2Ds.FindAll(x => x.Inside(polygon2D)); if (polygon2Ds != null && polygon2Ds.Count > 0) { polygon2Ds.Sort((x, y) => y.GetArea().CompareTo(x.GetArea())); polygon3D = plane.Convert(polygon2Ds[0]); } } } face3Ds[i].Add(new Face3D(polygon3D)); } }); foreach (List <Face3D> face3Ds_Temp in face3Ds) { if (face3Ds_Temp != null && face3Ds_Temp.Count > 0) { result.AddRange(face3Ds_Temp); } } } return(result); }
protected AGCWallBase(CurtainSystem elem) : base(elem) { }
public static List <Aperture> ToSAM_Apertures(this FamilyInstance familyInstance, ConvertSettings convertSettings) { if (familyInstance == null) { return(null); } List <Aperture> result = convertSettings?.GetObjects <Aperture>(familyInstance.Id); if (result != null) { return(result); } if (Core.Revit.Query.Simplified(familyInstance)) { result = Core.Revit.Query.IJSAMObjects <Aperture>(familyInstance); if (result != null) { convertSettings?.Add(familyInstance.Id, result); return(result); } } Point3D point3D_Location = Geometry.Revit.Query.LocationPoint3D(familyInstance); if (point3D_Location == null) { List <Solid> solids = Core.Revit.Query.Solids(familyInstance, new Options()); solids?.RemoveAll(x => x.Volume == 0); if (solids == null || solids.Count == 0) { return(null); } if (solids.Count > 1) { solids.Sort((x, y) => y.Volume.CompareTo(x.Volume)); } point3D_Location = solids[0].ComputeCentroid()?.ToSAM(); } if (point3D_Location == null) { return(null); } List <Face3D> face3Ds = null; PanelType panelType_Host = PanelType.Undefined; BuiltInCategory builtInCategory_Host = BuiltInCategory.INVALID; HostObject hostObject = null; if (familyInstance.Host != null) { hostObject = familyInstance.Host as HostObject; if (hostObject != null) { builtInCategory_Host = (BuiltInCategory)hostObject.Category.Id.IntegerValue; } } //Method 1 of extracting Geometry if (face3Ds == null || face3Ds.Count == 0) { Vector3D axisX = null; Vector3D normal = null; Vector3D axisY = null; if (builtInCategory_Host == BuiltInCategory.OST_Roofs) { axisX = familyInstance.HandOrientation.ToSAM_Vector3D(false); axisY = familyInstance.FacingOrientation.ToSAM_Vector3D(false); normal = Geometry.Spatial.Query.AxisY(axisY, axisX); } else { axisX = familyInstance.HandOrientation.ToSAM_Vector3D(false); normal = familyInstance.FacingOrientation.ToSAM_Vector3D(false); axisY = Geometry.Spatial.Query.AxisY(normal, axisX); } Geometry.Spatial.Plane plane = Geometry.Spatial.Create.Plane(point3D_Location, axisX, axisY); if (!plane.Normal.SameHalf(normal)) { plane.FlipZ(false); } List <Shell> shells = Geometry.Revit.Convert.ToSAM_Geometries <Shell>(familyInstance); if (shells == null || shells.Count == 0) { return(null); } List <Point2D> point2Ds = new List <Point2D>(); foreach (Shell shell in shells) { List <Face3D> face3Ds_Shell = shell?.Face3Ds; if (face3Ds_Shell == null || face3Ds_Shell.Count == 0) { continue; } foreach (Face3D face3D_Temp in face3Ds_Shell) { ISegmentable3D segmentable3D = face3D_Temp.GetExternalEdge3D() as ISegmentable3D; if (segmentable3D == null) { continue; } segmentable3D?.GetPoints()?.ForEach(x => point2Ds.Add(plane.Convert(x))); } } Face3D face3D = new Face3D(plane, Geometry.Planar.Create.Rectangle2D(point2Ds)); if (face3D != null && face3D.IsValid() && face3D.GetArea() > Core.Tolerance.MacroDistance) { face3Ds = new List <Face3D>() { face3D }; } } //Method 2 of extracting Geometry if (hostObject != null) { builtInCategory_Host = (BuiltInCategory)hostObject.Category.Id.IntegerValue; Geometry.Spatial.Plane plane_Host = null; if (hostObject is CurtainSystem && familyInstance is Autodesk.Revit.DB.Panel) { Autodesk.Revit.DB.Panel panel = (Autodesk.Revit.DB.Panel)familyInstance; ElementId uGridLineElementId = null; ElementId vGridLineElementId = null; panel.GetRefGridLines(ref uGridLineElementId, ref vGridLineElementId); CurtainSystem curtainSystem = (CurtainSystem)hostObject; List <Polygon3D> polygon3Ds = curtainSystem.CurtainCell(uGridLineElementId, vGridLineElementId)?.Polygon3Ds(); if (polygon3Ds != null && polygon3Ds.Count != 0) { polygon3Ds.Sort((x, y) => y.GetArea().CompareTo(x.GetArea())); plane_Host = polygon3Ds[0].GetPlane(); } } else { List <Face3D> face3Ds_Temp = hostObject.Profiles(); if (face3Ds_Temp != null && face3Ds_Temp.Count != 0) { plane_Host = face3Ds_Temp.Closest(point3D_Location)?.GetPlane(); } } if (plane_Host != null) { face3Ds = face3Ds?.ConvertAll(x => plane_Host.Project(x)); point3D_Location = plane_Host.Project(point3D_Location); } HostObjAttributes hostObjAttributes = familyInstance.Document.GetElement(hostObject.GetTypeId()) as HostObjAttributes; if (hostObjAttributes != null) { panelType_Host = hostObjAttributes.PanelType(); } if (panelType_Host == PanelType.Undefined) { panelType_Host = hostObject.PanelType(); } List <Face3D> face3Ds_Profiles = hostObject.Profiles(familyInstance.Id); face3Ds_Profiles?.RemoveAll(x => x == null || !x.IsValid()); if (face3Ds_Profiles != null && face3Ds_Profiles.Count > 0) { if (face3Ds == null || (face3Ds != null && face3Ds_Profiles.ConvertAll(x => x.GetArea()).Sum() <= face3Ds.ConvertAll(x => x.GetArea()).Sum())) { face3Ds = face3Ds_Profiles; } } } ApertureConstruction apertureConstruction = ToSAM_ApertureConstruction(familyInstance, convertSettings); if (apertureConstruction == null && panelType_Host != PanelType.Undefined) { apertureConstruction = Analytical.Query.DefaultApertureConstruction(panelType_Host, familyInstance.ApertureType()); //Default Aperture Construction } if (face3Ds == null || face3Ds.Count == 0) { return(result); } //TODO: Working on SAM Families (requested by Michal) string parameterName_Height = Core.Revit.Query.Name(ActiveSetting.Setting, typeof(Aperture), typeof(FamilyInstance), "GetHeight"); string parameterName_Width = Core.Revit.Query.Name(ActiveSetting.Setting, typeof(Aperture), typeof(FamilyInstance), "GetWidth"); if (!string.IsNullOrWhiteSpace(parameterName_Height) && !string.IsNullOrWhiteSpace(parameterName_Width)) { Parameter parameter_Height = familyInstance.LookupParameter(parameterName_Height); Parameter parameter_Width = familyInstance.LookupParameter(parameterName_Width); if (parameter_Height != null && parameter_Width != null && parameter_Height.HasValue && parameter_Width.HasValue && parameter_Height.StorageType == StorageType.Double && parameter_Width.StorageType == StorageType.Double) { #if Revit2017 || Revit2018 || Revit2019 || Revit2020 double height = UnitUtils.ConvertFromInternalUnits(parameter_Height.AsDouble(), DisplayUnitType.DUT_METERS); double width = UnitUtils.ConvertFromInternalUnits(parameter_Width.AsDouble(), DisplayUnitType.DUT_METERS); #else double height = UnitUtils.ConvertFromInternalUnits(parameter_Height.AsDouble(), UnitTypeId.Meters); double width = UnitUtils.ConvertFromInternalUnits(parameter_Width.AsDouble(), UnitTypeId.Meters); #endif } } result = new List <Aperture>(); foreach (Face3D face3D_Temp in face3Ds) { Aperture aperture = Analytical.Create.Aperture(apertureConstruction, face3D_Temp); if (aperture == null) { continue; } aperture.UpdateParameterSets(familyInstance, ActiveSetting.Setting.GetValue <Core.TypeMap>(Core.Revit.ActiveSetting.Name.ParameterMap)); result.Add(aperture); } convertSettings?.Add(familyInstance.Id, result); return(result); }
/// <summary> /// Creates a new CurtainSystem. /// </summary> /// <param name="doc"></param> /// <param name="app"></param> /// <param name="parm"></param> public static CurtainSystem CreateCurtainSystemWithTrans(this Document doc, Application app, CurtainSystemParameter parm) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } if (app == null) { throw new NullReferenceException(nameof(app)); } if (parm == null) { throw new NullReferenceException(nameof(parm)); } var wline = parm.RefWall.GetLocationCurve() as Line; var wdir = wline.GetLineDirection(parm.RefCenter); var innerNormal = wdir.GetInnerNormal(); var face = parm.RefWall.GetInnerFace(parm.RefCenter); var profile = face.GetEdgesAsCurveLoops().ToCurveArrArray(); var minPt = profile.ToCurveList().GetDistinctPointList().GetMinPoint(); #if R2016 var plane = new Plane(innerNormal, XYZ.Zero); #endif #if !R2016 var plane = Plane.CreateByNormalAndOrigin(innerNormal, XYZ.Zero); #endif var symbolParm = new FamilySymbolParameter(parm.TemplateFileName, profile, plane, 1); var symbol = doc.CreateExtrusionSymbol(app, symbolParm); var lvl = doc.GetElement(parm.RefWall.LevelId) as Level; var instanceParm = new FamilyInstanceParameter(minPt, symbol, lvl, StructuralType.NonStructural); CurtainSystem result = null; doc.AutoTransaction(() => { var inst = doc.CreateFamilyInstance(instanceParm); doc.Regenerate(); // The instance has thickness. var faces = inst.GetFaceList(-innerNormal).ToFaceArray(); result = doc.CreateCurtainSystemWithTrans(faces); doc.Delete(inst.Id); doc.Delete(symbol.Family.Id); if (parm.PanelType == null) { return; } result.CurtainSystemType.get_Parameter(BuiltInParameter.AUTO_PANEL).Set(parm.PanelType.Id); var thickness = parm.PanelType.get_Parameter(BuiltInParameter.CURTAIN_WALL_SYSPANEL_THICKNESS).AsDouble(); ElementTransformUtils.MoveElement(doc, result.Id, innerNormal * thickness / 2); }); return(result); }