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


C# ElementSet.Insert方法代码示例

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


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

示例1: Execute

 /// <summary>
 /// Implement this method as an external command for Revit.
 /// </summary>
 /// <param name="commandData">An object that is passed to the external application 
 /// which contains data related to the command, 
 /// such as the application object and active view.</param>
 /// <param name="message">A message that can be set by the external application 
 /// which will be displayed if a failure or cancellation is returned by 
 /// the external command.</param>
 /// <param name="elements">A set of elements to which the external application 
 /// can add elements that are to be highlighted in case of failure or cancellation.</param>
 /// <returns>Return the status of the external command. 
 /// A result of Succeeded means that the API external method functioned as expected. 
 /// Cancelled can be used to signify that the user cancelled the external operation 
 /// at some point. Failure should be returned if the application is unable to proceed with 
 /// the operation.</returns>
 public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
                                        ref string message,
                                        ElementSet elements)
 {
     try
     {
         Transaction documentTransaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "Document");
         documentTransaction.Start();
         using (SpotDimensionInfoDlg infoForm = new SpotDimensionInfoDlg(commandData))
         {
             //Highlight the selected spotdimension
             if (infoForm.ShowDialog() == System.Windows.Forms.DialogResult.OK
                 && infoForm.SelectedSpotDimension != null)
             {
                 elements.Insert(infoForm.SelectedSpotDimension);
                 message = "High light the selected SpotDimension";
                 return Autodesk.Revit.UI.Result.Failed;
             }
         }
         documentTransaction.Commit();
         return Autodesk.Revit.UI.Result.Succeeded;
     }
     catch (Exception ex)
     {
        // If there are something wrong, give error information and return failed
        message = ex.Message;
        return Autodesk.Revit.UI.Result.Failed;
     }
 }
开发者ID:AMEE,项目名称:revit,代码行数:45,代码来源:Command.cs

示例2: GetAllSheets

        /// <summary>
        /// Gather up all the available sheets.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="sheet"></param>
        /// <returns></returns>
        public static ElementSet GetAllSheets(Document doc)
        {
            ElementSet allSheets = new ElementSet();
            FilteredElementCollector fec = new FilteredElementCollector(doc);
            ElementClassFilter elementsAreWanted = new ElementClassFilter(typeof(ViewSheet));
            fec.WherePasses(elementsAreWanted);
            List<Element> elements = fec.ToElements() as List<Element>;

            foreach (Element element in elements)
            {
               ViewSheet viewSheet = element as ViewSheet;

               if (null == viewSheet)
               {
                  continue;
               }
               else
               {
                  ElementId objId = viewSheet.GetTypeId();
                  if (ElementId.InvalidElementId == objId)
                  {
                     continue;
                  }
                  else
                  {
                     allSheets.Insert(viewSheet);
                  }
               }
            }

            return allSheets;
        }
开发者ID:halad,项目名称:RevitLookup,代码行数:38,代码来源:View.cs

示例3: FilterToCategory

        /// <summary>
        /// Given an Enumerable set of Elements, walk through them and filter out the ones of a specific 
        /// category.
        /// </summary>
        /// <param name="set">The unfiltered set</param>
        /// <param name="filterForCategoryEnum">The BuiltInCategory enum to filter for</param>
        /// <param name="doc">The current Document object</param>
        /// <returns>The filtered ElementSet</returns>
        public static ElementSet FilterToCategory(IEnumerable set, BuiltInCategory filterForCategoryEnum, bool includeSymbols, Document doc)
        {
            // get the
            Category filterForCategory = doc.Settings.Categories.get_Item(filterForCategoryEnum);
            Debug.Assert(filterForCategory != null);

            ElementSet filteredSet = new ElementSet();

            IEnumerator iter = set.GetEnumerator();
            while (iter.MoveNext()) {
                Element elem = (Element)iter.Current;
                if (elem.Category == filterForCategory) {
                    if (includeSymbols)
                        filteredSet.Insert(elem);   // include it no matter what
                    else {
                        if (elem is ElementType == false)    // include it only if its not a symbol
                            filteredSet.Insert(elem);
                    }
                }
            }

            return filteredSet;
        }
