当前位置: 首页>>代码示例>>C#>>正文


C# Element.get_Geometry方法代码示例

本文整理汇总了C#中Element.get_Geometry方法的典型用法代码示例。如果您正苦于以下问题:C# Element.get_Geometry方法的具体用法?C# Element.get_Geometry怎么用?C# Element.get_Geometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Element的用法示例。


在下文中一共展示了Element.get_Geometry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ElementGeometry

        public ElementGeometry(string label, Element val, Autodesk.Revit.ApplicationServices.Application app)
            : base(label)
        {
            m_val = val;
            m_app = app;

            m_hasGeometry = false;

            if (m_val != null && m_app != null) {
                Autodesk.Revit.DB.Options geomOp = m_app.Create.NewGeometryOptions();
                geomOp.DetailLevel = ViewDetailLevel.Undefined;
                if (m_val.get_Geometry(geomOp) != null)
                    m_hasGeometry = true;
            }
        }
开发者ID:halad,项目名称:RevitLookup,代码行数:15,代码来源:ElementGeometry.cs

示例2: GetFaces

 private static FaceArray GetFaces(Element element)
 {
     var faceArray = new FaceArray();
     var options = new Options();
     options.ComputeReferences = true;
     var geomElem = element.get_Geometry(options);
     if (geomElem != null)
     {
         foreach (GeometryObject geomObj in geomElem.Objects)
         {
             var solid = geomObj as Solid;
             if (solid != null)
             {
                 foreach (Face f in solid.Faces)
                 {
                     faceArray.Append(f);
                 }
             }
             var inst = geomObj as GeometryInstance;
             if (inst != null) // in-place family walls
             {
                 foreach (Object o in inst.SymbolGeometry.Objects)
                 {
                     var s = o as Solid;
                     if (s != null)
                     {
                         foreach (Face f in s.Faces)
                         {
                             faceArray.Append(f);
                         }
                     }
                 }
             }
         }
     }
     return faceArray;
 }
开发者ID:AMEE,项目名称:revit,代码行数:37,代码来源:CO2eVisualisationCreator.cs

示例3: Stream

        public virtual void Stream(Element elem)
        {
            if ((m_viewStack.Count == 0) || (m_geomOptionsStack.Count == 0)) {
                throw new System.ArgumentException("View stack or Geometry Options stack is empty.");
            }

            GeometryElement geom = elem.get_Geometry(this.CurrentGeometryOptions);
            if (geom != null) {
                Stream(geom);
            }
        }
开发者ID:halad,项目名称:RevitLookup,代码行数:11,代码来源:GraphicsStream.cs

示例4: GetSolid

        /// <summary>
        /// 
        /// </summary>
        /// <param name="e"></param>
        /// <param name="opt"></param>
        /// <returns></returns>
        Solid GetSolid(Element e, Options opt)
        {
            Solid solid = null;
            // access solid geometry of element
            GeometryElement geo = e.get_Geometry(opt);

            if (null != geo)
            {
                if (e is FamilyInstance)
                {
                    geo = geo.GetTransformed(Transform.Identity);
                }

                GeometryInstance inst = null;
                // iterate through multiple geometry objects
                foreach (GeometryObject obj in geo)
                {
                    solid = obj as Solid;
                    // if there is a solid with faces stop here
                    if (null != solid && 0 < solid.Faces.Size)
                    {
                        break;
                    }
                    // otherwise assign variable inst
                    inst = obj as GeometryInstance;
                }
                // if there is an instance def but no solid check the symbol
                if (null == solid && null != inst)
                {
                    geo = inst.GetSymbolGeometry();
                    // iterate through geometry of symbol
                    foreach (GeometryObject obj in geo)
                    {
                        solid = obj as Solid;
                        // if there is a solid with faces stop here
                        if (null != solid && 0 < solid.Faces.Size)
                        {
                            break;
                        }
                    }
                }
            }
            return solid;
        }
开发者ID:dangwalsh,项目名称:ExportObj,代码行数:50,代码来源:Command.cs

