/// <summary> /// Exports a footing to IFC footing. /// </summary> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="footing"> /// The footing element. /// </param> /// <param name="geometryElement"> /// The geometry element. /// </param> /// <param name="productWrapper"> /// The ProductWrapper. /// </param> public static void ExportFootingElement(ExporterIFC exporterIFC, WallFoundation footing, GeometryElement geometryElement, ProductWrapper productWrapper) { String ifcEnumType = "STRIP_FOOTING"; ExportFooting(exporterIFC, footing, geometryElement, ifcEnumType, productWrapper); }
/// <summary> /// get all the required information of selected elements and store them in a data table /// </summary> /// <param name="selectedElements"> /// all selected elements in Revit main program /// </param> /// <returns> /// a data table which store all the required information /// </returns> private DataTable StoreInformationInDataTable(ElementSet selectedElements) { DataTable informationTable = CreatDataTable(); foreach (Element element in selectedElements) { // Get AnalyticalModel analyticalModel = element.GetAnalyticalModel(); if (null == analyticalModel) // skip no AnalyticalModel element { continue; } DataRow newRow = informationTable.NewRow(); string idValue = element.Id.IntegerValue.ToString(); // store element Id value string typeName = ""; // store element type name string[] supportInformation = GetSupportInformation(analyticalModel); // store support information // get element type information switch (element.GetType().Name) { case "WallFoundation": WallFoundation wallFound = element as WallFoundation; ElementType wallFootSymbol = m_revit.Application.ActiveUIDocument.Document.GetElement(wallFound.GetTypeId()) as ElementType;// get element Type typeName = wallFootSymbol.Category.Name + ": " + wallFootSymbol.Name; break; case "FamilyInstance": FamilyInstance familyInstance = element as FamilyInstance; FamilySymbol symbol = m_revit.Application.ActiveUIDocument.Document.GetElement(familyInstance.GetTypeId()) as FamilySymbol; typeName = symbol.Family.Name + ": " + symbol.Name; break; case "Floor": Floor slab = element as Floor; FloorType slabType = m_revit.Application.ActiveUIDocument.Document.GetElement(slab.GetTypeId()) as FloorType; // get element type typeName = slabType.Category.Name + ": " + slabType.Name; break; case "Wall": Wall wall = element as Wall; WallType wallType = m_revit.Application.ActiveUIDocument.Document.GetElement(wall.GetTypeId()) as WallType; // get element type typeName = wallType.Kind.ToString() + ": " + wallType.Name; break; default: break; } // set the relative information of current element into the table. newRow["Id"] = idValue; newRow["Element Type"] = typeName; newRow["Support Type"] = supportInformation[0]; newRow["Remark"] = supportInformation[1]; informationTable.Rows.Add(newRow); } return(informationTable); }
GetSymbolRef(Element elem) { WallFoundation contFoot = elem as WallFoundation; if (contFoot != null) { return(contFoot.GetFoundationType()); } FamilyInstance famInst = elem as FamilyInstance; if (famInst != null) { return(famInst.Symbol); } Floor floor = elem as Floor; if (floor != null) { return(floor.FloorType); } Group group = elem as Group; if (group != null) { return(group.GroupType); } Wall wall = elem as Wall; if (wall != null) { return(wall.WallType); } return(null); // nothing we know about }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; UIDocument uidoc = app.ActiveUIDocument; Document doc = uidoc.Document; Wall wall = Util.SelectSingleElementOfType( uidoc, typeof(Wall), "a wall", false) as Wall; if (null == wall) { message = "Please select a single wall element."; return(Result.Failed); } ICollection <ElementId> delIds = null; using (Transaction t = new Transaction(doc)) { try { t.Start("Temporary Wall Deletion"); delIds = doc.Delete(wall.Id); t.RollBack(); } catch (Exception ex) { message = "Deletion failed: " + ex.Message; t.RollBack(); } } WallFoundation footing = null; foreach (ElementId id in delIds) { footing = doc.GetElement(id) as WallFoundation; if (null != footing) { break; } } string s = Util.ElementDescription(wall); Util.InfoMsg((null == footing) ? string.Format("No footing found for {0}.", s) : string.Format("{0} has {1}.", s, Util.ElementDescription(footing))); return(Result.Succeeded); }
private void Stream( ArrayList data, WallFoundation contFooting ) { data.Add( new Snoop.Data.ClassSeparator( typeof( WallFoundation ) ) ); data.Add( new Snoop.Data.Object( "Analytical model", contFooting.GetAnalyticalModel() ) ); data.Add( new Snoop.Data.Object( "Footing type", contFooting.GetFoundationType() ) ); }
private void Stream( ArrayList data, WallFoundation contFooting ) { data.Add( new Snoop.Data.ClassSeparator( typeof( WallFoundation ) ) ); data.Add( new Snoop.Data.Object( "Name", contFooting.Name ) ); data.Add( new Snoop.Data.Object( "Analytical model", contFooting.GetAnalyticalModel() ) ); data.Add( new Snoop.Data.Object( "Footing type", contFooting.GetTypeId() ) ); data.Add( new Snoop.Data.Object( "Location", contFooting.Location ) ); data.Add( new Snoop.Data.Object( "WallId", contFooting.WallId ) ); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Application app = commandData.Application.Application; UIDocument uidoc = commandData.Application.ActiveUIDocument; Document doc = uidoc.Document; bool SourceIsWallFoundation = false; Reference ref1 = null; IList<Reference> ref2List = new List<Reference>(); try { ref1 = uidoc.Selection.PickObject(ObjectType.Element, new RebarHostSelectionFilter(), "Pick a rebar host to copy from"); ref2List = uidoc.Selection.PickObjects(ObjectType.Element, new RebarHostSelectionFilter(), "Pick a rebar host to copy to"); } catch(Autodesk.Revit.Exceptions.OperationCanceledException) { TaskDialog.Show("Rebar Copy command cancelled", "Click finish in top left corner to complete the command"); return Result.Cancelled; } using (Transaction t1 = new Transaction(doc, "Copy rebar")) { t1.Start(); foreach (Reference ref2 in ref2List) { Element sourceHost = doc.GetElement(ref1.ElementId); Element targetHost = doc.GetElement(ref2.ElementId); ICollection<ElementId> elementIdToBeDeleted = new List<ElementId>(); WallFoundation sourceWallFoundation = null; WallFoundation targetWallFoundation = null; //Workaround for wall foundations: They have no location lines, but are completely dependent on their walls. So by copiing the host wall, both the wall foundation and the rebars follows along if (sourceHost is WallFoundation && targetHost is WallFoundation) { SourceIsWallFoundation = true; sourceWallFoundation = (WallFoundation)sourceHost; sourceHost = doc.GetElement(sourceWallFoundation.WallId); targetWallFoundation = (WallFoundation)targetHost; targetHost = doc.GetElement(targetWallFoundation.WallId); } //STEP 1: Copy element to random location //5000 is a random chosen number, surprisingly it matters if its copied in Y or Z direction: ICollection<ElementId> copiedElements = ElementTransformUtils.CopyElement(doc, sourceHost.Id, new XYZ(0, 5000, 0)); Element copiedElement = doc.GetElement(copiedElements.FirstOrDefault()); elementIdToBeDeleted.Add(copiedElement.Id); //STEP 2: Relocate copy to match the target if (copiedElement.Location is LocationCurve && targetHost.Location is LocationCurve) { LocationCurve locationTo = targetHost.Location as LocationCurve; LocationCurve locationCopied = copiedElement.Location as LocationCurve; locationCopied.Curve = locationTo.Curve; } else if (copiedElement.Location is LocationPoint && targetHost.Location is LocationPoint) { LocationPoint locationTo = targetHost.Location as LocationPoint; LocationPoint locationCopied = copiedElement.Location as LocationPoint; locationCopied.Point = locationTo.Point; if (locationCopied.Rotation != locationTo.Rotation) { Transform trans1 = Transform.CreateTranslation(new XYZ(0, 0, 1)); XYZ origin1 = locationTo.Point; XYZ endAxis = trans1.OfPoint(origin1); Line axis1 = Line.CreateBound(origin1, endAxis); locationCopied.Rotate(axis1, locationTo.Rotation); } } else { TaskDialog.Show("Warning", "Pick two Rebar Hosts with the same location type. Only elements with locatoion lines and location points are supported. Elements such as beams, walls and slanted columns do typically have location lines. Floors and slabs are not supported."); t1.RollBack(); return Result.Cancelled; } //STEP 3: Change the type of the copied element to match the target element //TODO: Change types for wall foundations and change heights/offsets for walls try { if (targetHost.GetTypeId() != copiedElement.GetTypeId()) { copiedElement.ChangeTypeId(targetHost.GetTypeId()); } if (targetHost is Wall && sourceHost is Wall) { copiedElement.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET).Set(targetHost.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET).AsDouble()); copiedElement.get_Parameter(BuiltInParameter.WALL_TOP_OFFSET).Set(targetHost.get_Parameter(BuiltInParameter.WALL_TOP_OFFSET).AsDouble()); } if (IsNotSlantedColumn(targetHost) && IsNotSlantedColumn(sourceHost)) { copiedElement.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_PARAM).Set(targetHost.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_PARAM).AsElementId()); copiedElement.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM).Set(targetHost.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM).AsDouble()); copiedElement.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_PARAM).Set(targetHost.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_PARAM).AsElementId()); copiedElement.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM).Set(targetHost.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM).AsDouble()); } } catch { } doc.Regenerate(); //Step 3: Change rebar host from copied element to target element IList<Rebar> copiedRebars = new List<Rebar>(); if (SourceIsWallFoundation) { //Need to find the foundation that was created by copying the wall WallFoundation wallFoundation = new FilteredElementCollector(doc) .OfClass(typeof(WallFoundation)) .WhereElementIsNotElementType().Cast<WallFoundation>() .FirstOrDefault(q => q.WallId == copiedElement.Id); elementIdToBeDeleted.Add(wallFoundation.Id); copiedRebars = RebarHostData.GetRebarHostData(wallFoundation).GetRebarsInHost(); if (targetWallFoundation != null) { foreach (Rebar r in copiedRebars) { r.SetHostId(doc, targetWallFoundation.Id); } } } else { copiedRebars = RebarHostData.GetRebarHostData(copiedElement).GetRebarsInHost(); foreach (Rebar r in copiedRebars) { r.SetHostId(doc, targetHost.Id); } } //Step 4: Delete the copied element doc.Delete(elementIdToBeDeleted); } t1.Commit(); } return Result.Succeeded; }
/// <summary> /// Exports a footing to IFC footing. /// </summary> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="footing"> /// The footing element. /// </param> /// <param name="geometryElement"> /// The geometry element. /// </param> /// <param name="productWrapper"> /// The ProductWrapper. /// </param> public static void ExportFootingElement(ExporterIFC exporterIFC, WallFoundation footing, GeometryElement geometryElement, ProductWrapper productWrapper) { String ifcEnumType = "STRIP_FOOTING"; ExportFooting(exporterIFC, footing, geometryElement, ifcEnumType, productWrapper); }