开发者ID:halad,项目名称:RevitLookup,代码行数:31,代码来源:Selection.cs

示例4: GetSelectedModelLinesAndArcs

        /// <summary>
        /// Get all model and detail lines/arcs within selected elements
        /// </summary>
        /// <param name="document">Revit's document</param>
        /// <returns>ElementSet contains all model and detail lines/arcs within selected elements </returns>
        public static ElementSet GetSelectedModelLinesAndArcs(Document document)
        {
            UIDocument newUIdocument = new UIDocument(document);
            ElementSet elements = newUIdocument.Selection.Elements;
            ElementSet tmpSet = new ElementSet();
            foreach (Autodesk.Revit.DB.Element element in elements)
            {
                if ((element is ModelLine) || (element is ModelArc) || (element is DetailLine) || (element is DetailArc))
                {
                    tmpSet.Insert(element);
                }
            }

            return tmpSet;
        }
开发者ID:AMEE,项目名称:revit,代码行数:20,代码来源:Command.cs

示例5: Execute

        public IExternalCommand.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            int ii = 0;
            message = "Error elements with highlight"; //这行不能少,必须给message赋值
            ElementSetIterator it = commandData.Application.ActiveDocument.Selection.Elements.ForwardIterator();
            while (it.MoveNext())
            {
                Element e = it.Current as Element;
                if (e == null) continue;
                elements.Insert(e);
                if (++ii > 2) break;
            }

            return IExternalCommand.Result.Failed;
        }
开发者ID:guchanghai,项目名称:Cut,代码行数:15,代码来源:HighlightElements.cs

示例6: Execute

        public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
            ref string message, ElementSet elements)
        {
            UIApplication uiApp = commandData.Application;
            Autodesk.Revit.ApplicationServices.Application app = uiApp.Application;
            Document doc = uiApp.ActiveUIDocument.Document;

            string strAppInfo = app.VersionBuild + ";" + app.VersionName + ";" + app.VersionNumber + ";";
            Autodesk.Revit.UI.Selection.Selection sel = uiApp.ActiveUIDocument.Selection;
            foreach (Element elem in sel.Elements)
            {
                elements.Insert(elem);
            }
            message = "当前选择集中包含如下对象";

            //为了显示错误信息框需要返回Failed
            return Result.Failed;
        }
开发者ID:zxx2112,项目名称:Revittest,代码行数:18,代码来源:Class1.cs

