本文整理汇总了C#中Dynamo.Nodes.List.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToList方法的具体用法?C# List.ToList怎么用?C# List.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dynamo.Nodes.List
的用法示例。
在下文中一共展示了List.ToList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnumerateAssembliesInBinDirectory
/// <summary>
/// Enumerates all assemblies in the package
/// </summary>
/// <returns>The list of all node library assemblies</returns>
internal IEnumerable<PackageAssembly> EnumerateAssembliesInBinDirectory()
{
var assemblies = new List<PackageAssembly>();
if (!Directory.Exists(BinaryDirectory))
return assemblies;
// Use the pkg header to determine which assemblies to load and prevent multiple enumeration
// In earlier packages, this field could be null, which is correctly handled by IsNodeLibrary
var nodeLibraries = Header.node_libraries;
foreach (var assemFile in (new System.IO.DirectoryInfo(BinaryDirectory)).EnumerateFiles("*.dll"))
{
Assembly assem;
// dll files may be un-managed, skip those
var result = PackageLoader.TryLoadFrom(assemFile.FullName, out assem);
if (result)
{
// IsNodeLibrary may fail, we store the warnings here and then show
IList<ILogMessage> warnings = new List<ILogMessage>();
assemblies.Add(new PackageAssembly()
{
Assembly = assem,
IsNodeLibrary = IsNodeLibrary(nodeLibraries, assem.GetName(), ref warnings)
});
warnings.ToList().ForEach(this.Log);
}
}
foreach (var assem in assemblies)
{
LoadedAssemblies.Add( assem );
}
return assemblies;
}
示例2: TagRenderPackageForPath
/// <summary>
/// Log visualization update timing and geometry data.
/// </summary>
/// <param name="rd">The aggregated render description for the model.</param>
/// <param name="ellapsedTime">The ellapsed time of visualization as a string.</param>
//protected void LogVisualizationUpdateData(RenderDescription rd, string ellapsedTime)
//{
// var renderDict = new Dictionary<string, object>();
// renderDict["points"] = rd.Points.Count;
// renderDict["line_segments"] = rd.Lines.Count / 2;
// renderDict["mesh_facets"] = rd.Meshes.Any()
// ? rd.Meshes.Select(x => x.TriangleIndices.Count / 3).Aggregate((a, b) => a + b)
// : 0;
// renderDict["time"] = ellapsedTime;
// renderDict["manager_type"] = this.GetType().ToString();
// var renderData = JsonConvert.SerializeObject(renderDict);
// InstrumentationLogger.LogInfo("Perf-Latency-RenderGeometryGeneration", renderData);
// //Debug.WriteLine(renderData);
//}
/// <summary>
/// Lookup a node from a location selected on geometry in the scene.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="z"></param>
//public void LookupSelectedElement(double x, double y, double z)
//{
// var id = octree.GetNode(x, y, z);
// if (id == null)
// return;
// var node = _controller.DynamoModel.Nodes.FirstOrDefault(n => n.GUID.ToString() == id.ToString());
// if (node != null && !DynamoSelection.Instance.Selection.Contains(node))
// {
// DynamoSelection.Instance.ClearSelection();
// DynamoSelection.Instance.Selection.Add(node);
// }
//}
/// <summary>
/// Display a label for one or several render packages
/// based on the paths of those render packages.
/// </summary>
/// <param name="path"></param>
public void TagRenderPackageForPath(string path)
{
var packages = new List<RenderPackage>();
foreach (var node in dynSettings.Controller.DynamoModel.Nodes)
{
lock (node.RenderPackagesMutex)
{
packages
.AddRange(node.RenderPackages.Where(x => x.Tag == path || x.Tag.Contains(path + ":"))
.Cast<RenderPackage>());
}
}
if (packages.Any())
{
//clear any labels that might have been drawn on this
//package already and add the one we want
if (_currentTaggedPackages.Any())
{
_currentTaggedPackages.ForEach(x=>x.DisplayLabels = false);
_currentTaggedPackages.Clear();
}
packages.ToList().ForEach(x => x.DisplayLabels = true);
_currentTaggedPackages.AddRange(packages);
var allPackages = new List<RenderPackage>();
foreach (var node in _controller.DynamoModel.Nodes)
{
lock (node.RenderPackagesMutex)
{
allPackages.AddRange(node.RenderPackages.Where(x=>((RenderPackage) x).IsNotEmpty()).Cast<RenderPackage>());
}
}
OnResultsReadyToVisualize(this,
new VisualizationEventArgs(
allPackages, string.Empty));
}
}
示例3: TagRenderPackageForPath
/// <summary>
/// Display a label for one or several render packages
/// based on the paths of those render packages.
/// </summary>
/// <param name="path"></param>
public void TagRenderPackageForPath(string path)
{
CurrentTaskId++;
TaskList.Add(CurrentTaskId);
var packages = new List<RenderPackage>();
//This also isn't thread safe
foreach (var node in dynSettings.Controller.DynamoModel.Nodes)
{
lock (node.RenderPackagesMutex)
{
//Note(Luke): this seems really inefficent, it's doing an O(n) search for a tag
//This is also a target for memory optimisation
packages
.AddRange(node.RenderPackages.Where(x => x.Tag == path || x.Tag.Contains(path + ":"))
.Cast<RenderPackage>());
}
}
if (packages.Any())
{
//clear any labels that might have been drawn on this
//package already and add the one we want
if (currentTaggedPackages.Any())
{
currentTaggedPackages.ForEach(x => x.DisplayLabels = false);
currentTaggedPackages.Clear();
}
packages.ToList().ForEach(x => x.DisplayLabels = true);
currentTaggedPackages.AddRange(packages);
var allPackages = new List<RenderPackage>();
foreach (var node in controller.DynamoModel.Nodes)
{
lock (node.RenderPackagesMutex)
{
allPackages.AddRange(node.RenderPackages.Where(x => ((RenderPackage)x).IsNotEmpty()).Cast<RenderPackage>());
}
}
OnResultsReadyToVisualize(this,
new VisualizationEventArgs(
allPackages, string.Empty, CurrentTaskId));
}
}
示例4: 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.");
//.........这里部分代码省略.........