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


C# Document.GetElement方法代码示例

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


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

示例1: GetAllViews

        /// <summary>
        /// Finds all the views in the active document.
        /// </summary>
        /// <param name="doc">the active document</param>
        public static ViewSet GetAllViews (Document doc)
        {
            ViewSet allViews = new ViewSet();

            FilteredElementCollector fec = new FilteredElementCollector(doc);
            ElementClassFilter elementsAreWanted = new ElementClassFilter(typeof(FloorType));
            fec.WherePasses(elementsAreWanted);
            List<Element> elements = fec.ToElements() as List<Element>;

            foreach (Element element in elements)
            {
               Autodesk.Revit.DB.View view = element as Autodesk.Revit.DB.View;

               if (null == view)
               {
                  continue;
               }
               else
               {
                  
                  ElementType objType = doc.GetElement(view.GetTypeId()) as ElementType;
                  if (null == objType || objType.Name.Equals("Drawing Sheet"))
                  {
                     continue;
                  }
                  else
                  {
                     allViews.Insert(view);
                  }
               }
            }

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

示例2: Execute

        public Result Execute(
          ExternalCommandData commandData,
          ref string message,
          ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            doc = uidoc.Document;

            //creates a new instance of the wallselectionFilter
            ISelectionFilter wallfil = new WallSelectionFilter();

            //gets the object selected Elementid, applies the selection filter and the string mesasge
            ElementId obj = uidoc.Selection.PickObject(ObjectType.Element, wallfil, "Select a Wall please").ElementId;

            //gets the element from the ElementID
            Element e = doc.GetElement(obj);
            //get the family type Elementid
            ElementId idType = e.GetTypeId();
            //Get the Element Type ID
            Element pType = doc.GetElement(idType);

            //gets the instance length of the object
            string s = e.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsValueString();

            //gets the type width of the object
            string t = pType.get_Parameter(BuiltInParameter.WALL_ATTR_WIDTH_PARAM).AsValueString();

            //Shows the values
            TaskDialog.Show("Example", s + " " + t);

            return Result.Succeeded;
        }
开发者ID:Gytaco,项目名称:RevitAPI,代码行数:34,代码来源:Command.cs

示例3: RoomSpace

        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="spaceReference"></param>
        public RoomSpace(Document doc, Reference spaceReference)
        {
            m_doc = doc;
            LightFixtures = new List<LightFixture>();
            Space refSpace = m_doc.GetElement(spaceReference) as Space;

            // Set properties of newly create RoomSpace object from Space
            AverageEstimatedIllumination = refSpace.AverageEstimatedIllumination;
            Area = refSpace.Area;
            CeilingReflectance = refSpace.CeilingReflectance;
            FloorReflectance = refSpace.FloorReflectance;
            WallReflectance = refSpace.WallReflectance;
            CalcWorkPlane = refSpace.LightingCalculationWorkplane;
            ParentSpaceObject = refSpace;

            // Populate light fixtures list for RoomSpace
            FilteredElementCollector fec = new FilteredElementCollector(m_doc)
            .OfCategory(BuiltInCategory.OST_LightingFixtures)
            .OfClass(typeof(FamilyInstance));
            foreach (FamilyInstance fi in fec)
            {
                if (fi.Space.Id == refSpace.Id)
                {
                    ElementId eID = fi.GetTypeId();
                    Element e = m_doc.GetElement(eID);
                    //TaskDialog.Show("C","LF: SPACEID " + fi.Space.Id.ToString() + "\nSPACE ID: " + refSpace.Id.ToString());
                    LightFixtures.Add(new LightFixture(e,fi));
                }
            }
        }
开发者ID:kmorin,项目名称:LightingAnalysis,代码行数:35,代码来源:RoomSpace.cs

示例4: Ungroup

        public void Ungroup(Document doc, UIDocument uidoc)
        {
            IList<Category> categoryToDelete = new List<Category>();
            List<Group> ungroupList = new List<Group>();

            //Finds the groups in the project
            FilteredElementCollector collector = new FilteredElementCollector(uidoc.Document).OfClass(typeof(Group));
            FilteredElementIterator itr = collector.GetElementIterator();

            //Gets the dictionary to lookup line
            getLines getlines = new getLines(path);
            var dictionary = getlines.DictionaryLines();

            //iterators over all the groups
            while (itr.MoveNext())
            {
                Element element = (Element)itr.Current;
                Group group = doc.GetElement(element.Id) as Group;
                List<ElementId> groupElements = group.GetMemberIds().ToList();

                foreach (ElementId lineStyle in groupElements)
                {
                    Element elements = doc.GetElement(lineStyle);
                    CurveElement curveElement = elements as CurveElement;
                    try
                    {
                        string lineStyleName = curveElement.LineStyle.Name;
                        if (lineStyleName != null)
                        {
                            //compare lines to dictionary to ungroup.
                            if (dictionary.ContainsKey(lineStyleName))
                            {
                                ungroupList.Add(group);
                            }
                        }
                    }
                    catch { }
                }
            }

            foreach (Group group in ungroupList)
            {
                try
                {
                    ungroup(doc, group);
                    //CreateGroup(doc, uidoc);
                }
                catch { }
            }
        }
开发者ID:dannysbentley,项目名称:Delete-Change-Line-Styles,代码行数:50,代码来源:groups.cs

示例5: AddMaterial

        public void AddMaterial(Document inDocument, MaterialNode inNode)
        {
            if (!m_pMaterialDict.ContainsKey(inNode.MaterialId.IntegerValue))
            {
                Autodesk.Revit.DB.Material _revitMat = inDocument.GetElement(inNode.MaterialId) as Autodesk.Revit.DB.Material;
                if (_revitMat != null && _revitMat.IsValidObject)
                {
                    BoldarcManagedFbx.Material _mat = new BoldarcManagedFbx.Material(_revitMat.Name);

                    _mat.Red = _revitMat.Color.Red;
                    _mat.Green = _revitMat.Color.Green;
                    _mat.Blue = _revitMat.Color.Blue;
                    _mat.Shininess = _revitMat.Shininess;
                    _mat.Smoothness = _revitMat.Smoothness;
                    _mat.Transparency = _revitMat.Transparency;

                    m_pMaterialDict.Add(inNode.MaterialId.IntegerValue, _mat);
                    m_pCurrentMesh.MaterialIDPerFace.Add(m_pCurrentMesh.FaceCount, inNode.MaterialId.IntegerValue);
                }
                else
                    m_pCurrentMesh.MaterialIDPerFace.Add(m_pCurrentMesh.FaceCount, -1);
            }
            else
                m_pCurrentMesh.MaterialIDPerFace.Add(m_pCurrentMesh.FaceCount, inNode.MaterialId.IntegerValue);
        }
开发者ID:Ninjestra,项目名称:BoldArcRevitPlugin,代码行数:25,代码来源:FbxExporter.cs

示例6: GetClosestFace

        public static Tuple<Face, Reference> GetClosestFace(Document document, XYZ p)
        {
            Face resultFace = null;
            Reference resultReference = null;

            double min_distance = double.MaxValue;
            FilteredElementCollector collector = new FilteredElementCollector(document);
            var walls = collector.OfClass(typeof (Wall));
            foreach (Wall wall in walls)
            {
                IList<Reference> sideFaces =
                    HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior);
                // access the side face
                Face face = document.GetElement(sideFaces[0]).GetGeometryObjectFromReference(sideFaces[0]) as Face;
                var intersection = face.Project(p);

                if (intersection != null)
                {
                    if (intersection.Distance < min_distance)
                    {
                        resultFace = face;
                        resultReference = sideFaces[0];
                        min_distance = intersection.Distance;
                    }
                }
            }
            //resultFace.
            return new Tuple<Face,Reference>( resultFace, resultReference);
        }