示例5: GetInstancesIntersectingElement

        /// <summary>
        /// Retrieve all family instances intersecting a
        /// given BIM element, e.g. all columns 
        /// intersecting a wall.
        /// </summary>
        void GetInstancesIntersectingElement( Element e )
        {
            #region Joe's code
            #if JOE_CODE
            // Find intersections between family instances and a selected element

            Reference Reference = uidoc.Selection.PickObject(
            ObjectType.Element, "Select element that will "
            + "be checked for intersection with all family "
            + "instances" );

            Element e = doc.GetElement( reference );

            GeometryElement geomElement = e.get_Geometry(
            new Options() );

            Solid solid = null;
            foreach( GeometryObject geomObj in geomElement )
            {
            solid = geomObj as Solid;
            if( solid = !null ) break;
            }

            FilteredElementCollector collector
            = new FilteredElementCollector( doc )
              .OfClass( typeof( FamilyInstance ) )
              .WherePasses( new ElementIntersectsSolidFilter(
            solid ) );

            TaskDialog.Show( "Revit", collector.Count() +
            "Family instances intersect with selected element ("
            + element.Category.Name + "ID:" + element.Id + ")" );
            #endif // JOE_CODE
              #endregion // Joe's code

              // Test this in these SDK sample models:
              // C:\a\lib\revit\2015\SDK\Samples\FindReferencesByDirection\FindColumns\FindColumns-Basic.rvt
              // C:\a\lib\revit\2015\SDK\Samples\FindReferencesByDirection\FindColumns\FindColumns-TestCases.rvt

              Document doc = e.Document;

              Solid solid = e.get_Geometry( new Options() )
            .OfType<Solid>()
            .Where<Solid>( s => null != s && !s.Edges.IsEmpty )
            .FirstOrDefault();

              FilteredElementCollector intersectingInstances
            = new FilteredElementCollector( doc )
              .OfClass( typeof( FamilyInstance ) )
              .WherePasses( new ElementIntersectsSolidFilter(
            solid ) );

              int n1 = intersectingInstances.Count<Element>();

              intersectingInstances
            = new FilteredElementCollector( doc )
              .OfClass( typeof( FamilyInstance ) )
              .WherePasses( new ElementIntersectsElementFilter(
            e ) );

              int n = intersectingInstances.Count<Element>();

              Debug.Assert( n.Equals( n1 ),
            "expected solid intersection to equal element intersection" );

              string result = string.Format(
            "{0} family instance{1} intersect{2} the "
            + "selected element {3}{4}",
            n, Util.PluralSuffix( n ),
            ( 1 == n ? "s" : "" ),
            Util.ElementDescription( e ),
            Util.DotOrColon( n ) );

              string id_list = 0 == n
            ? string.Empty
            : string.Join( ", ",
            intersectingInstances
              .Select<Element, string>(
                x => x.Id.IntegerValue.ToString() ) )
              + ".";

              Util.InfoMsg2( result, id_list );
        }
开发者ID:nbright,项目名称:the_building_coder_samples,代码行数:88,代码来源:CmdCollectorPerformance.cs

示例6: GetSolid

        /// <summary>
        /// Obsolete, since a single element may contain
        /// more than one solid that really needs 
        /// exporting, e.g. the fireplace in 
        /// rac_basic_sample_project.rvt.
        /// Replaced by the ExportSolids + ExportSolid 
        /// methods.
        /// Retrieve the first non-empty solid found for 
        /// the given element. In case it is a family 
        /// instance, it may have its own non-empty solid, 
        /// in which case we use that. 
        /// Otherwise we search the symbol geometry. 
        /// If we use the symbol geometry, we might have 
        /// to keep track of the instance transform to map 
        /// it to the actual instance project location. 
        /// Instead, we ask for transformed geometry to be 
        /// returned, so the resulting solid is already in 
        /// place.
        /// </summary>
        Solid GetSolid( Element e, Options opt )
        {
            Solid solid = null;

              GeometryElement geo = e.get_Geometry( opt );

              if( null != geo )
              {
            if( e is FamilyInstance )
            {
              geo = geo.GetTransformed(
            Transform.Identity );
            }

            GeometryInstance inst = null;
            //Transform t = Transform.Identity;

            // Some columns have no solids, and we have to
            // retrieve the geometry from the symbol;
            // others do have solids on the instance itself
            // and no contents in the instance geometry
            // (e.g. in rst_basic_sample_project.rvt).

            foreach( GeometryObject obj in geo )
            {
              solid = obj as Solid;

              if( null != solid
            && 0 < solid.Faces.Size )
              {
            break;
              }

              inst = obj as GeometryInstance;
            }

            if( null == solid && null != inst )
            {
              geo = inst.GetSymbolGeometry();
              //t = inst.Transform;

              foreach( GeometryObject obj in geo )
              {
            solid = obj as Solid;

            if( null != solid
              && 0 < solid.Faces.Size )
            {
              break;
            }
              }
            }
              }
              return solid;
        }
