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


C# Document.GetElement方法代码示例

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


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

示例1: GetChildren

    /// <summary>
    /// Recursively retrieve entire linked document 
    /// hierarchy and return the resulting TreeNode
    /// structure.
    /// </summary>
    void GetChildren( 
      Document mainDoc, 
      ICollection<ElementId> ids, 
      TreeNode parentNode )
    {
      int level = parentNode.Level;

      foreach( ElementId id in ids )
      {
        // Get the child information.

        RevitLinkType type = mainDoc.GetElement( id ) 
          as RevitLinkType;

        string label = LinkLabel( type, level );

        TreeNode subNode = new TreeNode( label );

        Debug.Print( "{0}{1}", Indent( 2 * level ), 
          label );

        parentNode.Nodes.Add( subNode );

        // Go to the next level.

        GetChildren( mainDoc, type.GetChildIds(), 
          subNode );
      }
    }
开发者ID:jeremytammik,项目名称:ListLinkType,代码行数:34,代码来源:Command.cs

示例2: ElementId

		ElementId(string label, Autodesk.Revit.DB.ElementId val, Document doc)
		:   base(label)
		{
		   m_val = val;
         try
         {
            if (val != Autodesk.Revit.DB.ElementId.InvalidElementId)
               m_elem = doc.GetElement(val);	// TBD: strange signature!
         }
         catch (System.Exception)
         {
            m_elem = null;
         }
		}
开发者ID:15921050052,项目名称:RevitLookup,代码行数:14,代码来源:ElementId.cs

示例3: pickView

        //user picks the viewport to move in the sheet
        public static Viewport pickView(Document doc, UIDocument uidoc)
        {
            Viewport viewport = null;
            ElementId id = uidoc.Selection.PickObject(ObjectType.Element, "PICK VIEWPORT").ElementId;
            Element elem = doc.GetElement(id);

            var type = elem.Category.Name;
            //compare the name of the category to the a string Viewports to make sure the user has selected a viewport.
            if (type == "Viewports")
            {
                Viewport vp = elem as Viewport;
                viewport = vp;
                return viewport;
            }
            //if the user has selected a element that isn't a viewport they should get this warning.
            else
            {
                MessageBox.Show("Warning", "Selection is not a viewport or not on a sheet.");
            }
            return viewport;
        }
开发者ID:dannysbentley,项目名称:alignviewtosheetcell,代码行数:22,代码来源:Views.cs

示例4: GetParameters

 List<string> GetParameters( Document doc, Element element )
 {
     List<string> _parameters = new List<string>();
       foreach( Parameter param in element.Parameters )
       {
     if( param == null ) continue;
     string _name = param.Definition.Name;
     switch( param.StorageType )
     {
       case Autodesk.Revit.Parameters.StorageType.Double:
     _parameters.Add( _name + " : " + param.AsDouble().ToString() );
     break;
       case Autodesk.Revit.Parameters.StorageType.Integer:
     if( param.Definition.ParameterType == ParameterType.YesNo )
     {
       if( param.AsInteger() == 0 ) _parameters.Add( _name + " : " + "false" );
       else _parameters.Add( _name + " : " + "true" );
     }
     else
     {
       _parameters.Add( _name + " : " + param.AsInteger().ToString() );
     }
     break;
       case Autodesk.Revit.Parameters.StorageType.String:
     _parameters.Add( _name + " : " + param.AsString() );
     break;
       case Autodesk.Revit.Parameters.StorageType.ElementId:
     ElementId id = param.AsElementId();
     if( id.Value >= 0 ) _parameters.Add( _name + " : " + doc.GetElement( ref id ).Name );
     else _parameters.Add( _name + " : " + id.Value.ToString() );
     break;
       case Autodesk.Revit.Parameters.StorageType.None:
     _parameters.Add( _name + " : " + "none" );
     break;
     }
       }
       return _parameters;
 }
开发者ID:jeremytammik,项目名称:AdnRevitApiLabsXtra,代码行数:38,代码来源:Labs4.cs

