public static List <Revit.Elements.Element> CreateWallSweep(List <Revit.Elements.Wall> Walls, Revit.Elements.Element TypeElement, string SweepOrReveal, bool IsVertical, double Offset = 1000) { var doc = DocumentManager.Instance.CurrentDBDocument; var WallSweeps = new List <Revit.Elements.Element>(); var wallSweepTypes = new Dictionary <string, Autodesk.Revit.DB.WallSweepType>(); wallSweepTypes.Add("Sweep", WallSweepType.Sweep); wallSweepTypes.Add("Reveal", WallSweepType.Reveal); var wallSweepTypeId = TypeElement.InternalElement.Id; WallSweepInfo wallSweepInfo = new WallSweepInfo(wallSweepTypes[SweepOrReveal], IsVertical); wallSweepInfo.Distance = Offset / 304.8; TransactionManager.Instance.EnsureInTransaction(doc); foreach (var w in Walls) { var wall = w.InternalElement as Autodesk.Revit.DB.Wall; WallSweep wallSweep = WallSweep.Create(wall, wallSweepTypeId, wallSweepInfo); WallSweeps.Add(wallSweep.ToDSType(true)); } TransactionManager.Instance.TransactionTaskDone(); return(WallSweeps); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Document doc = uidoc.Document; Selection selection = uidoc.Selection; View acview = uidoc.ActiveView; try { Reference reff = selection.PickObject(ObjectType.Element, new MySelectionFilter <Room>(), "select a room"); Room room = doc.GetElement(reff) as Room; ElementType wallSweepType = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Cornices).WhereElementIsElementType().Cast <ElementType>().FirstOrDefault(); if (wallSweepType != null) { using (Transaction ts = new Transaction(doc, "创建踢脚线")) { ts.Start(); ElementType type = wallSweepType.Duplicate("踢脚线2"); SpatialElementBoundaryOptions opts = new SpatialElementBoundaryOptions(); opts.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish; IList <IList <Autodesk.Revit.DB.BoundarySegment> > boundList = room.GetBoundarySegments(opts); foreach (IList <BoundarySegment> bs in boundList) { foreach (BoundarySegment bs1 in bs) { Wall wall = doc.GetElement(bs1.ElementId) as Wall; if (wall != null) { WallSweepInfo info = new WallSweepInfo(WallSweepType.Sweep, false); // 墙的正反或者里面 info.WallSide = WallSide.Exterior; // 距离墙底的高度 info.Distance = 10 / 304.8; // 偏移距离 info.WallOffset = 0; WallSweep.Create(wall, type.Id, info); } } } ts.Commit(); } } } catch (Exception ex) { TaskDialog.Show("Error", ex.Message); } return(Result.Succeeded); }
/// <summary> /// Exports a wall swepp. /// </summary> /// <param name="exporterIFC">The ExporterIFC object.</param> /// <param name="wallSweep">The WallSwepp.</param> /// <param name="geometryElement">The geometry element.</param> /// <param name="productWrapper">The ProductWrapper.</param> public static void Export(ExporterIFC exporterIFC, WallSweep wallSweep, GeometryElement geometryElement, ProductWrapper productWrapper) { WallSweepInfo wallSweepInfo = wallSweep.GetWallSweepInfo(); //Reveals are exported as openings with wall exporter. if (wallSweepInfo.WallSweepType == WallSweepType.Reveal) return; if (!ProxyElementExporter.Export(exporterIFC, wallSweep, geometryElement, productWrapper)) return; HostObjectExporter.ExportHostObjectMaterials(exporterIFC, wallSweep, productWrapper.GetAnElement(), geometryElement, productWrapper, ElementId.InvalidElementId, Toolkit.IFCLayerSetDirection.Axis2); }
public static RevitInstance3D ToSAM(this WallSweep wallSweep, ConvertSettings convertSettings) { if (wallSweep == null || !wallSweep.IsValidObject) { return(null); } RevitInstance3D result = convertSettings?.GetObject <RevitInstance3D>(wallSweep.Id); if (result != null) { return(result); } Document document = wallSweep.Document; if (document == null) { return(result); } ElementType elementType = document.GetElement(wallSweep.GetTypeId()) as ElementType; if (elementType == null) { return(null); } RevitType3D revitType3D = elementType.ToSAM(convertSettings) as RevitType3D; if (revitType3D == null) { return(null); } result = new RevitInstance3D(revitType3D, wallSweep.ToSAM_Geometries <Spatial.ISAMGeometry3D>()); if (result != null) { result.UpdateParameterSets(elementType, ActiveSetting.Setting.GetValue <TypeMap>(Core.Revit.ActiveSetting.Name.ParameterMap)); convertSettings?.Add(elementType.Id, result); } return(result); }
/// <summary> /// Exports a wall swepp. /// </summary> /// <param name="exporterIFC">The ExporterIFC object.</param> /// <param name="wallSweep">The WallSweep.</param> /// <param name="geometryElement">The geometry element.</param> /// <param name="productWrapper">The ProductWrapper.</param> public static void Export(ExporterIFC exporterIFC, WallSweep wallSweep, GeometryElement geometryElement, ProductWrapper productWrapper) { WallSweepInfo wallSweepInfo = wallSweep.GetWallSweepInfo(); //Reveals are exported as openings with wall exporter. if (wallSweepInfo.WallSweepType == WallSweepType.Reveal) { return; } if (!ProxyElementExporter.Export(exporterIFC, wallSweep, geometryElement, productWrapper)) { return; } HostObjectExporter.ExportHostObjectMaterials(exporterIFC, wallSweep, productWrapper.GetAnElement(), geometryElement, productWrapper, ElementId.InvalidElementId, Toolkit.IFCLayerSetDirection.Axis2, null); }
/// <summary> /// Conversion of WallSweep to panels. WARNING! Method does not handle more complex WallSweep /// </summary> /// <param name="wallSweep">Revit WallSweep</param> /// <param name="convertSettings">SAM Revit ConvertSettings</param> /// <returns>SAM Analytical Panels (Panels projected on host (Wall) plane)</returns> public static List <Panel> ToSAM_Panels(this WallSweep wallSweep, ConvertSettings convertSettings) { if (wallSweep == null) { return(null); } List <Panel> result = convertSettings?.GetObjects <Panel>(wallSweep.Id); if (result != null) { return(result); } RevitInstance3D revitInstance3D = Geometry.Revit.Convert.ToSAM(wallSweep, convertSettings); if (revitInstance3D == null) { return(null); } result = ToSAM_Panels(revitInstance3D); if (result != null) { convertSettings?.Add(wallSweep.Id, result); } return(result); //if (wallSweep == null || !wallSweep.IsValidObject) // return null; //List<Panel> result = convertSettings?.GetObjects<Panel>(wallSweep.Id); //if (result != null) // return result; //IEnumerable<ElementId> elementIds = wallSweep.GetHostIds(); //if (elementIds == null || elementIds.Count() == 0) //{ // return null; //} //Document document = wallSweep.Document; //if(document == null) //{ // return null; //} //HostObject hostObject = null; //foreach(ElementId elementId in elementIds) //{ // hostObject = document.GetElement(elementId) as HostObject; // if(hostObject != null) // { // break; // } //} //List<Face3D> face3Ds = hostObject?.Profiles(); //if(face3Ds == null || face3Ds.Count == 0) //{ // return null; //} //Geometry.Spatial.Plane plane = face3Ds[0]?.GetPlane(); //if(plane == null) //{ // return null; //} //List<Face3D> face3Ds_WallSweep = Geometry.Revit.Convert.ToSAM_Geometries<Face3D>(wallSweep); //if(face3Ds_WallSweep == null || face3Ds_WallSweep.Count == 0) //{ // return null; //} //List<Face2D> face2Ds = new List<Face2D>(); //foreach(Face3D face3D_WallSweep in face3Ds_WallSweep) //{ // Geometry.Spatial.Plane plane_WallSweep = face3D_WallSweep?.GetPlane(); // if (plane_WallSweep == null || plane.Perpendicular(plane_WallSweep)) // { // continue; // } // Face3D face3D = plane.Project(face3D_WallSweep); // if(face3D == null || !face3D.IsValid()) // { // continue; // } // Face2D face2D = plane.Convert(face3D); // if(face2D == null || !face2D.IsValid()) // { // continue; // } // face2Ds.Add(face2D); //} //face2Ds = face2Ds.Union(); //if(face2Ds == null || face2Ds.Count == 0) //{ // return null; //} //Construction construction = ToSAM_Construction((ElementType)document.GetElement(wallSweep.GetTypeId()), convertSettings); //result = new List<Panel>(); //foreach(Face2D face2D in face2Ds) //{ // Face3D face3D = plane.Convert(face2D); // if(face3D == null || !face3D.IsValid()) // { // continue; // } // Panel panel = Analytical.Create.Panel(construction, PanelType.Wall, face3D); // if(panel == null) // { // continue; // } // result.Add(panel); //} //convertSettings?.Add(wallSweep.Id, result); //return result; }