Exemple #1
0
        /// <summary>
        /// construct function.
        /// </summary>
        /// <param name="door">of which geometry data is wanted.</param>
        public DoorGeometry(Autodesk.Revit.DB.Element door)
        {
            m_options                              = new Options();
             m_options.View                         = GetPlanform2DView(door);
             m_options.ComputeReferences            = false;
             Autodesk.Revit.DB.GeometryElement geoEle = door.get_Geometry(m_options);
             AddGeometryElement(geoEle);

             m_bbox = door.get_BoundingBox(m_options.View);
        }
Exemple #2
0
        /// <summary>
        /// Obtain a sparse point collection outlining a Revit element bt traversing it's
        /// GeometryObject representation
        /// </summary>
        /// <param name="e"></param>
        /// <param name="pts"></param>
        protected static void GetPointCloud(Autodesk.Revit.DB.Element e, List<XYZ> pts)
        {
            var options = new Options()
            {
                ComputeReferences = true,
                DetailLevel = ViewDetailLevel.Coarse,
                IncludeNonVisibleObjects = false
            };

            foreach (var gObj in e.get_Geometry(options))
            {
                if (gObj is Autodesk.Revit.DB.Solid)
                {
                    GetPointCloud(gObj as Autodesk.Revit.DB.Solid, pts);
                }
                else if (gObj is GeometryInstance)
                {
                    GetPointCloud(gObj as GeometryInstance, pts);
                }
            }
        }
Exemple #3
0
        private Value GetCurvesFromFamily(Autodesk.Revit.DB.FamilyInstance fi, int count,
                                          Autodesk.Revit.DB.Options options)
        {
            FamilySymbol fs = fi.Symbol;
            //Autodesk.Revit.DB.GeometryElement geomElem = fs.get_Geometry(options);
            Autodesk.Revit.DB.GeometryElement geomElem = fi.get_Geometry(options);
                // our particular case of a loaded mass family with no joins has no geom in the instance

            //fi.GetOriginalGeometry(options);
            //fi.GetTransform()

            Autodesk.Revit.DB.CurveArray curves = new CurveArray();
            Autodesk.Revit.DB.ReferenceArray curveRefs = new ReferenceArray();

            //Find all curves and insert them into curve array
            AddCurves(fi, geomElem, count, ref curves);

            //curves.Append(GetCurve(fi, options)); //test

            //extract references for downstream use
            foreach (Curve c in curves)
            {
                curveRefs.Append(c.Reference);
            }

            //convert curvearray into list using Stephens MakeEnumerable
            Value result = Value.NewList(Utils.SequenceToFSharpList(
                dynUtils.MakeEnumerable(curves).Select(Value.NewContainer)
                                             ));

            return result;
        }
Exemple #4
0
        // Note: Some element does not expose geometry, for example, curtain wall and dimension.
        // In case of a curtain wall, try selecting a whole wall by a window/box instead of a single pick.
        // It will then select internal components and be able to display its geometry.
        //
        public void SendElement(Autodesk.Revit.DB.Element elem)
        {
            if (elem.GetType() ==  typeof(Autodesk.Revit.DB.Element))
             {
            return;
             }
             if (elem is Autodesk.Revit.DB.TextNote)
             {
             sendTextNote(elem);
             }
             if (elem is Autodesk.Revit.DB.View)
             {
             sendViewpoint(elem);
             }
             // if it is a Group. we will need to look at its components.
             if (elem is Autodesk.Revit.DB.Group)
             {

             /* if we add this, the elements of the Group are duplicates
                Autodesk.Revit.DB.Group @group = (Autodesk.Revit.DB.Group)elem;
                Autodesk.Revit.DB.ElementArray members = @group.GetMemberIds;

                MessageBuffer mb = new MessageBuffer();
                mb.add(elem.Id.IntegerValue);
                mb.add(elem.Name);
                sendMessage(mb.buf, MessageTypes.NewGroup);
                foreach (Autodesk.Revit.DB.Element elm in members)
                {
                   SendElement(elm);
                }
                mb = new MessageBuffer();
                sendMessage(mb.buf, MessageTypes.EndGroup);*/
             }

             else
             {

            // not a group. look at the geom data.
             Autodesk.Revit.DB.GeometryElement geom = elem.get_Geometry(mOptions);
            if ((geom != null))
            {
               SendElement(geom, elem);
            }
             }
        }
