/// <summary> /// Create a SlabEdge. /// </summary> /// <param name="symbol">SlabEdge type</param> /// <param name="refArr">SlabEdge reference array</param> /// <returns>Created SlabEdge</returns> protected override HostedSweep CreateHostedSweep(ElementType symbol, ReferenceArray refArr) { SlabEdge slabEdge = m_rvtDoc.Create.NewSlabEdge(symbol as SlabEdgeType, refArr); if (slabEdge != null) { // Avoid the Revit warning, flip the direction in horizontal direction. slabEdge.HorizontalFlip(); } return(slabEdge); }
public static List <SlabEdge> ByReferenceArray(Revit.Elements.Element Floor, Revit.Elements.Element SlabEdgeType) { var doc = DocumentManager.Instance.CurrentDBDocument; List <SlabEdge> slab = new List <SlabEdge>(); ElementId id = Elements.UnwrapElement(SlabEdgeType); SlabEdgeType unwrapSlabEdge = doc.GetElement(id) as SlabEdgeType; Console.WriteLine(id); ElementId floorId = Elements.UnwrapElement(Floor); Autodesk.Revit.DB.Floor elem = doc.GetElement(floorId) as Autodesk.Revit.DB.Floor; Options geomOptions = new Options(); GeometryElement solid = elem.get_Geometry(geomOptions); try { foreach (GeometryElement k in solid) { ReferenceArray referenceArray = new ReferenceArray(); referenceArray.Clear(); //IEnumerable<ReferenceArray> reference = Line as IEnumerable<ReferenceArray>; //foreach (Autodesk.DesignScript.Geometry.Curve host in k) //{ // //var curve = host.ToRevitType(); // //var host = curve.ToProtoType(); // //Reference j = host as Reference; // Curve curve = host.ToRevitType(); // Reference refc = curve.Reference; // referenceArray.Append(refc); //} TransactionManager.Instance.EnsureInTransaction(doc); SlabEdge slabcreator = doc.Create.NewSlabEdge(unwrapSlabEdge, referenceArray); slabcreator.ToDSType(true); slab.Add(slabcreator); TransactionManager.Instance.TransactionTaskDone(); } return(slab); } catch (Exception ex) { throw ex; } }
/// <summary> /// Filter all the edges from the element which SlabEdge can be created on. /// </summary> /// <param name="elem"></param> private void FilterEdgesForSlabEdge(Autodesk.Revit.DB.Element elem) { Transaction transaction = new Transaction(this.RvtDocument, "FilterEdgesForSlabEdge"); transaction.Start(); // Note: This method will create a SlabEdge with no reference. // In the future, API may not allow to create such SlabEdge with // no references, invoke this methods like this may throw exception. // SlabEdge slabEdge = m_rvtDoc.Create.NewSlabEdge(null, new ReferenceArray()); List <Edge> floorEdges = m_floorSlabEdges[elem]; foreach (Edge edge in m_elemGeom[elem].EdgeBindingDic.Keys) { if (edge.Reference == null) { continue; } try { slabEdge.AddSegment(edge.Reference); // AddSegment successfully, so this edge can be used to crate SlabEdge. floorEdges.Add(edge); } catch (Autodesk.Revit.Exceptions.ArgumentOutOfRangeException) { // Exception, this edge will be discard. } } // Delete this element, because we just use it to filter the edges. m_rvtDoc.Delete(slabEdge); transaction.RollBack(); }
private void Stream( ArrayList data, SlabEdge slabEdge ) { data.Add( new Snoop.Data.ClassSeparator( typeof( SlabEdge ) ) ); data.Add( new Snoop.Data.Object( "Slab edge type", slabEdge.SlabEdgeType ) ); }