원클릭으로
c3d-grading
Grading groups, criteria, feature line grading, daylight, volume calculation
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Grading groups, criteria, feature line grading, daylight, volume calculation
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | c3d-grading |
| description | Grading groups, criteria, feature line grading, daylight, volume calculation |
Use this skill when working with grading objects - creating grading groups, defining grading criteria, projecting feature lines to surfaces or elevations, computing daylight lines, and calculating grading volumes.
Site
├── GradingGroup - Container for related grading objects
│ ├── Grading - Single grading projection from a footprint
│ └── Surface (automatic) - TIN surface generated from grading objects
└── FeatureLine - 3D polyline used as grading footprint
A Grading projects outward (or inward) from a FeatureLine footprint toward a target (surface, distance, elevation, or relative elevation) using a slope defined in a GradingCriteria. Gradings are organized into GradingGroups, which can automatically generate a TIN surface.
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;
using Autodesk.Civil.DatabaseServices.Styles;
GradingCriteria and GradingCriteriaSet live in Autodesk.Civil.DatabaseServices.Styles. All other grading classes live in Autodesk.Civil.DatabaseServices.
CivilDocument doc = CivilApplication.ActiveDocument;
// Get all grading group ObjectIds in the drawing
ObjectIdCollection gradingGroupIds = doc.GetGradingGroupIds();
foreach (ObjectId ggId in gradingGroupIds)
{
GradingGroup gg = ts.GetObject(ggId, OpenMode.ForRead) as GradingGroup;
ed.WriteMessage("Grading Group: {0}, Surface: {1}\n",
gg.Name, gg.AutomaticSurfaceCreation ? "Auto" : "None");
}
CivilDocument doc = CivilApplication.ActiveDocument;
// Grading groups belong to a site - get or create a site first
ObjectId siteId = doc.GetSiteIds()[0]; // use existing site
Site site = ts.GetObject(siteId, OpenMode.ForWrite) as Site;
// Create a new grading group
ObjectId ggId = GradingGroup.Create(site.Id, "Parking Lot Grading");
GradingGroup gg = ts.GetObject(ggId, OpenMode.ForWrite) as GradingGroup;
// Enable automatic surface creation
gg.AutomaticSurfaceCreation = true;
// Set a volume baseline surface for cut/fill computation
gg.VolumeBaselineSurfaceId = existingSurfaceId;
Feature lines are 3D polylines that serve as grading footprints. They belong to a site and can have per-vertex elevations.
// Create from an existing polyline, arc, line, or 3D polyline
ObjectId flId = FeatureLine.Create(
"MyFeatureLine", // name
polylineId, // source entity ObjectId
siteId); // site ObjectId
// Create from a set of points
Point3dCollection points = new Point3dCollection();
points.Add(new Point3d(0, 0, 100));
points.Add(new Point3d(100, 0, 100));
points.Add(new Point3d(100, 100, 100));
points.Add(new Point3d(0, 100, 100));
ObjectId flId = FeatureLine.Create("Footprint", points, siteId);
FeatureLine fl = ts.GetObject(flId, OpenMode.ForWrite) as FeatureLine;
// Set all vertex elevations from a surface
fl.SetElevationsFromSurface(surfaceId);
// Assign a constant elevation to the entire feature line
fl.AssignElevationsToVertices(105.0);
// Get the elevation at a specific station along the feature line
double elev = fl.GetElevationAtStation(50.0);
// Insert an elevation point at a station
fl.InsertElevationPoint(75.0); // station
// Get all points (geometry + elevation points)
Point3dCollection pts = fl.GetPoints(FeatureLinePointType.AllPoints);
// Get only PI (geometry) points
Point3dCollection piPts = fl.GetPoints(FeatureLinePointType.PIPoint);
// Get only elevation points
Point3dCollection elevPts = fl.GetPoints(FeatureLinePointType.ElevationPoint);
// Set elevation at a specific point
fl.SetPointElevation(pointIndex, 102.5);
// Raise/lower entire feature line by a delta
fl.RaiseElevations(2.0); // raise by 2 feet
fl.RaiseElevations(-1.5); // lower by 1.5 feet
AllPoints — all geometry and elevation pointsPIPoint — point of intersection (geometry vertices)ElevationPoint — manually inserted elevation pointsGrading criteria define the projection rule: target type, slope format, cut/fill slopes, and search order. They are style objects stored in criteria sets.
Surface — project to a target surface (daylight)Distance — project a fixed horizontal distanceElevation — project to an absolute elevationRelativeElevation — project to an elevation relative to the footprintGrade -- slope as a percentage (e.g., 2.0 = 2%)SlopeRatio -- slope as a ratio (e.g., 3.0 = 3:1)RiseRun -- slope as rise over runCutFirst -- test for cut condition before fillFillFirst -- test for fill condition before cutCivilDocument doc = CivilApplication.ActiveDocument;
// Access grading criteria sets from styles
ObjectIdCollection criteriaSetIds = doc.Styles.GradingCriteriaSetStyles;
GradingCriteriaSet criteriaSet = ts.GetObject(
criteriaSetIds[0], OpenMode.ForRead) as GradingCriteriaSet;
// Iterate criteria in the set
foreach (ObjectId criteriaId in criteriaSet)
{
GradingCriteria criteria = ts.GetObject(
criteriaId, OpenMode.ForRead) as GradingCriteria;
ed.WriteMessage("Criteria: {0}, Target: {1}\n",
criteria.Name, criteria.Target);
}
// Get or create a criteria set
ObjectId csId = doc.Styles.GradingCriteriaSetStyles.Add("Site Criteria");
GradingCriteriaSet criteriaSet = ts.GetObject(csId, OpenMode.ForWrite) as GradingCriteriaSet;
// Add a new criteria to the set
ObjectId critId = criteriaSet.Add("3:1 to Surface");
GradingCriteria criteria = ts.GetObject(critId, OpenMode.ForWrite) as GradingCriteria;
// Configure as daylight to surface with 3:1 slopes
// IMPORTANT: Set Target first, before CutSlope/FillSlope
criteria.Target = GradingTargetType.Surface;
criteria.SearchOrder = GradingSearchOrderType.CutFirst;
criteria.SlopeFormatType = GradingSlopeFormatType.SlopeRatio;
criteria.CutSlope = 3.0; // 3:1 cut
criteria.FillSlope = 3.0; // 3:1 fill
ObjectId critId = criteriaSet.Add("10ft at 2%");
GradingCriteria criteria = ts.GetObject(critId, OpenMode.ForWrite) as GradingCriteria;
criteria.Target = GradingTargetType.Distance;
criteria.SlopeFormatType = GradingSlopeFormatType.Grade;
criteria.Slope = -2.0; // 2% downward grade
criteria.Distance = 10.0; // 10-foot projection
ObjectId critId = criteriaSet.Add("Drop 3ft at 4:1");
GradingCriteria criteria = ts.GetObject(critId, OpenMode.ForWrite) as GradingCriteria;
criteria.Target = GradingTargetType.RelativeElevation;
criteria.SlopeFormatType = GradingSlopeFormatType.SlopeRatio;
criteria.Slope = 4.0; // 4:1
criteria.RelativeElevation = -3.0; // 3 feet below footprint
A grading projects from a feature line footprint using a grading criteria.
// Create a grading in a grading group from a feature line
Grading grading = Grading.Create(
gradingGroupId, // parent grading group ObjectId
featureLineId, // footprint feature line ObjectId
criteriaId, // grading criteria ObjectId
targetSurfaceId, // target surface (for daylight; ObjectId.Null for non-surface targets)
true); // grade to exterior (true) or interior (false)
Grading grading = ts.GetObject(gradingId, OpenMode.ForWrite) as Grading;
// Change criteria
grading.GradingCriteriaId = newCriteriaId;
// Change target surface
grading.TargetSurfaceId = newSurfaceId;
// Rebuild the grading group after changes
GradingGroup gg = ts.GetObject(grading.GradingGroupId, OpenMode.ForWrite) as GradingGroup;
gg.Update();
Daylight grading projects from a feature line to an existing ground surface. The projection follows cut and fill slopes until it intersects the target surface.
// 1. Create or access the existing ground surface
ObjectId existingGroundId = doc.GetSurfaceIds()[0];
// 2. Create a feature line for the design edge (e.g., top of slope)
Point3dCollection pts = new Point3dCollection();
pts.Add(new Point3d(1000, 1000, 105));
pts.Add(new Point3d(1200, 1000, 105));
pts.Add(new Point3d(1200, 1200, 105));
ObjectId flId = FeatureLine.Create("Design Edge", pts, siteId);
// 3. Set up daylight criteria (2:1 cut, 3:1 fill)
ObjectId csId = doc.Styles.GradingCriteriaSetStyles.Add("Daylight Set");
GradingCriteriaSet cs = ts.GetObject(csId, OpenMode.ForWrite) as GradingCriteriaSet;
ObjectId critId = cs.Add("Daylight 2:1/3:1");
GradingCriteria crit = ts.GetObject(critId, OpenMode.ForWrite) as GradingCriteria;
crit.Target = GradingTargetType.Surface;
crit.SearchOrder = GradingSearchOrderType.CutFirst;
crit.SlopeFormatType = GradingSlopeFormatType.SlopeRatio;
crit.CutSlope = 2.0;
crit.FillSlope = 3.0;
// 4. Create grading group and grading
ObjectId ggId = GradingGroup.Create(siteId, "Daylight Grading");
GradingGroup gg = ts.GetObject(ggId, OpenMode.ForWrite) as GradingGroup;
gg.AutomaticSurfaceCreation = true;
Grading grading = Grading.Create(ggId, flId, critId, existingGroundId, true);
// 5. Rebuild
gg.Update();
When a grading group has AutomaticSurfaceCreation enabled and a VolumeBaselineSurfaceId set, Civil 3D computes cut/fill volumes between the grading surface and the baseline surface.
GradingGroup gg = ts.GetObject(ggId, OpenMode.ForRead) as GradingGroup;
// Ensure volume baseline is set
if (gg.VolumeBaselineSurfaceId != ObjectId.Null)
{
// Access the grading group's auto-generated surface
ObjectId gradingSurfaceId = gg.SurfaceId;
// Create a TIN volume surface for precise computation
ObjectId volSurfId = TinVolumeSurface.Create(
"Grading Volumes",
gg.VolumeBaselineSurfaceId, // base (existing ground)
gradingSurfaceId, // comparison (grading surface)
doc.Styles.SurfaceStyles[0]);
TinVolumeSurface volSurf = ts.GetObject(
volSurfId, OpenMode.ForRead) as TinVolumeSurface;
VolumeSurfaceProperties volProps = volSurf.GetVolumeProperties();
ed.WriteMessage("Cut: {0:F2} cu.yd, Fill: {1:F2} cu.yd, Net: {2:F2} cu.yd\n",
volProps.AdjustedCutVolume / 27.0,
volProps.AdjustedFillVolume / 27.0,
volProps.AdjustedNetVolume / 27.0);
}
// Calculate volumes within a polygon region
TinSurface surface = ts.GetObject(surfaceId, OpenMode.ForRead) as TinSurface;
Point3dCollection boundary = new Point3dCollection();
boundary.Add(new Point3d(x1, y1, 0));
boundary.Add(new Point3d(x2, y2, 0));
boundary.Add(new Point3d(x3, y3, 0));
SurfaceVolumeInfo volInfo = surface.GetBoundedVolumes(boundary, datumElevation);
ed.WriteMessage("Cut: {0:F2}, Fill: {1:F2}\n", volInfo.Cut, volInfo.Fill);
TinVolumeSurface volSurf = ts.GetObject(volSurfId, OpenMode.ForWrite) as TinVolumeSurface;
volSurf.CutFactor = 1.0; // no swell
volSurf.FillFactor = 1.15; // 15% compaction factor
VolumeSurfaceProperties props = volSurf.GetVolumeProperties();
// props.AdjustedCutVolume, AdjustedFillVolume reflect factors
GradingCriteria.Target before accessing CutSlope, FillSlope, or Slope. Setting slopes before target causes unexpected behavior or exceptions.Site. You cannot create them without a valid site.GradingGroup.Update() to rebuild the surface.SetElevationsFromSurface() overwrites all vertex elevations. If you need to override specific vertices afterward, call SetPointElevation() after the surface assignment.isExterior parameter in Grading.Create() controls projection direction. Exterior projects outward from the footprint; interior projects inward (e.g., pond or ditch).Grading.Create() is unavailable, use the COM IAeccGradingGroup interface as a fallback.c3d-surfaces -- TIN surfaces, volume surfaces, and bounded volume queriesc3d-corridors -- Corridor feature lines and corridor surfacesc3d-alignments -- Alignments that can define grading footprint geometryc3d-root-objects -- CivilDocument, sites, and top-level object accessCorridors, baselines, regions, assemblies, subassemblies, corridor surfaces
Custom subassembly .NET design — CorridorState, SubassemblyGenerator, targets, SATemplate
Stock-subassembly pattern catalog — need→file index, worked DrawImplement recipes, point/link/shape code reference, mined from Autodesk's 120 VB stock subassemblies
Superelevation design, attainment, cross slope, pivot points, lane config
Block definitions, references, attributes, dynamic block properties, exploding
Dimensions — aligned, rotated, arc, radial, angular, ordinate, text overrides