本文整理汇总了C#中Dynamo.Nodes.List.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# List.Clear方法的具体用法?C# List.Clear怎么用?C# List.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dynamo.Nodes.List
的用法示例。
在下文中一共展示了List.Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Evaluate
public override Value Evaluate(FSharpList<Value> args)
{
var input = args[0];
var xi = ((Value.Number)args[1]).Item;// Number
var x0 = ((Value.Number)args[2]).Item;// Starting Coord
var xs = (SpacingRuleLayout)((Value.Container)args[3]).Item; // Spacing
Autodesk.Revit.DB.DividedPath divPath;
var refList = new List<Reference>();
refList.Clear();
var c = (CurveElement)((Value.Container)input).Item;
FSharpList<Value> result = FSharpList<Value>.Empty;
Curve crvRef = c.GeometryCurve;
refList.Add(crvRef.Reference);
if (this.Elements.Any())
{
if (dynUtils.TryGetElement(this.Elements[0], out divPath))
{
SetSpacing(divPath, xi, xs);
}
else
{
divPath = Autodesk.Revit.DB.DividedPath.Create(this.UIDocument.Document, refList);
SetSpacing(divPath, xi, xs);
this.Elements[0] = divPath.Id;
}
}
else
{
divPath = Autodesk.Revit.DB.DividedPath.Create(this.UIDocument.Document, refList);
SetSpacing(divPath, xi, xs);
this.Elements.Add(divPath.Id);
}
refList.Clear();
return Value.NewContainer(divPath);
}
示例2: RegisterDeleteHook
internal void RegisterDeleteHook(Autodesk.Revit.DB.ElementId id, DynElementUpdateDelegate d)
{
DynElementUpdateDelegate del = delegate(List<Autodesk.Revit.DB.ElementId> deleted)
{
var valid = new List<Autodesk.Revit.DB.ElementId>();
var invalid = new List<Autodesk.Revit.DB.ElementId>();
foreach (var delId in deleted)
{
try
{
Autodesk.Revit.DB.Element e = dynRevitSettings.Doc.Document.GetElement(delId);
if (e != null)
{
valid.Add(e.Id);
}
else
invalid.Add(delId);
}
catch
{
invalid.Add(delId);
}
}
valid.Clear();
d(invalid);
foreach (var invId in invalid)
{
this.Updater.UnRegisterChangeHook(invId, ChangeTypeEnum.Modify);
this.Updater.UnRegisterChangeHook(invId, ChangeTypeEnum.Add);
this.Updater.UnRegisterChangeHook(invId, ChangeTypeEnum.Delete);
}
};
DynElementUpdateDelegate mod = delegate(List<Autodesk.Revit.DB.ElementId> modded)
{
_transElements.RemoveAll(modded.Contains);
foreach (var mid in modded)
{
this.Updater.UnRegisterChangeHook(mid, ChangeTypeEnum.Modify);
this.Updater.UnRegisterChangeHook(mid, ChangeTypeEnum.Add);
}
};
this.Updater.RegisterChangeHook(
id, ChangeTypeEnum.Delete, del
);
this.Updater.RegisterChangeHook(
id, ChangeTypeEnum.Modify, mod
);
this.Updater.RegisterChangeHook(
id, ChangeTypeEnum.Add, mod
);
this._transElements.Add(id);
}
示例3: Evaluate
//.........这里部分代码省略.........
// else
// {
// //...otherwise, we can make a new divided path and replace it in the list of
// //previously created divided paths.
// //...we extract a curve element from the container.
// c = (CurveElement)((Value.Container)x).Item;
// //...we create a new curve ref
// Curve crvRef = c.GeometryCurve;
// refList.Add(crvRef.Reference);
// divPath = Autodesk.Revit.DB.DividedPath.Create(this.UIDocument.Document, refList);
// divPath.FixedNumberOfPoints = (int)xi;
// this.Elements[count] = divPath.Id;
// refList.Clear();
// }
// }
// //...otherwise...
// else
// {
// //...we extract a curve element from the container.
// c = (CurveElement)((Value.Container)x).Item;
// //...we create a new curve ref
// Curve crvRef = c.GeometryCurve;
// refList.Add(crvRef.Reference);
// divPath = Autodesk.Revit.DB.DividedPath.Create(this.UIDocument.Document, refList);
// divPath.FixedNumberOfPoints = (int)xi;
// //...and store the element in the element list for future runs.
// this.Elements.Add(divPath.Id);
// refList.Clear();
// }
// //Finally, we update the counter, and return a new Value containing the reference list.
// count++;
// return Value.NewContainer(divPath);
// }
// )
// );
// //Now that we've added all the divided paths from this run, we delete all of the
// //extra ones from the previous run.
// foreach (var eid in this.Elements.Skip(count))
// {
// this.DeleteElement(eid); // remove unused divided paths
// }
// return Value.NewList(result);
//}
////If we're not receiving a list, we will just assume we received one curve.
//else
//{
refList.Clear();
Reference r = (Reference)((Value.Container)input).Item;
FSharpList<Value> result = FSharpList<Value>.Empty;
refList.Add(r);
//If we've made any elements previously...
if (this.Elements.Any())
{
Element e;
//...try to get the first one...
if (dynUtils.TryGetElement(this.Elements[0], out e))
{
//..and if we do, update it's data.
divSurf = e as DividedSurface;
//divSurf. = (int)xi;
}
else
{
//...otherwise, just make a new one and replace it in the list.
divSurf = this.UIDocument.Document.FamilyCreate.NewDividedSurface(r);
//divSurf.FixedNumberOfPoints = (int)xi;
this.Elements[0] = divSurf.Id;
}
//We still delete all extra elements, since in the previous run we might have received a list.
foreach (var el in this.Elements.Skip(1))
{
this.DeleteElement(el);
}
}
//...otherwise...
else
{
//...just make a divided curve and store it.
divSurf = this.UIDocument.Document.FamilyCreate.NewDividedSurface(r);
//divSurf.FixedNumberOfPoints = (int)xi;
this.Elements.Add(divSurf.Id);
}
refList.Clear();
//Fin
return Value.NewContainer(divSurf);
}
示例4: Evaluate
public override Value Evaluate(FSharpList<Value> args)
{
SpatialFieldManager sfm = ((Value.Container)args[2]).Item as SpatialFieldManager;
// Place analysis results in the form of vectors at each of a beam or column's analytical model curve
Curve curve = ((Value.Container)args[3]).Item as Curve;
int index = sfm.AddSpatialFieldPrimitive(curve, Transform.Identity);
IList<double> doubleList = new List<double>();
doubleList.Add(curve.get_EndParameter(0)); // vectors will be at each end of the analytical model curve
doubleList.Add(curve.get_EndParameter(1));
FieldDomainPointsByParameter pointsByParameter = new FieldDomainPointsByParameter(doubleList);
List<XYZ> xyzList = new List<XYZ>();
xyzList.Add(curve.ComputeDerivatives(0, true).BasisX.Normalize()); // vectors will be tangent to the curve at its ends
IList<VectorAtPoint> vectorList = new List<VectorAtPoint>();
vectorList.Add(new VectorAtPoint(xyzList));
xyzList.Clear();
xyzList.Add(curve.ComputeDerivatives(1, true).BasisX.Normalize().Negate());
vectorList.Add(new VectorAtPoint(xyzList));
FieldDomainPointsByXYZ feildPoints = new FieldDomainPointsByXYZ(xyzList);
FieldValues fieldValues = new FieldValues(vectorList);
int n = 0;
sfm.UpdateSpatialFieldPrimitive(index, feildPoints, fieldValues, n);
/*
//first, cleanup the old one
if (idx != -1)
{
sfm.RemoveSpatialFieldPrimitive(idx);
}
Reference reference = ((Value.Container)args[3]).Item as Reference;
idx = sfm.AddSpatialFieldPrimitive(reference);
Face face = dynRevitSettings.Doc.Document.GetElement(reference).GetGeometryObjectFromReference(reference) as Face;
//unwrap the sample locations
IEnumerable<UV> pts = ((Value.List)args[1]).Item.Select(
x => (UV)((Value.Container)x).Item
);
FieldDomainPointsByUV sample_pts = new FieldDomainPointsByUV(pts.ToList<UV>());
//unwrap the values
IEnumerable<double> nvals = ((Value.List)args[0]).Item.Select(
x => (double)((Value.Number)x).Item
);
//for every sample location add a list
//of valueatpoint objets. for now, we only
//support one value per point
IList<ValueAtPoint> valList = new List<ValueAtPoint>();
foreach (var n in nvals)
{
valList.Add(new ValueAtPoint(new List<double> { n }));
}
FieldValues sample_values = new FieldValues(valList);
int schemaIndex = 0;
if (!sfm.IsResultSchemaNameUnique(DYNAMO_ANALYSIS_RESULTS_NAME, -1))
{
IList<int> arses = sfm.GetRegisteredResults();
foreach (int i in arses)
{
AnalysisResultSchema arsTest = sfm.GetResultSchema(i);
if (arsTest.Name == DYNAMO_ANALYSIS_RESULTS_NAME)
{
schemaIndex = i;
break;
}
}
}
else
{
AnalysisResultSchema ars = new AnalysisResultSchema(DYNAMO_ANALYSIS_RESULTS_NAME, "Resulting analyses from Dynamo.");
schemaIndex = sfm.RegisterResult(ars);
}
sfm.UpdateSpatialFieldPrimitive(idx, sample_pts, sample_values, schemaIndex);
*/
return Value.NewContainer(idx);
}