소스 정보
- 저장소
- hebackus/c3d-api-plugin
- 최근 소스 활동
- 2026년 4월 9일 01:53
- 감지된 SKILL.md 언어
- 영어
- 스타
- 3
- 포크
- 0
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/hebackus/c3d-api-plugin --skill acad-polylines명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | acad-polylines |
| description | Polyline, Polyline2d, Polyline3d — vertices, bulges, area, type conversion |
Use this skill when creating, reading, or modifying polylines — lightweight polylines (Polyline / LWPOLYLINE), 2D polylines (Polyline2d), 3D polylines (Polyline3d), vertex manipulation, bulge values, and curve extraction.
Polyline polyline = new Polyline();
polyline.Layer = layerName;
for (int i = 0; i < points.Count; i++)
{
Point2d pt = points[i];
double bulge = i < bulges.Count ? bulges[i] : 0.0;
polyline.AddVertexAt(i, pt, bulge, 0.0, 0.0);
// AddVertexAt(index, point, bulge, startWidth, endWidth)
}
polyline.ColorIndex = 256; // ByLayer
// or: polyline.Color = Color.FromRgb(255, 0, 255);
BlockTableRecord ms = (BlockTableRecord)tr.GetObject(
bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
ms.AppendEntity(polyline);
tr.AddNewlyCreatedDBObject(polyline, true);
Polyline pline = tr.GetObject(entityId, OpenMode.ForRead) as Polyline;
int count = pline.NumberOfVertices;
for (int i = 0; i < count; i++)
{
Point2d pt = pline.GetPoint2dAt(i); // 2D vertex in OCS
Point3d pt3d = pline.GetPoint3dAt(i); // 3D vertex (applies Elevation)
double bulge = pline.GetBulgeAt(i); // arc curvature to next vertex
double startW = pline.GetStartWidthAt(i);
double endW = pline.GetEndWidthAt(i);
}
pline.UpgradeOpen(); // or open ForWrite initially
// Move a vertex
pline.SetPointAt(2, new Point2d(10.0, 20.0));
// Change arc curvature
pline.SetBulgeAt(2, 0.5);
// Change width at a vertex
pline.SetStartWidthAt(2, 0.0);
pline.SetEndWidthAt(2, 1.0);
// Insert a new vertex at index 3
pline.AddVertexAt(3, new Point2d(15.0, 25.0), 0.0, 0.0, 0.0);
// Remove vertex at index 3
pline.RemoveVertexAt(3);
The bulge value at vertex i defines the arc from vertex i to vertex i+1:
bulge = tan(includedAngle / 4)
| Bulge | Meaning |
|---|---|
0.0 | Straight segment |
> 0 | Counter-clockwise arc |
< 0 | Clockwise arc |
1.0 | Semicircle (180°) CCW |
-1.0 | Semicircle (180°) CW |
0.4142 | 90° arc CCW |
-0.4142 | 90° arc CW |
// From included angle (radians)
double bulge = Math.Tan(includedAngle / 4.0);
// Back to angle
double angle = 4.0 * Math.Atan(Math.Abs(bulge)); // always positive
Polyline inherits from Curve. All Curve methods are available.
// Point at a given distance along the curve
Point3d pt = pline.GetPointAtDist(50.0);
// Distance to a point on the curve
double dist = pline.GetDistAtPoint(pt);
// Closest point on curve to an arbitrary point
Point3d closest = pline.GetClosestPointTo(testPoint, false);
// second param: extend curve if needed
// Tangent direction at a point
Vector3d tangent = pline.GetFirstDerivative(pline.GetParameterAtPoint(pt));
// Offset polyline by distance (positive = left, negative = right relative to direction)
DBObjectCollection offsets = pline.GetOffsetCurves(2.5);
foreach (DBObject obj in offsets)
{
Entity offsetEnt = (Entity)obj;
ms.AppendEntity(offsetEnt);
tr.AddNewlyCreatedDBObject(offsetEnt, true);
}
// Split at a point
DBObjectCollection pieces = pline.GetSplitCurves(
new Point3dCollection { splitPoint });
// Reverse direction
pline.ReverseCurve();
for (int i = 0; i < pline.NumberOfVertices - 1; i++)
{
SegmentType segType = pline.GetSegmentType(i);
if (segType == SegmentType.Line)
{
LineSegment2d lineSeg = pline.GetLineSegment2dAt(i);
double length = lineSeg.Length;
}
else if (segType == SegmentType.Arc)
{
CircularArc2d arcSeg = pline.GetArcSegment2dAt(i);
double radius = arcSeg.Radius;
Point2d center = arcSeg.Center;
}
}
SegmentType.Line — straight segmentSegmentType.Arc — arc segmentSegmentType.Coincident — zero-length segment (coincident vertices)SegmentType.Point — degenerate segmentSegmentType.Empty — no segmentPolyline2d vertices are separate database objects (Vertex2d) owned by the polyline.
Point3dCollection pts = new Point3dCollection
{
new Point3d(0, 0, 0),
new Point3d(10, 0, 0),
new Point3d(10, 10, 0)
};
Polyline2d pline2d = new Polyline2d(Poly2dType.SimplePoly, pts, 0.0, false, 0.0, 0.0, null);
// (type, points, elevation, closed, defaultStartWidth, defaultEndWidth, bulges)
ms.AppendEntity(pline2d);
tr.AddNewlyCreatedDBObject(pline2d, true);
Polyline2d pline2d = tr.GetObject(entityId, OpenMode.ForRead) as Polyline2d;
foreach (ObjectId vertexId in pline2d)
{
Vertex2d vertex = tr.GetObject(vertexId, OpenMode.ForRead) as Vertex2d;
if (vertex == null) continue;
Point3d position = vertex.Position;
double bulge = vertex.Bulge;
double startWidth = vertex.StartWidth;
double endWidth = vertex.EndWidth;
}
Polyline3d vertices are separate database objects (PolylineVertex3d) with full 3D coordinates.
Point3dCollection pts = new Point3dCollection
{
new Point3d(0, 0, 0),
new Point3d(10, 0, 5),
new Point3d(20, 10, 10)
};
Polyline3d pline3d = new Polyline3d(Poly3dType.SimplePoly, pts, false);
ms.AppendEntity(pline3d);
tr.AddNewlyCreatedDBObject(pline3d, true);
Polyline3d pline3d = tr.GetObject(entityId, OpenMode.ForRead) as Polyline3d;
foreach (ObjectId vertexId in pline3d)
{
PolylineVertex3d vertex = tr.GetObject(vertexId, OpenMode.ForRead) as PolylineVertex3d;
if (vertex == null) continue;
Point3d position = vertex.Position;
}
When processing an entity that could be any polyline type, use a cascade pattern:
private static List<Point3d> GetVertices(Entity entity, Transaction tr)
{
List<Point3d> points = new List<Point3d>();
Polyline pline = entity as Polyline;
if (pline != null)
{
for (int i = 0; i < pline.NumberOfVertices; i++)
points.Add(pline.GetPoint3dAt(i));
}
else
{
Polyline2d pline2d = entity as Polyline2d;
if (pline2d != null)
{
foreach (ObjectId vId in pline2d)
{
Vertex2d v = tr.GetObject(vId, OpenMode.ForRead) as Vertex2d;
if (v != null) points.Add(v.Position);
}
}
else
{
Polyline3d pline3d = entity as Polyline3d;
if (pline3d != null)
{
foreach (ObjectId vId in pline3d)
{
PolylineVertex3d v = tr.GetObject(vId, OpenMode.ForRead) as PolylineVertex3d;
if (v != null) points.Add(v.Position);
}
}
}
}
return points;
}
// Join contiguous polylines into one (endpoints must be within tolerance)
pline.UpgradeOpen();
pline.JoinEntities(new Entity[] { otherPline1, otherPline2 });
pline.UpgradeOpen();
pline.ReverseCurve();
Point3dCollection points = new Point3dCollection();
for (int i = 0; i < pline.NumberOfVertices; i++)
points.Add(pline.GetPoint3dAt(i));
pline2d.UpgradeOpen();
pline2d.ConvertToPolyType(Poly2dType.CubicSplinePoly);
// Also: QuadSplinePoly, FitCurvePoly
Elevation propertyMatrix3d.WorldToPlane(Normal) if the normal is not ZAxisAddVertexAt index must be 0 to NumberOfVertices inclusive — index = NumberOfVertices appendsRemoveVertexAt on a polyline with only 2 vertices throws — erase the entity instead"LWPOLYLINE" = Polyline class; "POLYLINE" = Polyline2d or Polyline3d — check the managed type to distinguishGetOffsetCurves returns DBObjectCollection — results may not be Polyline (could be individual curves for complex offsets)Area only works on closed polylines in a plane — throws for non-planar 3D polylinesi defines the arc from vertex i to vertex i+1 (not centered on vertex i)Closed = true adds a segment from last to first vertex — does not duplicate the first pointJoinEntities requires contiguous endpoints within Application.DocumentManager.MdiActiveDocument.Database.EqualPoint toleranceforeach yields ObjectIds of all sub-entities including fit/spline vertices — check VertexType to filterConvertToPolyType on Polyline2d is destructive — original vertices become control/fit pointsacad-geometry — Point2d/Point3d construction, bulge math, CircularArc2d from arc segmentsacad-editor-input — selecting polylines with GetEntity or selection filters (DxfCode.Start "LWPOLYLINE")acad-layers — setting polyline layer, reading layer propertiesacad-hatches — polylines as hatch boundary loops (AppendLoop with entity IDs or vertex+bulge arrays)