开发者ID:KonbOgonb,项目名称:revit-psElectro-bridge,代码行数:29,代码来源:FindWallHelper.cs

示例7: WatcherMethodForAdd

 public void WatcherMethodForAdd(Document document, IEnumerable<ElementId> added)
 {
     foreach (ElementId id in added)
     {
         Add(document, id, document.GetElement(id).UniqueId);
     }
 }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:7,代码来源:ElementMapping.cs

示例8: Execute

    public Result Execute(
      ExternalCommandData commandData,
      ref string message,
      ElementSet elements)
    {
      // Get the access to the top most objects. 
      UIApplication rvtUIApp = commandData.Application;
      UIDocument uiDoc = rvtUIApp.ActiveUIDocument;
      _app = rvtUIApp.Application;
      _doc = uiDoc.Document;

      // Select a door on screen. (We'll come back to the selection in the UI Lab later.) 
      Reference r = uiDoc.Selection.PickObject(ObjectType.Element, "Pick a wall, please");
      // We have picked something. 
      Element e = _doc.GetElement(r);

      // (1) element level modification 
      // Modify element's properties, parameters, location. 

      ModifyElementPropertiesWall(e); 
      //ModifyElementPropertiesDoor(e);
      _doc.Regenerate();

      // Select an object on a screen. (We'll come back to the selection in the UI Lab later.) 
      Reference r2 = uiDoc.Selection.PickObject(ObjectType.Element, "Pick another element");
      // We have picked something. 
      Element e2 = _doc.GetElement(r2);

      // (2) you can also use transformation utility to move and rotate. 
      ModifyElementByTransformUtilsMethods(e2);

      return Result.Succeeded;
    }