示例7: SimpleShed

        /// <summary>
        /// Creates a simple shed consisting of a door, window, a few floors and walls
        /// </summary>
        public void SimpleShed()
        {
            FamilySymbol doorSymbol = null;
              FamilySymbol windowSymbol = null;
              Family doorFamily = null;
              Family windowFamily = null;
              Autodesk.Revit.Creation.Document doc = m_revitApp.ActiveUIDocument.Document.Create;
              Revit.Document docu = m_revitApp.ActiveUIDocument.Document;
              Autodesk.Revit.Creation.Application applic = m_revitApp.Application.Create;

              //The levels for the floors and the fake roof
              Level floorLevel = null;
              Level midLevel = null;

              Revit.ElementSet wallSet = new ElementSet();

              // Create a new CurveArray to provide the profile of the walls to the floor
              CurveArray curArray = applic.NewCurveArray();

              // iterate through all available levels...
              FilteredElementCollector fec = new FilteredElementCollector( m_revitApp.ActiveUIDocument.Document );
              ElementClassFilter elementsAreWanted = new ElementClassFilter( typeof( Level ) );
              fec.WherePasses( elementsAreWanted );
              List<Element> elements = fec.ToElements() as List<Element>;

              foreach( Element element in elements )
              {
            Level sysLevel = element as Level;
            if( sysLevel != null )
            {
              String name = sysLevel.Name;

              if( name == "Level 1" )
              {
            floorLevel = sysLevel;
              }

              if( name == "Level 2" )
              {
            midLevel = sysLevel;
              }
            }
              }

              // first create 4 walls

              // wall1
              XYZ pt1 = new XYZ( 10.0, 10.0, 0.0 );
              XYZ pt2 = new XYZ( 30.0, 10.0, 0.0 );

              Line line = Line.CreateBound( pt1, pt2 );

              Wall windowHost = Wall.Create( docu, line, floorLevel.Id, false );

              curArray.Append( line );
              wallSet.Insert( windowHost );

              Revit.ElementId windowHostId = windowHost.Id;
              m_shedElements.Add( windowHostId );

              // wall2
              XYZ pt3 = new XYZ( 10.0, 10.0, 0.0 );
              XYZ pt4 = new XYZ( 10.0, 30.0, 0.0 );

              Line line1 = Line.CreateBound( pt3, pt4 );

              Wall wall2 = Wall.Create( docu, line1, floorLevel.Id, false );

              curArray.Append( line1 );
              wallSet.Insert( wall2 );

              Revit.ElementId wall2Id = wall2.Id;
              m_shedElements.Add( wall2Id );

              // wall3
              XYZ pt5 = new XYZ( 10.0, 30.0, 0.0 );
              XYZ pt6 = new XYZ( 30.0, 30.0, 0.0 );

              Line line2 = Line.CreateBound( pt5, pt6 );

              Wall doorHost = Wall.Create( docu, line2, floorLevel.Id, false );

              curArray.Append( line2 );
              wallSet.Insert( doorHost );

              Revit.ElementId doorHostId = doorHost.Id;
              m_shedElements.Add( doorHostId );

              // wall4
              XYZ pt7 = new XYZ( 30.0, 30.0, 0.0 );
              XYZ pt8 = new XYZ( 30.0, 10.0, 0.0 );

              Line line3 = Line.CreateBound( pt7, pt8 );

              Wall wall4 = Wall.Create( docu, line3, floorLevel.Id, false );

              curArray.Append( line3 );
//.........这里部分代码省略.........
开发者ID:halad,项目名称:RevitLookup,代码行数:101,代码来源:TestElements.cs

示例8: GetElementsOfType

        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        private ElementSet GetElementsOfType( Type type )
        {
            ElementSet elemSet = new ElementSet();
              FilteredElementCollector fec = new FilteredElementCollector( m_activeDoc );
              ElementClassFilter elementsAreWanted = new ElementClassFilter( type );
              fec.WherePasses( elementsAreWanted );
              List<Element> elements = fec.ToElements() as List<Element>;

              foreach( Element element in elements )
              {
            elemSet.Insert( element );
              }

              return elemSet;
        }
开发者ID:halad,项目名称:RevitLookup,代码行数:20,代码来源:Importer.cs

示例9: Initialize

        /// <summary>
        /// Initialize the data member
        /// </summary>
        private void Initialize()
        {
            Document doc = m_commandData.Application.ActiveUIDocument.Document;
            FilteredElementIterator iter = (new FilteredElementCollector(doc)).OfClass(typeof(Level)).GetElementIterator();
            iter.Reset();
            while (iter.MoveNext())
            {
                m_levels.Add(iter.Current as Level);
            }

            foreach (RoofType roofType in m_commandData.Application.ActiveUIDocument.Document.RoofTypes)
            {
                m_roofTypes.Add(roofType);
            }

            // FootPrint Roofs
            m_footPrintRoofs = new ElementSet();
            iter = (new FilteredElementCollector(doc)).OfClass(typeof(FootPrintRoof)).GetElementIterator();
            iter.Reset();
            while (iter.MoveNext())
            {
                m_footPrintRoofs.Insert(iter.Current as FootPrintRoof);
            }

            // Extrusion Roofs
            m_extrusionRoofs = new ElementSet();
            iter = (new FilteredElementCollector(doc)).OfClass(typeof(ExtrusionRoof)).GetElementIterator();
            iter.Reset();
            while (iter.MoveNext())
            {
                m_extrusionRoofs.Insert(iter.Current as ExtrusionRoof);
            }

            // Reference Planes
            iter = (new FilteredElementCollector(doc)).OfClass(typeof(ReferencePlane)).GetElementIterator();
            iter.Reset();
            while (iter.MoveNext())
            {
                ReferencePlane plane = iter.Current as ReferencePlane;
                // just use the vertical plane
                if (Math.Abs(plane.Normal.DotProduct(Autodesk.Revit.DB.XYZ.BasisZ)) < 1.0e-09)
                {
                    if (plane.Name == "Reference Plane")
                    {
                        plane.Name = "Reference Plane" + "(" + plane.Id.IntegerValue.ToString() + ")";
                    }
                    m_referencePlanes.Add(plane);
                }

            }
        }
开发者ID:AMEE,项目名称:revit,代码行数:54,代码来源:RoofsManager.cs

示例10: FilterElementTypes

        /// <summary>
        /// Have the user select a type of Element and then filter the document for all instances of that type.
        /// </summary>
        public void FilterElementTypes()
        {
            Test.Forms.Elements elems = new Test.Forms.Elements(m_revitApp);
             if (elems.ShowDialog() != DialogResult.OK)
            return;

             ElementSet elemSet = new ElementSet();

             FilteredElementCollector fec = new FilteredElementCollector(m_revitApp.ActiveUIDocument.Document);
             ElementClassFilter whatAreWanted = new ElementClassFilter(elems.ElemTypeSelected);
             fec.WherePasses(whatAreWanted);
             List<Element> elements = fec.ToElements() as List<Element>;

             foreach (Element element in elements)
             {
            elemSet.Insert(element);
             }

             Snoop.Forms.Objects objs = new Snoop.Forms.Objects(elemSet);
             objs.ShowDialog();
        }
开发者ID:jeremytammik,项目名称:RevitLookup,代码行数:24,代码来源:TestDocument.cs

示例11: Execute

        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            #region 1.2.a. Examine command data input argument:
              //
              // access application, document, and current view:
              //
              UIApplication uiapp = commandData.Application;
              Application app = uiapp.Application;
              UIDocument uidoc = uiapp.ActiveUIDocument;
              Document doc = uidoc.Document;
              View view = commandData.View;
              LanguageType lt = app.Language;
              ProductType pt = app.Product;
              string s = "Application = " + app.VersionName
            + "\r\nLanguage = " + lt.ToString()
            + "\r\nProduct = " + pt.ToString()
            + "\r\nVersion = " + app.VersionNumber
            + "\r\nDocument path = " + doc.PathName // empty if not yet saved
            + "\r\nDocument title = " + doc.Title
            + "\r\nView name = " + view.Name;
              LabUtils.InfoMsg( s );
              #endregion // 1.2.a. Examine command data input argument

              #region 1.2.b. List selection set content:
              //
              // list the current selection set:
              //
              Selection sel = uidoc.Selection;
              List<string> a = new List<string>();
              foreach( ElementId id in sel.GetElementIds() )
              {
            Element e = doc.GetElement( id );

            string name = ( null == e.Category )
              ? e.GetType().Name
              : e.Category.Name;

            a.Add( name + " Id="
              + e.Id.IntegerValue.ToString() );
              }
              LabUtils.InfoMsg(
            "There are {0} element{1} in the selection set{2}",
            a );

              #endregion // 1.2.b. List selection set content

              #region 1.2.c. Populate return arguments:

              // We pretend that something is wrong with the
              // first element in the selection. Pass an error
              // message back to the user and indicate the
              // error result:

              ICollection<ElementId> ids = sel.GetElementIds();

              if( 0 < ids.Count )
              {
            //ElementSetIterator iter = sel.Elements.ForwardIterator();
            //iter.MoveNext();
            //Element errElem = iter.Current as Element;

            Element errElem = doc.GetElement( ids.First()  );
            elements.Clear();
            elements.Insert( errElem );
            message = "We pretend something is wrong with this "
              + " element and pass back this message to user";

            return Result.Failed;
              }
              else
              {
            // We return failed here as well.
            // As long as the message string and element set are empty,
            // it makes no difference to the user.
            // If they are not empty, the message is displayed to the
            // user and/or the elements in the set are highlighted.
            // If an automatic transaction is open, it is aborted,
            // avoiding marking the database as dirty.

            return Result.Failed;
              }
              #endregion // 1.2.c. Populate return arguments
        }
