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


C# Document.get_Element方法代码示例

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


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

示例1: GetAllViews

 /// <summary>
 /// Finds all the views in the active document.
 /// </summary>
 /// <param name="doc">the active document</param>
 private void GetAllViews(Document doc)
 {
     FilteredElementCollector collector = new FilteredElementCollector(doc);
     FilteredElementIterator itor = collector.OfClass(typeof(Autodesk.Revit.DB.View)).GetElementIterator();
     itor.Reset();
     while (itor.MoveNext())
     {
         Autodesk.Revit.DB.View view = itor.Current as Autodesk.Revit.DB.View;
         // skip view templates because they're invisible in project browser
         if (null == view || view.IsTemplate)
         {
             continue;
         }
         else
         {
             ElementType objType = doc.get_Element(view.GetTypeId()) as ElementType;
             if (null == objType || objType.Name.Equals("Schedule")
                 || objType.Name.Equals("Drawing Sheet"))
             {
                 continue;
             }
             else
             {
                 m_allViews.Insert(view);
                 AssortViews(view.Name, objType.Name);
             }
         }
     }
 }
开发者ID:AMEE,项目名称:revit,代码行数:33,代码来源:AllViews.cs

示例2: GetProperty

        /// <summary>
        /// Get the room property value according the parameter name
        /// </summary>
        /// <param name="activeDoc">Current active document.</param>
        /// <param name="room">an instance of room class</param>
        /// <param name="paraEnum">the parameter used to get parameter value</param>
        /// <param name="useValue">convert parameter to value type or not.
        /// if true, the value of parameter will be with unit.
        /// if false, the value of parameter will be without unit.</param>
        /// <returns>the string value of property specified by shared parameter</returns>
        public static String GetProperty(Document activeDoc, Room room, BuiltInParameter paraEnum, bool useValue)
        {
            String propertyValue = null;  //the value of parameter

            // Assuming the build in parameter is legal for room.
            // if the room is not placed, some properties are not available, i.g. Level name, Area ...
            // trying to retrieve them will throw exception;
            // however some parameters are available, e.g.: name, number
            Parameter param;
            try
            {
                param = room.get_Parameter(paraEnum);
            }
            catch (Exception)
            {
                // throwing exception for this parameter is acceptable if it's a unplaced room
                if (null == room.Location)
                {
                    propertyValue = "Not Placed";
                    return propertyValue;
                }
                else
                {
                    throw new Exception("Illegal built in parameter.");
                }
            }

            // get the parameter via the built in parameter
            if (null == param)
            {
                return "";
            }

            // get the parameter's storage type and convert parameter to string
            StorageType storageType = param.StorageType;
            switch (storageType)
            {
                case StorageType.Integer:
                    int iVal = param.AsInteger();
                    propertyValue = iVal.ToString();
                    break;
                case StorageType.String:
                    propertyValue = param.AsString();
                    break;
                case StorageType.Double:
                    // AsValueString will make the return string with unit, it's appreciated.
                    if (useValue)
                    {
                        propertyValue = param.AsValueString();
                    }
                    else
                    {
                        propertyValue = param.AsDouble().ToString();
                    }
                    break;
                case StorageType.ElementId:
                    Autodesk.Revit.DB.ElementId elemId = param.AsElementId();
                    Element elem = activeDoc.get_Element(elemId);
                    propertyValue = elem.Name;
                    break;
                default:
                    propertyValue = param.AsString();
                    break;
            }

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

示例3: PlaceColumn

        /// <summary>
        /// create a column instance and place it on the wall line.
        /// </summary>
        /// <param name="rvtApp">revit application</param>
        /// <param name="rvtDoc">revit document</param>
        /// <param name="point2">location for placing column</param>
        /// <param name="angle">column angle</param>
        /// <param name="columnType">column type placed in Wall</param>
        /// <param name="baseLevelId">level id for base level where column is placed</param>
        /// <param name="topLevelId">level id for top level where column is placed</param>
        private void PlaceColumn(Autodesk.Revit.ApplicationServices.Application rvtApp, Document rvtDoc, Autodesk.Revit.DB.XYZ point2,
            double angle, FamilySymbol columnType, Autodesk.Revit.DB.ElementId baseLevelId, Autodesk.Revit.DB.ElementId topLevelId)
        {
            Autodesk.Revit.DB.XYZ point = point2;

            // Note: Must use level-hosted NewFamilyInstance!
            Level instLevel = (Level)rvtDoc.get_Element(baseLevelId);
            Autodesk.Revit.DB.FamilyInstance column = rvtDoc.Create.NewFamilyInstance(point, columnType,
                instLevel, Autodesk.Revit.DB.Structure.StructuralType.Column);
            if (column == null)
            {
                MessageBox.Show("failed to create an instance of a column.");
                return;
            }

            // rotate column to place it to right location
            Autodesk.Revit.DB.XYZ zVec = new Autodesk.Revit.DB.XYZ (0, 0, 1);
            Autodesk.Revit.DB.Line axis = rvtApp.Create.NewLineUnbound(point, zVec);
            column.Location.Rotate(axis, angle);

            // Set the level Ids
            Parameter baseLevelParameter = column.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.FAMILY_BASE_LEVEL_PARAM);
            Parameter topLevelParameter = column.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.FAMILY_TOP_LEVEL_PARAM); ;
            baseLevelParameter.Set(baseLevelId);
            topLevelParameter.Set(topLevelId);
        }
开发者ID:AMEE,项目名称:revit,代码行数:36,代码来源:Command.cs


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