public IEnumerable <DBText> CreateVolumeLabels(Rectangle3d rectg, Autodesk.Civil.DatabaseServices.TinVolumeSurface surface) { List <DBText> res = new List <DBText>(); Point3d topPosition = Point3d.Origin; Vector3d centralVector = rectg.UpperRight - rectg.LowerLeft; topPosition = rectg.LowerLeft.Add(centralVector.MultiplyBy(0.5d)); Point3d bottomPosition = topPosition; Autodesk.Civil.DatabaseServices.SurfaceVolumeInfo volumeInfo = new civil.DatabaseServices.SurfaceVolumeInfo(); try { volumeInfo = surface.GetBoundedVolumes(rectg.GetPoints(true)); } catch (ArgumentException) { return(null); } if (Math.Round(volumeInfo.Fill, 1) > 0d && Math.Round(volumeInfo.Cut, 1) > 0d) { Vector3d yaxis = rectg.GetLeftVerticalVector().Normalize(); Matrix3d mat = Matrix3d.Displacement(yaxis.MultiplyBy(_volumeTextHeight * 0.7)); topPosition = topPosition.TransformBy(mat); bottomPosition = bottomPosition.TransformBy(mat.Inverse()); } if (Math.Round(volumeInfo.Fill, 1) > 0d) { DBText topText = new DBText(); topText.SetDatabaseDefaults(); topText.Height = _volumeTextHeight; topText.Rotation = 0d; topText.Position = Point3d.Origin; topText.HorizontalMode = TextHorizontalMode.TextCenter; topText.VerticalMode = TextVerticalMode.TextVerticalMid; topText.Annotative = AnnotativeStates.False; //topText.AddContext(_scale); topText.AlignmentPoint = topPosition; topText.AdjustAlignment(HostApplicationServices.WorkingDatabase); topText.TextString = '+' + Math.Round(volumeInfo.Fill).ToString("#0.0", _culture); res.Add(topText); } else { res.Add(null); } if (Math.Round(volumeInfo.Cut, 1) > 0d) { DBText bottomText = new DBText(); bottomText.SetDatabaseDefaults(); bottomText.Height = _volumeTextHeight; bottomText.Rotation = 0d; bottomText.Position = Point3d.Origin; bottomText.HorizontalMode = TextHorizontalMode.TextCenter; bottomText.VerticalMode = TextVerticalMode.TextVerticalMid; bottomText.Annotative = AnnotativeStates.False; //bottomText.AddContext(_scale); bottomText.AlignmentPoint = bottomPosition;; bottomText.AdjustAlignment(HostApplicationServices.WorkingDatabase); bottomText.TextString = Math.Round(-volumeInfo.Cut, 1).ToString("#0.0", _culture); res.Add(bottomText); } else { res.Add(null); } if (Math.Round(volumeInfo.Fill, 1) == 0d && Math.Round(volumeInfo.Cut, 1) == 0d) { DBText centralText = new DBText(); centralText.SetDatabaseDefaults(); centralText.Height = _volumeTextHeight; centralText.Rotation = 0d; centralText.Position = Point3d.Origin; centralText.HorizontalMode = TextHorizontalMode.TextCenter; centralText.VerticalMode = TextVerticalMode.TextVerticalMid; centralText.Annotative = AnnotativeStates.False; //topText.AddContext(_scale); centralText.AlignmentPoint = topPosition; centralText.AdjustAlignment(HostApplicationServices.WorkingDatabase); centralText.TextString = Math.Round(volumeInfo.Fill).ToString("#0.0", _culture); res.Add(centralText); } return(res); }