Exemple #5
0
 /// <summary>
 /// Get edges of element's profile
 /// </summary>
 /// <param name="elem">selected element</param>
 /// <returns>all the faces in the selected Element</returns>
 public virtual List<List<Edge>> GetFaces(Autodesk.Revit.DB.Element elem)
 {
     List<List<Edge>> faceEdges = new List<List<Edge>>();
     Options options = m_appCreator.NewGeometryOptions();
     options.DetailLevel = DetailLevels.Medium;
     //make sure references to geometric objects are computed.
     options.ComputeReferences = true;
     Autodesk.Revit.DB.GeometryElement geoElem = elem.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)
                 {
                     List<Edge> edgesList = new List<Edge>();
                     foreach (Edge edge in edgeArr)
                     {
                         edgesList.Add(edge);
                     }
                     faceEdges.Add(edgesList);
                 }
             }
         }
     }
     return faceEdges;
 }
Exemple #6
0
 /// <summary>
 /// Extract the geometry of the given Element.
 /// </summary>
 /// <param name="elem">Element parameter</param>
 /// <returns>Element's geometry</returns>
 protected ElementGeometry ExtractGeom(Autodesk.Revit.DB.Element elem)
 {
     Solid result = null;
     Options options = new Options();
     options.ComputeReferences = true;
     Autodesk.Revit.DB.GeometryElement gElement = elem.get_Geometry(options);
     foreach (GeometryObject gObj in gElement.Objects)
     {
         result = gObj as Solid;
         if (result != null && result.Faces.Size > 0)
             break;
     }
     BoundingBoxXYZ box = elem.get_BoundingBox(null);
     return new ElementGeometry(result, box);
 }
Exemple #7
0
 /// <summary>
 /// Get edges of element's profile
 /// </summary>
 /// <param name="elem">selected element</param>
 /// <returns>all the faces in the selected Element</returns>
 public override List<List<Edge>> GetFaces(Autodesk.Revit.DB.Element elem)
 {
     List<List<Edge>> faceEdges = new List<List<Edge>>();
     Options options = m_appCreator.NewGeometryOptions();
     options.DetailLevel = DetailLevels.Medium;
     //make sure references to geometric objects are computed.
     options.ComputeReferences = true;
     Autodesk.Revit.DB.GeometryElement geoElem = elem.get_Geometry(options);
     GeometryObjectArray gObjects = geoElem.Objects;
     //get all the edges in the Geometry object
     foreach (GeometryObject geo in gObjects)
     {
         //if beam doesn't contain opening on it, then we can get edges from instance
         //and the points we get should be transformed by instance.Tranceform
         if (geo is Autodesk.Revit.DB.GeometryInstance)
         {
             Autodesk.Revit.DB.GeometryInstance instance = geo as Autodesk.Revit.DB.GeometryInstance;
             m_beamTransform = instance.Transform;
             Autodesk.Revit.DB.GeometryElement elemGeo = instance.SymbolGeometry;
             GeometryObjectArray objectsGeo = elemGeo.Objects;
             foreach (GeometryObject objGeo in objectsGeo)
             {
                 Solid solid = objGeo as Solid;
                 if (null != solid)
                 {
                     FaceArray faces = solid.Faces;
                     foreach (Face face in faces)
                     {
                         EdgeArrayArray edgeArrarr = face.EdgeLoops;
                         foreach (EdgeArray edgeArr in edgeArrarr)
                         {
                             List<Edge> edgesList = new List<Edge>();
                             foreach (Edge edge in edgeArr)
                             {
                                 edgesList.Add(edge);
                             }
                             faceEdges.Add(edgesList);
                         }
                     }
                 }
             }
         }
         //if beam contains opening on it, then we can get edges from solid
         //and the points we get do not need transform anymore
         else if (geo is Autodesk.Revit.DB.Solid)
         {
             m_haveOpening = true;
             Solid solid = geo as Solid;
             FaceArray faces = solid.Faces;
             foreach (Face face in faces)
             {
                 EdgeArrayArray edgeArrarr = face.EdgeLoops;
                 foreach (EdgeArray edgeArr in edgeArrarr)
                 {
                     List<Edge> edgesList = new List<Edge>();
                     foreach (Edge edge in edgeArr)
                     {
                         edgesList.Add(edge);
                     }
                     faceEdges.Add(edgesList);
                 }
             }
         }
     }
     return faceEdges;
 }