开发者ID:jeremytammik,项目名称:AdnRevitApiLabsXtra,代码行数:86,代码来源:Labs1.cs

示例12: getCalculationElemSet

        private static int getCalculationElemSet(Document doc, string strDomain, ElementSet caculationOnElems, ElementSet elems)
        {
            if (doc == null)
            return 0;
             int nTotalCount = 0;
             foreach (Element elem in elems)
             {
            MEPSystem mepSys = elem as MEPSystem;
            if (mepSys == null)
               continue;
            Category category = mepSys.Category;
            BuiltInCategory enumCategory = (BuiltInCategory)category.Id.IntegerValue;

            if ( (strDomain == ReportResource.pipeDomain && enumCategory == BuiltInCategory.OST_PipingSystem) ||
                (strDomain == ReportResource.ductDomain && enumCategory == BuiltInCategory.OST_DuctSystem))
            {
               ++nTotalCount;
               MEPSystemType sysType = doc.GetElement(mepSys.GetTypeId()) as MEPSystemType;
               if (sysType != null && sysType.CalculationLevel == SystemCalculationLevel.All)
               {
                  caculationOnElems.Insert(mepSys);
               }
            }
             }
             return nTotalCount;
        }
开发者ID:jeremytammik,项目名称:UserMepCalculation,代码行数:26,代码来源:PressureLossReportEntry.cs