开发者ID:FlintSable,项目名称:RevitTrainingMaterial,代码行数:33,代码来源:4_ElementModification.cs

示例9: FindElevationView

        /// <summary>
        /// Return the first elevation view found in the 
        /// given element id collection or null.
        /// </summary>
        static View FindElevationView(
            Document doc,
            ICollection<ElementId> ids)
        {
            View view = null;

              foreach( ElementId id in ids )
              {
            view = doc.GetElement( id ) as View;

            // Creating a new view template in Revit 2013
            // erroneously triggers the elevation trigger.

            if( view.IsTemplate
              && ViewType.Internal == view.ViewType )
            {
              view = null;
              continue;
            }

            if( null != view
              && ViewType.Elevation == view.ViewType )
            {
              break;
            }

            view = null;
              }
              return view;
        }
开发者ID:jeremytammik,项目名称:the_building_coder_samples,代码行数:34,代码来源:CmdElevationWatcher.cs

示例10: ElementDescription

 public static string ElementDescription(
   Document doc,
   int element_id)
 {
     return ElementDescription(doc.GetElement(
       new ElementId(element_id)));
 }
开发者ID:pix3lot,项目名称:Slackit,代码行数:7,代码来源:TrackChanges.cs

示例11: SheetInfo

        public SheetInfo(Document doc, ViewSheet TempSheet)
        {
            this.ViewPorts = new List<ViewPortInfo>();

            this.sheetId = TempSheet.Id;                     // extract sheet ID
            this.sheet = TempSheet;

            // for each sheet extract each view port
            foreach (ElementId vid in TempSheet.GetAllViewports())
            {
                Viewport vport = (Viewport)doc.GetElement(vid);
                View v = (View)doc.GetElement(vport.ViewId);

                if (v.ViewType == ViewType.AreaPlan || v.ViewType == ViewType.EngineeringPlan || v.ViewType == ViewType.Elevation || v.ViewType == ViewType.FloorPlan || v.ViewType == ViewType.Section || v.ViewType == ViewType.ThreeD)
                {

                    ViewPorts.Add(new ViewPortInfo(v.Id, vport.GetBoxOutline().MinimumPoint, v, vport));
                }
            }
        }
开发者ID:DOCQR,项目名称:revit,代码行数:20,代码来源:SheetInfo.cs

