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


C# List.ElementAt方法代码示例

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


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

示例1: Evaluate

        public override Value Evaluate(FSharpList<Value> args)
        {
            var xyzs = ((Value.List)args[0]).Item;
            var symbol = (FamilySymbol) ((Value.Container) args[1]).Item;

            var instData = new List<FamilyInstanceCreationData>();
            var updated = new HashSet<ElementId>();

            int count = 0;

            #region batch creation data

            var sw = new Stopwatch();
            sw.Start();
            foreach (var pts in xyzs)
            {
                FamilyInstance instance = null;
                if (Elements.Count > count)
                {
                    if (dynUtils.TryGetElement(this.Elements[count], out instance))
                    {
                        //if we've found an instance, change its symbol if it needs
                        //changing
                        if (instance.Symbol.Id != symbol.Id)
                            instance.Symbol = symbol;

                        //update the placement points and add the
                        //id to the list of updated acs
                        UpdatePlacementPoints(instance, xyzs, count);
                        updated.Add(Elements[count]);
                    }
                    else
                    {
                        var instanceData = new FamilyInstanceCreationData(XYZ.Zero, symbol, StructuralType.NonStructural);
                        instData.Add(instanceData);
                    }
                }
                else
                {
                    var instanceData = new FamilyInstanceCreationData(XYZ.Zero, symbol, StructuralType.NonStructural);
                    instData.Add(instanceData);
                }

                count++;
            }
            sw.Stop();
            Debug.WriteLine(string.Format("{0} elapsed for updating existing or generating family creation data.", sw.Elapsed));
            sw.Reset();

            #endregion

            //trim the elements collection
            foreach (var e in this.Elements.Skip(count))
            {
                DeleteElement(e);
            }

            FSharpList<Value> results = FSharpList<Value>.Empty;

            sw.Start();

            ICollection<ElementId> ids = new List<ElementId>();

            if (instData.Any())
            {
                if (dynRevitSettings.Doc.Document.IsFamilyDocument)
                {
                    ids = dynRevitSettings.Doc.Document.FamilyCreate.NewFamilyInstances2(instData);
                }
                else
                {
                    ids = dynRevitSettings.Doc.Document.Create.NewFamilyInstances2(instData);
                }
                if (ids.Count > 0)
                {
                    //hack to force regeneration. There should be a better way!!
                    XYZ moveVec = new XYZ(0.0, 0.0, 0.0);
                    ElementTransformUtils.MoveElement(this.UIDocument.Document, ids.ElementAt(0), moveVec);

                }

                //add our batch-created instances ids'
                //to the elements collection
                ids.ToList().ForEach(x => Elements.Add(x));
            }
            sw.Stop();
            Debug.WriteLine(string.Format("{0} elapsed for creating instances from creation data.", sw.Elapsed));
            sw.Reset();

            sw.Start();

            //make sure the ids list and the XYZ sets list
            //have the same length
            if (count != xyzs.Count())
            {
                foreach (var eId in ids)
                {
                    DeleteElement(eId);
                }
                throw new Exception("There are more adaptive component instances than there are points to adjust.");
//.........这里部分代码省略.........
开发者ID:parchjs,项目名称:Dynamo,代码行数:101,代码来源:AdaptiveComponents.cs


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