Exemple #8
0
        /// <summary>
        /// Internal constructor to make a solid by extracting solids from an element.
        /// </summary>
        /// <param name="element"></param>
        internal Solid(Autodesk.Revit.DB.Element element)
        {
            // Regenerate to get the solids in the element. If the element was
            // created during this same run, document regeneration will not have
            // occured.
            TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);
            DocumentManager.Regenerate();
            TransactionManager.Instance.TransactionTaskDone();

            var instanceSolids = new Dictionary<ElementId, List<Autodesk.Revit.DB.GeometryObject>>();;
            Autodesk.Revit.DB.Solid mySolid = null;

            var thisId = ElementId.InvalidElementId;

            if (element != null)
            {
                thisId = element.Id;
                instanceSolids[thisId] = new List<Autodesk.Revit.DB.GeometryObject>();
            }

            bool bNotVisibleOption = false;
            if (element is GenericForm)
            {
                var gF = (GenericForm)element;
                if (!gF.Combinations.IsEmpty)
                    bNotVisibleOption = true;
            }

            int nTry = (bNotVisibleOption) ? 2 : 1;
            for (int iTry = 0; iTry < nTry && (mySolid == null);
                iTry++)
            {
                var geoOptions = new Autodesk.Revit.DB.Options();
                geoOptions.ComputeReferences = true;
                if (bNotVisibleOption && (iTry == 1))
                    geoOptions.IncludeNonVisibleObjects = true;

                Autodesk.Revit.DB.GeometryObject geomObj = element.get_Geometry(geoOptions);
                var geomElement = geomObj as GeometryElement;

                if (geomElement != null)
                {
                    foreach (Autodesk.Revit.DB.GeometryObject geob in geomElement)
                    {
                        var ginsta = geob as GeometryInstance;
                        if (ginsta != null && thisId != ElementId.InvalidElementId)
                        {
                            GeometryElement instanceGeom = ginsta.GetInstanceGeometry();

                            instanceSolids[thisId].Add(instanceGeom);

                            foreach (Autodesk.Revit.DB.GeometryObject geobInst in instanceGeom)
                            {
                                mySolid = geobInst as Autodesk.Revit.DB.Solid;
                                if (mySolid != null)
                                {
                                    FaceArray faceArr = mySolid.Faces;
                                    var thisEnum = faceArr.GetEnumerator();
                                    bool hasFace = false;
                                    for (; thisEnum.MoveNext(); )
                                    {
                                        hasFace = true;
                                        break;
                                    }
                                    if (!hasFace)
                                        mySolid = null;
                                    else
                                        break;
                                }
                            }
                            if (mySolid != null)
                                break;
                        }
                        else
                        {
                            mySolid = geob as Autodesk.Revit.DB.Solid;
                            if (mySolid != null)
                            {
                                FaceArray faceArr = mySolid.Faces;
                                var thisEnum = faceArr.GetEnumerator();
                                bool hasFace = false;
                                for (; thisEnum.MoveNext(); )
                                {
                                    hasFace = true;
                                    break;
                                }
                                if (!hasFace)
                                    mySolid = null;
                                else
                                    break;
                            }

                        }
                    }
                }
            }

            this.InternalSolid = mySolid;
        }