示例12: Execute

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            uiApp = commandData.Application;
            uiDoc = commandData.Application.ActiveUIDocument;
            dbDoc = commandData.Application.ActiveUIDocument.Document;

            //don't run the command if the project isn't workshared
            if (!dbDoc.IsWorkshared)
            {
                TaskDialog.Show("Match Workset", "This project is not workshared");
                return Result.Failed;
            }

            ElementSet selElements = uiDoc.Selection.Elements;
            //don't run the command if nothing is selected
            if (0 == selElements.Size)
            {
                TaskDialog.Show("Match Workset", "No assignable elements selected");
                return Result.Failed;
            }

            Reference target;
            try
            {
                target = uiDoc.Selection.PickObject(ObjectType.Element, new ValidTargetFilter(), "Pick an element on the target workset");
            }
            catch (Autodesk.Revit.Exceptions.OperationCanceledException)
            {
                return Result.Cancelled;
            }

            //retrieve the Workset of the target Reference
            Workset targetWs = dbDoc.GetWorksetTable().GetWorkset( dbDoc.GetElement(target.ElementId).WorksetId );

            using (Transaction t = new Transaction(dbDoc, "Match Workset"))
            {
                t.Start();

                foreach (Element e in selElements)
                {
                    Parameter wsParam = e.get_Parameter(BuiltInParameter.ELEM_PARTITION_PARAM);
                    if (!wsParam.IsReadOnly)
                    {
                        wsParam.Set(targetWs.Id.IntegerValue);
                    }
                }

                t.Commit();
            }

            return Result.Succeeded;
        }
开发者ID:Tessera,项目名称:MatchWorkset,代码行数:52,代码来源:MatchWorksetCommand.cs

示例13: getSelection

        //first exercise put into a user interface
        public static void getSelection(Document doc, UIDocument uidoc)
        {
            ISelectionFilter wallfil = new WallSelectionFilter();

            //gets the object selected Elementid, applies the selection filter and the string mesasge
            ElementId obj = uidoc.Selection.PickObject(ObjectType.Element, wallfil, "Select a Wall please").ElementId;

            //gets the element from the ElementID
            Element e = doc.GetElement(obj);
            //get the family type Elementid
            ElementId idType = e.GetTypeId();
            //Get the Element Type ID
            Element pType = doc.GetElement(idType);

            //gets the instance length of the object
            string s = e.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsValueString();

            //gets the type width of the object
            string t = pType.get_Parameter(BuiltInParameter.WALL_ATTR_WIDTH_PARAM).AsValueString();

            //Shows the values
            TaskDialog.Show("Example", s + " " + t );
        }
开发者ID:Gytaco,项目名称:RevitAPI,代码行数:24,代码来源:examplecommands.cs

示例14: FilterToCategory

        // 2016, jeremy
        /// <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) // 2015, jeremy
        public static ICollection<ElementId> FilterToCategory(
            ICollection<ElementId> set,
            BuiltInCategory filterForCategoryEnum,
            bool includeSymbols,
            Document doc)
        {
            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;

              List<ElementId> filteredSet = new List<ElementId>();

              foreach(ElementId id in set )
              {
            Element elem = doc.GetElement(id);
            if( elem.Category == filterForCategory )
            {
              if( includeSymbols // include it no matter what
            || !(elem is ElementType) )    // include it only if its not a symbol
              {
            filteredSet.Add( id );
              }
            }
              }

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

示例15: Factory

        internal static ViewSchedule Factory(Document document, string familyName, IEnumerable<string> paramNames, string filter)
        {
            var noteblockFamilies = ViewSchedule.GetValidFamiliesForNoteBlock(document);
            var symbolId = (from id in noteblockFamilies
                            let element = document.GetElement(id)
                            where element.Name == familyName
                            select id).FirstOrDefault();
            var noteBlockSchedule = ViewSchedule.CreateNoteBlock(document, symbolId);
            var parameters = GetInstanceParams(document, familyName, paramNames);

            AddFieldsToSchedule(noteBlockSchedule, parameters);
            AddFilterToSchedule(noteBlockSchedule, parameters, filter, "Series");
            AddGroupingToSchedule(noteBlockSchedule, parameters, "Number");
            SetGraphics(noteBlockSchedule);
            noteBlockSchedule.Name = $"Sheet Notes - {filter}";

            return noteBlockSchedule;
        }
开发者ID:dangwalsh,项目名称:Gensler.SheetNoteManager,代码行数:18,代码来源:Schedule.cs


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