示例5: PlaceColumn

    PlaceColumn( Autodesk.Revit.ApplicationServices.Application rvtApp, Document rvtDoc, Autodesk.Revit.DB.XYZ point2, double angle, FamilySymbol columnType, ElementId baseLevelId, ElementId topLevelId )
    {
      Autodesk.Revit.DB.XYZ point = point2;
      // Note: Must use level-hosted NewFamilyInstance!
      Level instLevel = (Level) rvtDoc.GetElement( baseLevelId );
      Autodesk.Revit.DB.FamilyInstance column = rvtDoc.Create.NewFamilyInstance( point, columnType, instLevel, StructuralType.Column );

      if( column == null )
      {
        MessageBox.Show( "failed to create an instance of a column." );
        return;
      }

      Autodesk.Revit.DB.XYZ zVec = new Autodesk.Revit.DB.XYZ( 0, 0, 1 );


      Autodesk.Revit.DB.Line axis = Line.CreateUnbound( 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:15921050052,项目名称:RevitLookup,代码行数:27,代码来源:StructSample.cs

示例6: GetParameterValue2

        /// <summary>
        /// Helper to return parameter value as string, with additional
        /// support for element id to display the element type referred to.
        /// </summary>
        public static string GetParameterValue2( Parameter param, Document doc )
        {
            string s;
              if( StorageType.ElementId == param.StorageType
            && null != doc )
              {
            ElementId id = param.AsElementId();

            int i = id.IntegerValue;

            if( 0 > i )
            {
              s = i.ToString()
            + BuiltInCategoryString( i );
            }
            else
            {
              Element e = doc.GetElement( id );
              s = ElementDescription( e, true );
            }
              }
              else
              {
            s = GetParameterValue( param );
              }
              return s;
        }
开发者ID:jeremytammik,项目名称:AdnRevitApiLabsXtra,代码行数:31,代码来源:LabUtils.cs

示例7: ChangeDiffuserSize

        bool ChangeDiffuserSize( Document doc )
        {
            //
              // iterate over all air terminal families and determine
              // the min and max flow assigned to each type.
              //
              // for each family, create a list of all its symbols
              // with their respective min and max flows. collect
              // these lists in a map keyed by family name:
              //
              Dictionary<string, List<SymbMinMax>> dictFamilyToSymbols = new Dictionary<string, List<SymbMinMax>>();
              {
            WaitCursor waitCursor = new WaitCursor();
            //Category categoryAirTerminal = doc.Settings.Categories.get_Item( BuiltInCategory.OST_DuctTerminal );
            //ElementId categoryId = categoryAirTerminal.Id;
            //ElementIterator it = doc.get_Elements( typeof( Family ) );

            FilteredElementCollector collector
              = new FilteredElementCollector( doc )
            .OfClass( typeof( Family ) );

            foreach( Family family in collector )
            {
              ISet<ElementId> symbolIds
            = family.GetFamilySymbolIds();

              // Family category is not implemented,
              // so check the symbols instead:

              bool categoryMatches = false;

              foreach( ElementId id in symbolIds )
              {
            Element symbol = doc.GetElement( id );

            // in 2008 and even 2009 beta 1,
            // you could compare categories directly:
            //categoryMatches = ( null != symbol.Category
            //  && symbol.Category.Equals( categoryAirTerminal ) );

            // in 2009, check the category id instead:

            categoryMatches = ( null != symbol.Category
              && symbol.Category.Id.IntegerValue.Equals(
                (int) BuiltInCategory.OST_DuctTerminal ) );

            break; // we only need to check the first one
              }
              if( categoryMatches )
              {
            List<SymbMinMax> familySymbols
              = new List<SymbMinMax>();

            foreach( ElementId id in symbolIds )
            {
              FamilySymbol symbol = doc.GetElement( id )
                as FamilySymbol;

              SymbMinMax a = new SymbMinMax();
              a.Symbol = symbol;

              a.Min = Util.GetParameterValueFromName(
                symbol, ParameterName.MinFlow );

              a.Max = Util.GetParameterValueFromName(
                symbol, ParameterName.MaxFlow );

              familySymbols.Add( a );
            }
            dictFamilyToSymbols.Add(
              family.Name, familySymbols );
              }
            }
              }
              //
              // prompt user to select which families to process:
              //
              //List<string> familyNames = new List<string>( dictFamilyToSymbols.Count );
              //foreach( string s in dictFamilyToSymbols.Keys )
              //{
              //  familyNames.Add( string.Format( "{0}({1})", s, dictFamilyToSymbols[s].Count ) );
              //}
              List<string> familyNames = new List<string>( dictFamilyToSymbols.Keys );
              familyNames.Sort();
              FamilySelector fs = new FamilySelector( familyNames );
              if( W.DialogResult.OK == fs.ShowDialog() )
              {
            WaitCursor waitCursor = new WaitCursor();
            FilteredElementCollector collector = Util.GetSupplyAirTerminals( doc );
            IList<Element> terminals = collector.ToElements();
            int n = terminals.Count;
            string s = "{0} of " + n.ToString() + " terminals processed...";
            string caption = "Change Diffuser Size";
            using( ProgressForm pf = new ProgressForm( caption, s, n ) )
            {
              foreach( FamilyInstance terminal in terminals )
              {
            string familyName = terminal.Symbol.Family.Name;
            if( fs.IsChecked( familyName ) )
            {
//.........这里部分代码省略.........
开发者ID:jeremytammik,项目名称:AdnRme,代码行数:101,代码来源:CmdChangeSize.cs

示例8: 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

示例9: GetParameterInformation

        /// <summary>
        /// Extract the parameter information.
        /// By Dan Tartaglia.
        /// </summary>
        public string GetParameterInformation(
            Parameter para,
            Document doc)
        {
            string defName = "";

              // Use different method to get parameter
              // data according to the storage type

              switch( para.StorageType )
              {
            // Determine the parameter type

            case StorageType.Double:

              // Convert the number into Metric

              defName = para.AsValueString();
              break;

            case StorageType.ElementId:

              // Find out the name of the element

              Autodesk.Revit.DB.ElementId id
            = para.AsElementId();

              defName = ( id.IntegerValue >= 0 )
            ? doc.GetElement( id ).Name
            : id.IntegerValue.ToString();

              break;

            case StorageType.Integer:
              if( ParameterType.YesNo
            == para.Definition.ParameterType )
              {
            if( para.AsInteger() == 0 )
            {
              defName = "False";
            }
            else
            {
              defName = "True";
            }
              }
              else
              {
            defName = para.AsInteger().ToString();
              }
              break;

            case StorageType.String:
              defName = para.AsString();
              break;

            default:
              defName = "Unexposed parameter";
              break;
              }
              return defName;
        }
开发者ID:jeremytammik,项目名称:GetRevisionData,代码行数:66,代码来源:Command.cs

示例10: isCalculationOn

        private bool isCalculationOn(Document doc, Autodesk.Revit.DB.MEPSystem mepSys)
        {
            if (mepSys == null)
            return false;
             MEPSystemType sysType = doc.GetElement(mepSys.GetTypeId()) as MEPSystemType;
             if (sysType == null)
            return false;

             return sysType.CalculationLevel == Autodesk.Revit.DB.Mechanical.SystemCalculationLevel.All;
        }
开发者ID:jeremytammik,项目名称:UserMepCalculation,代码行数:10,代码来源:ReportSystemSelectorDlg.cs

示例11: Objects

        public Objects( Document doc, ICollection<ElementId> ids )
        {
            InitializeComponent();

              ICollection<Element> elemSet
            = new List<Element>( ids.Select<ElementId, Element>(
              id => doc.GetElement( id ) ) );

              CommonInit( elemSet );
        }
开发者ID:jeremytammik,项目名称:RevitLookup,代码行数:10,代码来源:Objects.cs

示例12: GetTriangular

        /// <summary>
        /// Get triangles in a solid with transform.
        /// </summary>
        /// <param name="solid">The solid contains triangulars</param>
        /// <param name="transform">The transformation.</param>
        private void GetTriangular(Document document, Solid solid, Transform transform)
        {
            // a solid has many faces
            FaceArray faces = solid.Faces;
            bool hasTransform = (null != transform);
            if (0 == faces.Size)
            {
                return;
            }

            foreach (Face face in faces)
            {
                if (face.Visibility != Visibility.Visible)
                {
                    continue;
                }
                Mesh mesh = face.Triangulate();
                if (null == mesh)
                {
                    continue;
                }

                m_TriangularNumber += mesh.NumTriangles;

                PlanarFace planarFace = face as PlanarFace;

                // write face to stl file
                // a face has a mesh, all meshes are made of triangles
                for (int ii = 0; ii < mesh.NumTriangles; ii++)
                {
                    MeshTriangle triangular = mesh.get_Triangle(ii);
                    double[] xyz = new double[9];
                    Autodesk.Revit.DB.XYZ normal = new Autodesk.Revit.DB.XYZ();
                    try
                    {
                        Autodesk.Revit.DB.XYZ[] triPnts = new Autodesk.Revit.DB.XYZ[3];
                        for (int n = 0; n < 3; ++n)
                        {
                            double x, y, z;
                            Autodesk.Revit.DB.XYZ point = triangular.get_Vertex(n);
                            if (hasTransform)
                            {
                                point = transform.OfPoint(point);
                            }
                            if (m_Settings.ExportSharedCoordinates)
                            {
                                ProjectPosition ps = document.ActiveProjectLocation.get_ProjectPosition(point);
                                x = ps.EastWest;
                                y = ps.NorthSouth;
                                z = ps.Elevation;
                            }
                            else
                            {
                                x = point.X;
                                y = point.Y;
                                z = point.Z;
                            }
                            if (m_Settings.Units != DisplayUnitType.DUT_UNDEFINED)
                            {
                                xyz[3 * n] = UnitUtils.ConvertFromInternalUnits(x, m_Settings.Units);
                                xyz[3 * n + 1] = UnitUtils.ConvertFromInternalUnits(y, m_Settings.Units);
                                xyz[3 * n + 2] = UnitUtils.ConvertFromInternalUnits(z, m_Settings.Units);
                            }
                            else
                            {
                                xyz[3 * n] = x;
                                xyz[3 * n + 1] = y;
                                xyz[3 * n + 2] = z;
                            }

                            triPnts[n] = point;
                        }

                        Autodesk.Revit.DB.XYZ pnt1 = triPnts[1] - triPnts[0];
                        normal = pnt1.CrossProduct(triPnts[2] - triPnts[1]);
                    }
                    catch (Exception ex)
                    {
                        m_TriangularNumber--;
                        STLDialogManager.ShowDebug(ex.Message);
                        continue;
                    }

                    if (m_Writer is SaveDataAsBinary && m_Settings.ExportColor)
                    {
                        Material material = document.GetElement(face.MaterialElementId) as Material;
                        if(material!=null)
                            ((SaveDataAsBinary)m_Writer).Color = material.Color;
                    }

                    m_Writer.WriteSection(normal, xyz);
                }
            }
        }
开发者ID:redscorpion201,项目名称:STLExporterForRevit,代码行数:99,代码来源:DataGenerator.cs

示例13: ExportSolid

        /// <summary>
        /// Export a non-empty solid.
        /// </summary>
        bool ExportSolid( 
      IJtFaceEmitter emitter,
      Document doc,
      Solid solid,
      Color color,
      int transparency )
        {
            Material m;
              Color c;
              int t;

              foreach( Face face in solid.Faces )
              {
            m = doc.GetElement(
              face.MaterialElementId ) as Material;

            c = ( null == m ) ? color : m.Color;

            t = ( null == m )
              ? transparency
              : m.Transparency;

            emitter.EmitFace( face,
              (null == c) ? DefaultColor : c,
              t );
              }
              return true;
        }
开发者ID:dangwalsh,项目名称:OBJExport,代码行数:31,代码来源:Command.cs

示例14: removeOpenings

        /// <summary>
        /// Remove Openings from wall baseline
        /// </summary>
        /// <param name="breaks">List of Interruptions</param>
        /// <param name="wall">Wall</param>
        /// <param name="doc">Document</param>
        public void removeOpenings(ref List<Interruption> breaks, Wall wall, Document doc)
        {
            LocationCurve c = (LocationCurve)wall.Location;
            foreach (ElementId elemId in wall.FindInserts(true, false, false, false))
            {
                Element insertedElement = doc.GetElement(elemId);
                if (insertedElement.GetType() == typeof(FamilyInstance))
                {
                    FamilyInstance o = (FamilyInstance)insertedElement;
                    if (o.Location.GetType() == typeof(LocationPoint))
                    {
                        LocationPoint lp = (LocationPoint)o.Location;
                        c.Curve.GetEndPoint(0).DistanceTo(lp.Point);
                        double width = o.Symbol.LookupParameter("Width").AsDouble();
                        breaks.Add(new Interruption(c.Curve, lp.Point, width));
                    }

                }
            }
        }
开发者ID:moethu,项目名称:Insulator,代码行数:26,代码来源:Insulator.cs

示例15: getInsulationLayer

        /// <summary>
        /// Get the Insulation Layer from a wall
        /// </summary>
        public Tuple<Curve, Curve> getInsulationLayer(Document doc, Wall wall)
        {
            double offset = 0;
            LocationCurve c = (LocationCurve)wall.Location;

            CompoundStructure cs = wall.WallType.GetCompoundStructure();
            foreach (CompoundStructureLayer layer in cs.GetLayers())
            {
                if (layer.MaterialId != null && layer.MaterialId != ElementId.InvalidElementId)
                {
                    Material mat = doc.GetElement(layer.MaterialId) as Material;
                    if (mat.Name.ToLower().Contains("soft insulation"))
                    {

                        double ypos = (wall.Width / 2) - offset;

                        double rotationangle = -1.57079633;
                        double layeroffset = ypos - layer.Width;
                        if (ypos - layer.Width < 0) { rotationangle *= -1; ypos = (wall.Width / 2) * -1 + offset; layeroffset = ypos + layer.Width; }

                        if (wall.Flipped) rotationangle *= -1;

                        Transform tra = Transform.CreateRotationAtPoint(XYZ.BasisZ, rotationangle, c.Curve.GetEndPoint(0));
                        Curve rotated = c.Curve.CreateTransformed(tra);

                        XYZ LowerStartPoint = rotated.Evaluate(((layeroffset) / rotated.Length), true);
                        XYZ UpperStartPoint = null;

                        if (ypos < 0)
                        {
                            Curve rotatedHelper = c.Curve.CreateTransformed(Transform.CreateRotationAtPoint(XYZ.BasisZ, rotationangle * -1, c.Curve.GetEndPoint(0)));
                            UpperStartPoint = rotatedHelper.Evaluate((ypos * -1 / rotatedHelper.Length), true);
                        }
                        else
                            UpperStartPoint = rotated.Evaluate((ypos / rotated.Length), true);

                        XYZ v = c.Curve.GetEndPoint(0) - LowerStartPoint;
                        XYZ u = c.Curve.GetEndPoint(0) - UpperStartPoint;

                        Curve locationCurvelower = c.Curve.CreateTransformed(Transform.CreateTranslation(v));
                        Curve locationCurveupper = c.Curve.CreateTransformed(Transform.CreateTranslation(u));

                        return new Tuple<Curve, Curve>(locationCurveupper, locationCurvelower);
                    }
                }
                offset += layer.Width;
            }

            return null;
        }
开发者ID:moethu,项目名称:Insulator,代码行数:53,代码来源:Insulator.cs


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