InternalSetSpatialFieldValues(int primitiveId, ISurfaceAnalysisData <Autodesk.DesignScript.Geometry.UV, double> data, string schemaName, string description, Type unitType) { // Get the surface reference var reference = data.Surface.Tags.LookupTag(DefaultTag) as Reference; var el = DocumentManager.Instance.CurrentDBDocument.GetElement(reference.ElementId); var pointLocations = new List <UV>(); if (el != null) { var face = el.GetGeometryObjectFromReference(reference) as Autodesk.Revit.DB.Face; if (face != null) { foreach (var loc in data.CalculationLocations) { var pt = data.Surface.PointAtParameter(loc.U, loc.V); var faceLoc = face.Project(pt.ToXyz()).UVPoint; pointLocations.Add(faceLoc); } } } var values = data.Results.Values.ToList(); // Data will come in as: // A B C D // E F G H // I J K L // We need it in the form: // A E I // B F J // C G K // D H L var height = values.First().Count(); var width = values.Count(); var valList = new List <ValueAtPoint>(); for (int i = 0; i < height; i++) { var lst = new List <double>() { }; for (int j = 0; j < width; j++) { lst.Add(values.ElementAt(j).ElementAt(i)); } valList.Add(new ValueAtPoint(lst)); } TransactionManager.Instance.EnsureInTransaction(Document); // Convert the analysis values to a special Revit type //var valList = enumerable.Select(n => new ValueAtPoint(n.ToList())).ToList(); var sampleValues = new FieldValues(valList); // Convert the sample points to a special Revit Type var samplePts = new FieldDomainPointsByUV(pointLocations.ToList()); // Get the analysis results schema var schemaIndex = GetAnalysisResultSchemaIndex(schemaName, description, unitType); // Update the values SpatialFieldManager.UpdateSpatialFieldPrimitive(primitiveId, samplePts, sampleValues, schemaIndex); TransactionManager.Instance.TransactionTaskDone(); }
InternalSetSpatialFieldValues(int primitiveId, ISurfaceAnalysisData<Autodesk.DesignScript.Geometry.UV, double> data, string schemaName, string description, Type unitType) { // Get the surface reference var reference = data.Surface.Tags.LookupTag(DefaultTag) as Reference; var el = DocumentManager.Instance.CurrentDBDocument.GetElement(reference.ElementId); var pointLocations = new List<UV>(); if (el != null) { var face = el.GetGeometryObjectFromReference(reference) as Autodesk.Revit.DB.Face; if (face != null) { foreach (var loc in data.CalculationLocations) { var pt = data.Surface.PointAtParameter(loc.U, loc.V); var faceLoc = face.Project(pt.ToXyz()).UVPoint; pointLocations.Add(faceLoc); } } } var values = data.Results.Values.ToList(); // Data will come in as: // A B C D // E F G H // I J K L // We need it in the form: // A E I // B F J // C G K // D H L var height = values.First().Count(); var width = values.Count(); var valList = new List<ValueAtPoint>(); for (int i = 0; i < height; i++) { var lst = new List<double>() { }; for (int j = 0; j < width; j++) { lst.Add(values.ElementAt(j).ElementAt(i)); } valList.Add(new ValueAtPoint(lst)); } TransactionManager.Instance.EnsureInTransaction(Document); // Convert the analysis values to a special Revit type //var valList = enumerable.Select(n => new ValueAtPoint(n.ToList())).ToList(); var sampleValues = new FieldValues(valList); // Convert the sample points to a special Revit Type var samplePts = new FieldDomainPointsByUV(pointLocations.ToList()); // Get the analysis results schema var schemaIndex = GetAnalysisResultSchemaIndex(schemaName, description, unitType); // Update the values SpatialFieldManager.UpdateSpatialFieldPrimitive(primitiveId, samplePts, sampleValues, schemaIndex); TransactionManager.Instance.TransactionTaskDone(); }