开发者ID:dangwalsh,项目名称:OBJExport,代码行数:74,代码来源:Command.cs

示例7: AddObjectsToTree

        protected void AddObjectsToTree(Element elem, TreeNodeCollection curNodes)
        {
            Autodesk.Revit.DB.Options geomOp = m_app.Create.NewGeometryOptions();
             geomOp.ComputeReferences = true;
             TreeNode tmpNode;

             // add geometry with the View set to null.
             TreeNode rootNode1 = new TreeNode("View = null");
             curNodes.Add(rootNode1);

             tmpNode = new TreeNode("Detail Level = Undefined");
             geomOp.DetailLevel = ViewDetailLevel.Undefined;
             tmpNode.Tag = elem.get_Geometry(geomOp);
             rootNode1.Nodes.Add(tmpNode);

             tmpNode = new TreeNode("Detail Level = Coarse");
             geomOp.DetailLevel = ViewDetailLevel.Coarse;
             tmpNode.Tag = elem.get_Geometry(geomOp);
             rootNode1.Nodes.Add(tmpNode);

             tmpNode = new TreeNode("Detail Level = Medium");
             geomOp.DetailLevel = ViewDetailLevel.Medium;
             tmpNode.Tag = elem.get_Geometry(geomOp);
             rootNode1.Nodes.Add(tmpNode);

             tmpNode = new TreeNode("Detail Level = Fine");
             geomOp.DetailLevel = ViewDetailLevel.Fine;
             tmpNode.Tag = elem.get_Geometry(geomOp);
             rootNode1.Nodes.Add(tmpNode);

             // SOFiSTiK FS
             // add model geometry including geometry objects not set as Visible.
             {
            Autodesk.Revit.DB.Options opts = m_app.Create.NewGeometryOptions();
            opts.ComputeReferences = true;
            opts.IncludeNonVisibleObjects = true;

            TreeNode rootNode = new TreeNode("View = null - Including geometry objects not set as Visible");
            curNodes.Add(rootNode);

            tmpNode = new TreeNode("Detail Level = Undefined");
            opts.DetailLevel = ViewDetailLevel.Undefined;
            tmpNode.Tag = elem.get_Geometry(opts);
            rootNode.Nodes.Add(tmpNode);

            tmpNode = new TreeNode("Detail Level = Coarse");
            opts.DetailLevel = ViewDetailLevel.Coarse;
            tmpNode.Tag = elem.get_Geometry(opts);
            rootNode.Nodes.Add(tmpNode);

            tmpNode = new TreeNode("Detail Level = Medium");
            opts.DetailLevel = ViewDetailLevel.Medium;
            tmpNode.Tag = elem.get_Geometry(opts);
            rootNode.Nodes.Add(tmpNode);

            tmpNode = new TreeNode("Detail Level = Fine");
            opts.DetailLevel = ViewDetailLevel.Fine;
            tmpNode.Tag = elem.get_Geometry(opts);
            rootNode.Nodes.Add(tmpNode);
             }

             // now add geometry with the View set to the current view
             if (elem.Document.ActiveView != null)
             {
            Options geomOp2 = m_app.Create.NewGeometryOptions();
            geomOp2.ComputeReferences = true;
            geomOp2.View = elem.Document.ActiveView;

            TreeNode rootNode2 = new TreeNode("View = Document.ActiveView");
            rootNode2.Tag = elem.get_Geometry(geomOp2);
            curNodes.Add(rootNode2);

            // SOFiSTiK FS
            // add model geometry including geometry objects not set as Visible.
            {
               Autodesk.Revit.DB.Options opts = m_app.Create.NewGeometryOptions();
               opts.ComputeReferences = true;
               opts.IncludeNonVisibleObjects = true;
               opts.View = elem.Document.ActiveView;

               TreeNode rootNode = new TreeNode("View = Document.ActiveView - Including geometry objects not set as Visible");
               curNodes.Add(rootNode);

               rootNode.Tag = elem.get_Geometry(opts);
            }
             }
        }
