示例#1
0
        public static SpecklePolycurve getFloorOutline(Autodesk.Revit.DB.Floor myFloor)
        {
            var geometry = myFloor.get_Geometry(new Options()
            {
                DetailLevel = ViewDetailLevel.Medium
            });
            var poly = new SpecklePolycurve();

            poly.Segments = new List <SpeckleObject>();

            foreach (Solid solid in geometry) // let's hope it's only one?
            {
                if (solid == null)
                {
                    continue;
                }
                var f        = GetLowestFace(solid);
                var crvLoops = f.GetEdgesAsCurveLoops();
                foreach (var crvloop in crvLoops)
                {
                    foreach (var curve in crvloop)
                    {
                        var c = curve as Autodesk.Revit.DB.Curve;

                        if (c == null)
                        {
                            continue;
                        }
                        poly.Segments.Add(SpeckleCore.Converter.Serialise(c) as SpeckleObject);
                    }
                }
            }
            return(poly);
        }
示例#2
0
        /// <summary>
        /// Get all points of the Slab
        /// </summary>
        /// <returns>points array stores all the points on slab</returns>
        public EdgeArray GetFloorEdges()
        {
            EdgeArray edges   = new EdgeArray();
            Options   options = m_commandData.Application.Application.Create.NewGeometryOptions();

            options.DetailLevel = DetailLevels.Medium;
            //make sure references to geometric objects are computed.
            options.ComputeReferences = true;
            Autodesk.Revit.DB.GeometryElement geoElem = m_floor.get_Geometry(options);
            GeometryObjectArray gObjects = geoElem.Objects;

            //get all the edges in the Geometry object
            foreach (GeometryObject geo in gObjects)
            {
                Solid solid = geo as Solid;
                if (solid != null)
                {
                    FaceArray faces = solid.Faces;
                    foreach (Face face in faces)
                    {
                        EdgeArrayArray edgeArrarr = face.EdgeLoops;
                        foreach (EdgeArray edgeArr in edgeArrarr)
                        {
                            foreach (Edge edge in edgeArr)
                            {
                                edges.Append(edge);
                            }
                        }
                    }
                }
            }
            return(edges);
        }
示例#3
0
        public static SpeckleElementsClasses.Floor ToSpeckle(this Autodesk.Revit.DB.Floor myFloor)
        {
            var speckleFloor = new SpeckleElementsClasses.Floor();

            speckleFloor.parameters = GetElementParams(myFloor);

            var geo = myFloor.get_Geometry(new Options()
            {
                DetailLevel = ViewDetailLevel.Medium
            });

            speckleFloor.floorType = myFloor.FloorType.Name;
            speckleFloor.baseCurve = getFloorOutline(myFloor);

            speckleFloor.ApplicationId = myFloor.UniqueId;
            speckleFloor.elementId     = myFloor.Id.ToString();
            speckleFloor.GenerateHash();

            (speckleFloor.Faces, speckleFloor.Vertices) = GetFaceVertexArrayFromElement(myFloor, new Options()
            {
                DetailLevel = ViewDetailLevel.Fine, ComputeReferences = false
            });

            return(speckleFloor);
        }
示例#4
0
        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;
            }
        }