示例13: applyChanges

        void applyChanges(DataGridView gridView)
        {
            foreach (DataGridViewRow row in gridView.Rows)
            {
                var element = activeDoc.get_Element(row.Cells[0].Value as ElementId);
                ElementSet elementSet = new ElementSet();
                elementSet.Insert(element);

                Transaction transaction = new Transaction(activeDoc);
                transaction.Start(string.Format("Applying visibility of element {0}", element.Id.ToString()));

                if ((bool)row.Cells[2].Value == true)
                    activeView.Unhide(elementSet);
                else
                    if (element.CanBeHidden(activeView))
                        activeView.Hide(elementSet);

                transaction.Commit();
            }
        }
开发者ID:pzurek,项目名称:RevitExplorer,代码行数:20,代码来源:Application.cs

示例14: WallFilter

        /// <summary>
        /// Filter none-wall elements.
        /// </summary>
        /// <param name="miscellanea">The currently selected Elements in Autodesk Revit</param>
        /// <returns></returns>
        private static ElementSet WallFilter(ElementSet miscellanea)
        {
            ElementSet walls = new ElementSet();
            foreach (Autodesk.Revit.DB.Element e in miscellanea)
            {
                Wall w = e as Wall;
                if (null != w)
                {
                    walls.Insert(w);
                }
            }

            if (0 == walls.Size)
            {
                throw new InvalidOperationException("Please select wall first.");
            }

            return walls;
        }
开发者ID:AMEE,项目名称:revit,代码行数:24,代码来源:Data.cs


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