开发者ID:jeremytammik,项目名称:RevitLookup,代码行数:87,代码来源:Geometry.cs

示例8: GetBiggestFaceFacingUser

        /// <summary>
        /// Gets the biggest face which faces the user.  Assumes that the element is a wall, or floor, or other "2-sided" element, and that
        /// one of the two biggest faces will be facing roughly towards the viewer.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="viewDirection">The view direction.</param>
        /// <returns>The face.  Face.Reference will also be populated.</returns>
        private static Face GetBiggestFaceFacingUser(Element element, XYZ viewDirection)
        {
            // Holds the faces sorted by area
            SortedDictionary<double, List<Face>> faceAreas = new SortedDictionary<double, List<Face>>();

            // Get the element geometry
            Options options = new Options();
            options.ComputeReferences = true;
            GeometryElement geomElem = element.get_Geometry(options);

            // Look at the faces in each solid
            foreach (GeometryObject geomObj in geomElem.Objects)
            {
                Solid solid = geomObj as Solid;
                if (solid != null)
                {
                    foreach (Face face in solid.Faces)
                    {
                        double area = face.Area;
                        // Save the face to the collection
                        if (faceAreas.ContainsKey(area))
                        {
                            faceAreas[area].Add(face);
                        }
                        else
                        {
                            List<Face> faces = new List<Face>();
                            faces.Add(face);
                            faceAreas.Add(area, faces);
                        }
                    }
                }
            }

            // Get biggest two faces.  There might be two faces in the last item, or one face in the last item.
            int count = faceAreas.Count;
            KeyValuePair<double, List<Face>> faceCollection1 = faceAreas.ElementAt<KeyValuePair<double, List<Face>>>(count - 1);
            KeyValuePair<double, List<Face>> faceCollection2 = faceAreas.ElementAt<KeyValuePair<double, List<Face>>>(count - 2);

            Face face1 = null;
            Face face2 = null;
            // Two or more equal faces.  Use the first two.
            if (faceCollection1.Value.Count > 1)
            {
                face1 = faceCollection1.Value[0];
                face2 = faceCollection1.Value[1];
            }
            // One largest face.  Use the first face from the next item for comparison.
            else
            {
                face1 = faceCollection1.Value[0];
                face2 = faceCollection2.Value[0];
            }

            // Compute face normal
            BoundingBoxUV box = face1.GetBoundingBox();
            UV faceCenter = (box.Max + box.Min) / 2;
            XYZ faceNormal = face1.ComputeNormal(faceCenter).Normalize();

            // Compute angle to the view direction.  If less than 90 degrees, keep this face.
            double angle = viewDirection.AngleTo(faceNormal);

            Face biggestFace = null;
            if (Math.Abs(angle) < Math.PI / 2)
                biggestFace = face1;
            else
                biggestFace = face2;

            return biggestFace;
        }
开发者ID:AMEE,项目名称:revit,代码行数:77,代码来源:MultithreadedCalculation.cs

示例9: ExportPart

        /// <summary>
        /// Export the individual part (IfcBuildingElementPart).
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="partElement">The part element to export.</param>
        /// <param name="geometryElement">The geometry of part.</param>
        /// <param name="productWrapper">The IFCProductWrapper object.</param>
        public static void ExportPart(ExporterIFC exporterIFC, Element partElement, IFCProductWrapper productWrapper,
            IFCPlacementSetter placementSetter, IFCAnyHandle originalPlacement, IFCRange range, IFCExtrusionAxes ifcExtrusionAxes,
            Element hostElement, ElementId overrideLevelId, bool asBuildingElement)
        {
            if (!ElementFilteringUtil.IsElementVisible(ExporterCacheManager.ExportOptionsCache.FilterViewForExport, partElement))
                return;

            Part part = partElement as Part;
            if (part == null)
                return;

            IFCPlacementSetter standalonePlacementSetter = null;
            bool standaloneExport = hostElement == null && !asBuildingElement;

            ElementId partExportLevel = null;
            if (standaloneExport || asBuildingElement)
            {
                if (partElement.Level != null)
                    partExportLevel = partElement.Level.Id;
            }
            else
            {
                if (part.OriginalCategoryId != hostElement.Category.Id)
                    return;
                partExportLevel = hostElement.Level.Id;
            }
            if (overrideLevelId != null)
                partExportLevel = overrideLevelId;

            if (ExporterCacheManager.PartExportedCache.HasExported(partElement.Id, partExportLevel))
                return;

            Options options = GeometryUtil.GetIFCExportGeometryOptions();
            View ownerView = partElement.Document.GetElement(partElement.OwnerViewId) as View;
            if (ownerView != null)
                options.View = ownerView;

            GeometryElement geometryElement = partElement.get_Geometry(options);
            if (geometryElement == null)
                return;

            try
            {
                IFCFile file = exporterIFC.GetFile();
                using (IFCTransaction transaction = new IFCTransaction(file))
                {
                    IFCAnyHandle partPlacement = null;
                    if (standaloneExport || asBuildingElement)
                    {
                        Transform orientationTrf = Transform.Identity;
                        standalonePlacementSetter = IFCPlacementSetter.Create(exporterIFC, partElement, null, orientationTrf, partExportLevel);
                        partPlacement = standalonePlacementSetter.GetPlacement();
                    }
                    else
                        partPlacement = ExporterUtil.CopyLocalPlacement(file, originalPlacement);

                    bool validRange = (range != null && !MathUtil.IsAlmostZero(range.Start - range.End));

                    SolidMeshGeometryInfo solidMeshInfo;
                    if (validRange)
                    {
                        solidMeshInfo = GeometryUtil.GetClippedSolidMeshGeometry(geometryElement, range);
                        if (solidMeshInfo.GetSolids().Count == 0 && solidMeshInfo.GetMeshes().Count == 0)
                            return;
                    }
                    else
                    {
                        solidMeshInfo = GeometryUtil.GetSolidMeshGeometry(geometryElement, Transform.Identity);
                    }

                    using (IFCExtrusionCreationData extrusionCreationData = new IFCExtrusionCreationData())
                    {
                        extrusionCreationData.SetLocalPlacement(partPlacement);
                        extrusionCreationData.ReuseLocalPlacement = false;
                        extrusionCreationData.PossibleExtrusionAxes = ifcExtrusionAxes;

                        IList<Solid> solids = solidMeshInfo.GetSolids();
                        IList<Mesh> meshes = solidMeshInfo.GetMeshes();

                        ElementId catId = CategoryUtil.GetSafeCategoryId(partElement);

                        BodyData bodyData = null;
                        BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
                        if (solids.Count > 0 || meshes.Count > 0)
                        {
                            bodyData = BodyExporter.ExportBody(partElement.Document.Application, exporterIFC, partElement, catId, solids, meshes,
                                bodyExporterOptions, extrusionCreationData);
                        }
                        else
                        {
                            IList<GeometryObject> geomlist = new List<GeometryObject>();
                            geomlist.Add(geometryElement);
                            bodyData = BodyExporter.ExportBody(partElement.Document.Application, exporterIFC, partElement, catId, geomlist,
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:BIM-IFC,代码行数:101,代码来源:PartExporter.cs

示例10: ParseElementGeometry

 private static void ParseElementGeometry(Element e, List<XYZ> pts)
 {
     foreach (GeometryObject gObj in e.get_Geometry(dynRevitSettings.GeometryOptions))
     {
         if (gObj is Solid)
         {
             ParseSolid(gObj, pts);
         }
         else if (gObj is GeometryInstance)
         {
             ParseInstanceGeometry(gObj, pts);
         }
     }
 }
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:14,代码来源:View.cs

示例11: ExportCurtainObjectCommonAsOneBRep

        /// <summary>
        /// Exports curtain object as one Brep.
        /// </summary>
        /// <param name="allSubElements">
        /// Collection of elements contained in the host curtain element.
        /// </param>
        /// <param name="wallElement">
        /// The curtain wall element.
        /// </param>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="setter">
        /// The PlacementSetter object.
        /// </param>
        /// <param name="localPlacement">
        /// The local placement handle.
        /// </param>
        /// <returns>
        /// The handle.
        /// </returns>
        public static IFCAnyHandle ExportCurtainObjectCommonAsOneBRep(ICollection<ElementId> allSubElements, Element wallElement,
           ExporterIFC exporterIFC, PlacementSetter setter, IFCAnyHandle localPlacement)
        {
            IFCAnyHandle prodDefRep = null;
            Document document = wallElement.Document;
            double eps = UnitUtil.ScaleLength(document.Application.VertexTolerance);

            IFCFile file = exporterIFC.GetFile();
            IFCAnyHandle contextOfItems = exporterIFC.Get3DContextHandle("Body");

            IFCGeometryInfo info = IFCGeometryInfo.CreateFaceGeometryInfo(eps);

            ISet<IFCAnyHandle> bodyItems = new HashSet<IFCAnyHandle>();

            // Want to make sure we don't accidentally add a mullion or curtain line more than once.
            HashSet<ElementId> alreadyVisited = new HashSet<ElementId>();
            bool useFallbackBREP = true;
            Options geomOptions = GeometryUtil.GetIFCExportGeometryOptions();

            foreach (ElementId subElemId in allSubElements)
            {
                Element subElem = wallElement.Document.GetElement(subElemId);
                GeometryElement geomElem = subElem.get_Geometry(geomOptions);
                if (geomElem == null)
                    continue;

                if (alreadyVisited.Contains(subElem.Id))
                    continue;
                alreadyVisited.Add(subElem.Id);


                // Export tessellated geometry when IFC4 Reference View is selected
                if (ExporterCacheManager.ExportOptionsCache.ExportAs4ReferenceView)
                {
                    BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(false);
                    IFCAnyHandle triFaceSet = BodyExporter.ExportBodyAsTriangulatedFaceSet(exporterIFC, subElem, bodyExporterOptions, geomElem);
                    if (!IFCAnyHandleUtil.IsNullOrHasNoValue(triFaceSet))
                    {
                        bodyItems.Add(triFaceSet);
                        useFallbackBREP = false;    // no need to do Brep since it is successful
                    }
                }
                // Export AdvancedFace before use fallback BREP
                else if (ExporterCacheManager.ExportOptionsCache.ExportAs4DesignTransferView)
                {
                    BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(false);
                    IFCAnyHandle advancedBRep = BodyExporter.ExportBodyAsAdvancedBrep(exporterIFC, subElem, bodyExporterOptions, geomElem);
                    if (!IFCAnyHandleUtil.IsNullOrHasNoValue(advancedBRep))
                    {
                        bodyItems.Add(advancedBRep);
                        useFallbackBREP = false;    // no need to do Brep since it is successful
                    }
                }

                if (useFallbackBREP)
                {
                    ExporterIFCUtils.CollectGeometryInfo(exporterIFC, info, geomElem, XYZ.Zero, false);
                    HashSet<IFCAnyHandle> faces = new HashSet<IFCAnyHandle>(info.GetSurfaces());
                    IFCAnyHandle outer = IFCInstanceExporter.CreateClosedShell(file, faces);

                    if (!IFCAnyHandleUtil.IsNullOrHasNoValue(outer))
                        bodyItems.Add(RepresentationUtil.CreateFacetedBRep(exporterIFC, document, outer, ElementId.InvalidElementId));
                }
            }

            if (bodyItems.Count == 0)
                return prodDefRep;

            ElementId catId = CategoryUtil.GetSafeCategoryId(wallElement);
            IFCAnyHandle shapeRep;

            // Use tessellated geometry in Reference View
            if (ExporterCacheManager.ExportOptionsCache.ExportAs4ReferenceView && !useFallbackBREP)
                shapeRep = RepresentationUtil.CreateTessellatedRep(exporterIFC, wallElement, catId, contextOfItems, bodyItems, null);
            else if (ExporterCacheManager.ExportOptionsCache.ExportAs4DesignTransferView && !useFallbackBREP)
                shapeRep = RepresentationUtil.CreateAdvancedBRepRep(exporterIFC, wallElement, catId, contextOfItems, bodyItems, null);
            else
                shapeRep = RepresentationUtil.CreateBRepRep(exporterIFC, wallElement, catId, contextOfItems, bodyItems);

//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:101,代码来源:CurtainSystemExporter.cs

示例12: _get2DRepresentation

        /*
          * Lot of code here implementing the
          * "IExportContext" interface...
          */
        private GeometryElement _get2DRepresentation(
            Element element)
        {
            View view = this._get2DViewForElement( element );
              if( view == null )
            return null;

              Options options = new Options();
              options.View = view;
              return element.get_Geometry( options );
        }
开发者ID:jeremytammik,项目名称:the_building_coder_samples,代码行数:15,代码来源:CmdCollectorPerformance.cs

示例13: ExportElementImpl

        /// <summary>
        /// Implements the export of element.
        /// </summary>
        /// <param name="exporterIFC">The IFC exporter object.</param>
        /// <param name="element ">The element to export.</param>
        /// <param name="productWrapper">The IFCProductWrapper object.</param>
        private void ExportElementImpl(ExporterIFC exporterIFC, Element element, IFCProductWrapper productWrapper)
        {
            Options options = new Options();
            View ownerView = element.Document.get_Element(element.OwnerViewId) as View;
            if (ownerView != null)
                options.View = ownerView;
            GeometryElement geomElem = element.get_Geometry(options);

            try
            {
                exporterIFC.PushExportState(element, geomElem);

                using (SubTransaction st = new SubTransaction(element.Document))
                {
                    st.Start();

                    if (element is CurveElement)
                    {
                        CurveElement curveElem = element as CurveElement;
                        CurveElementExporter.ExportCurveElement(exporterIFC, curveElem, geomElem, productWrapper, m_CurveAnnotationCache);
                    }
                    else if (element is FamilyInstance)
                    {
                        FamilyInstance familyInstanceElem = element as FamilyInstance;
                        FamilyInstanceExporter.ExportFamilyInstanceElement(exporterIFC, familyInstanceElem, geomElem, productWrapper);
                    }
                    else if (element is Floor)
                    {
                        Floor floorElem = element as Floor;
                        FloorExporter.ExportFloor(exporterIFC, floorElem, geomElem, productWrapper);
                    }
                    else if (element is SpatialElement)
                    {
                        SpatialElement spatialElem = element as SpatialElement;
                        SpatialElementExporter.ExportSpatialElement(exporterIFC, spatialElem, productWrapper);
                    }
                    else if (element is TextNote)
                    {
                        TextNote textNote = element as TextNote;
                        TextNoteExporter.Export(exporterIFC, textNote, productWrapper, m_PresentationStyleCache);
                    }
                    else if (element is Wall)
                    {
                        Wall wallElem = element as Wall;
                        WallExporter.Export(exporterIFC, wallElem, geomElem, productWrapper);
                    }
                    else if (IsMEPType(exporterIFC, element))
                    {
                        GenericMEPExporter.Export(exporterIFC, element, geomElem, productWrapper);
                    }
                    else if (element is FilledRegion)
                    {
                        // FilledRegion is still handled by internal Revit code, but the get_Geometry call makes sure
                        // that the Owner view is clean before we get the region's GeometryElement.
                        ExporterIFCUtils.ExportElementInternal(exporterIFC, element, productWrapper);
                    }

                    st.RollBack();
                }
            }
            finally
            {
                exporterIFC.PopExportState();
            }
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:71,代码来源:Exporter.cs

示例14: GetElementSolid

        /// <summary>
        /// Extract the Solid of given element.
        /// </summary>
        /// <param name="element">Given Element to get its Solid</param>
        /// <returns>Solid of given element</returns>
        private static Solid GetElementSolid(Element element)
        {
            Options goption = new Options();
            goption.ComputeReferences = true;
            GeometryElement gelem = element.get_Geometry(goption);
            Solid resultSolid = null;
            foreach (GeometryObject gobj in gelem.Objects)
            {
                GeometryInstance gIns = gobj as GeometryInstance;
                if (gIns != null)
                {
                    GeometryElement finalGeom = gIns.GetInstanceGeometry();
                    foreach (GeometryObject gobj2 in finalGeom.Objects)
                    {
                        Solid tSolid = gobj2 as Solid;
                        if (tSolid != null && tSolid.Faces.Size > 0 && tSolid.Volume > 0)
                        {
                            resultSolid = tSolid;
                            break;
                        }
                    }
                }

                if (resultSolid == null)
                {
                    Solid tSolid2 = gobj as Solid;
                    if (tSolid2 != null && tSolid2.Faces.Size > 0 && tSolid2.Volume > 0)
                    {
                        resultSolid = tSolid2;
                        break;
                    }
                }
            }

            return resultSolid;
        }
开发者ID:AMEE,项目名称:revit,代码行数:41,代码来源:GeometryUtil.cs

示例15: ExportPart

        /// <summary>
        /// Export the individual part (IfcBuildingElementPart).
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="partElement">The part element to export.</param>
        /// <param name="geometryElement">The geometry of part.</param>
        /// <param name="productWrapper">The ProductWrapper object.</param>
        public static void ExportPart(ExporterIFC exporterIFC, Element partElement, ProductWrapper productWrapper,
            PlacementSetter placementSetter, IFCAnyHandle originalPlacement, IFCRange range, IFCExtrusionAxes ifcExtrusionAxes,
            Element hostElement, ElementId overrideLevelId, bool asBuildingElement)
        {
            if (!ElementFilteringUtil.IsElementVisible(partElement))
                return;

            Part part = partElement as Part;
            if (part == null)
                return;

            PlacementSetter standalonePlacementSetter = null;
            bool standaloneExport = hostElement == null && !asBuildingElement;

            ElementId partExportLevel = null;
            if (standaloneExport || asBuildingElement)
            {
                partExportLevel = partElement.LevelId;
            }
            else
            {
                if (part.OriginalCategoryId != hostElement.Category.Id)
                    return;
                partExportLevel = hostElement.LevelId;
            }
            if (overrideLevelId != null)
                partExportLevel = overrideLevelId;

            if (ExporterCacheManager.PartExportedCache.HasExported(partElement.Id, partExportLevel))
                return;

            Options options = GeometryUtil.GetIFCExportGeometryOptions();
            View ownerView = partElement.Document.GetElement(partElement.OwnerViewId) as View;
            if (ownerView != null)
                options.View = ownerView;

            GeometryElement geometryElement = partElement.get_Geometry(options);
            if (geometryElement == null)
                return;

            try
            {
                IFCFile file = exporterIFC.GetFile();
                using (IFCTransaction transaction = new IFCTransaction(file))
                {
                    IFCAnyHandle partPlacement = null;
                    if (standaloneExport || asBuildingElement)
                    {
                        Transform orientationTrf = Transform.Identity;
                        standalonePlacementSetter = PlacementSetter.Create(exporterIFC, partElement, null, orientationTrf, partExportLevel);
                        partPlacement = standalonePlacementSetter.LocalPlacement;
                    }
                    else
                    {
                        partPlacement = ExporterUtil.CreateLocalPlacement(file, originalPlacement, null);
                    }

                    bool validRange = (range != null && !MathUtil.IsAlmostZero(range.Start - range.End));

                    SolidMeshGeometryInfo solidMeshInfo;
                    if (validRange)
                    {
                        solidMeshInfo = GeometryUtil.GetSplitClippedSolidMeshGeometry(geometryElement, range);
                        if (solidMeshInfo.GetSolids().Count == 0 && solidMeshInfo.GetMeshes().Count == 0)
                            return;
                    }
                    else
                    {
                        solidMeshInfo = GeometryUtil.GetSplitSolidMeshGeometry(geometryElement);
                    }

                    using (IFCExtrusionCreationData extrusionCreationData = new IFCExtrusionCreationData())
                    {
                        extrusionCreationData.SetLocalPlacement(partPlacement);
                        extrusionCreationData.ReuseLocalPlacement = false;
                        extrusionCreationData.PossibleExtrusionAxes = ifcExtrusionAxes;

                        IList<Solid> solids = solidMeshInfo.GetSolids();
                        IList<Mesh> meshes = solidMeshInfo.GetMeshes();

                        ElementId catId = CategoryUtil.GetSafeCategoryId(partElement);
                        ElementId hostCatId = CategoryUtil.GetSafeCategoryId(hostElement);

                        BodyData bodyData = null;
                        BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
                        if (solids.Count > 0 || meshes.Count > 0)
                        {
                            bodyData = BodyExporter.ExportBody(exporterIFC, partElement, catId, ElementId.InvalidElementId, solids, meshes,
                                bodyExporterOptions, extrusionCreationData);
                        }
                        else
                        {
                            IList<GeometryObject> geomlist = new List<GeometryObject>();
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:101,代码来源:PartExporter.cs


注:本文中的Element.get_Geometry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。