소스 정보
- 저장소
- 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 c3d-data-shortcuts명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | c3d-data-shortcuts |
| description | Data shortcut references, cross-drawing objects, broken reference repair |
Use this skill when working with data shortcuts, creating or managing cross-drawing references, synchronizing imported references, repairing broken references, or configuring data shortcut working and project folders.
Data shortcuts allow Civil 3D objects in one drawing (the source) to be referenced read-only into other drawings (the host). The .NET API exposes this through the DataShortcuts static class and the DataShortcutManager class in Autodesk.Civil.DataShortcuts. The assembly is AeccDataShortcutMgd.dll.
Working Folder
└── Project Folder (_Shortcuts/ subfolder)
├── Alignments.xml
├── Surfaces.xml
├── Pipe Networks.xml
├── Pressure Pipe Networks.xml
├── Corridors.xml
└── View Frame Groups.xml
The DataShortcuts.RefType enumeration defines the publishable entity types:
using Autodesk.Civil.DataShortcuts;
// Available RefType values:
// RefType.Surface
// RefType.Alignment (parent alignments)
// RefType.AlignmentChildren (child offset/widening alignments)
// RefType.Profile
// RefType.PipeNetwork
// RefType.PressureNetwork
// RefType.Corridor
// RefType.ViewFrameGroup
using Autodesk.Civil.DataShortcuts;
// Get current working folder path
string workingFolder = DataShortcuts.GetWorkingFolderPath();
ed.WriteMessage("Working folder: {0}\n", workingFolder);
// Set a new working folder path
DataShortcuts.SetWorkingFolderPath(@"C:\Civil3D Projects");
// Get current project folder (relative to working folder)
string projectFolder = DataShortcuts.GetProjectFolderPath();
ed.WriteMessage("Project folder: {0}\n", projectFolder);
// Set project folder (relative path from working folder)
DataShortcuts.SetProjectFolderPath("MyProject");
// Get the data shortcut project ID for a given path
int projectId = DataShortcuts.GetDSProjectId(@"C:\Civil3D Projects\MyProject");
// Associate a data shortcut project with the current drawing
DataShortcuts.AssociateDSProject(projectId);
// Get all published items in the current project
DataShortcutManager dsMgr = DataShortcuts.CreateDataShortcutManager(ref projectId);
int count = dsMgr.GetPublishedItemsCount();
for (int i = 0; i < count; i++)
{
DSEntityInfo info = dsMgr.GetPublishedItemAt(i);
ed.WriteMessage("Name: {0}, Type: {1}, Source: {2}\n",
info.Name, info.RefType, info.SourceDrawing);
}
// Clean up (DataShortcutManager implements IDisposable)
dsMgr.Dispose();
using Autodesk.Civil.DataShortcuts;
using Autodesk.Civil.ApplicationServices;
// Create a reference to a published surface in the current drawing
DataShortcuts.CreateReference(
doc.Database, // target database (host drawing)
"EG Surface", // entity name in the source drawing
RefType.Surface // entity type
);
int projectId = 0;
DataShortcutManager dsMgr = DataShortcuts.CreateDataShortcutManager(ref projectId);
// Find the published item index by name and type
int itemIndex = -1;
int count = dsMgr.GetPublishedItemsCount();
for (int i = 0; i < count; i++)
{
DSEntityInfo info = dsMgr.GetPublishedItemAt(i);
if (info.Name == "Main Road CL" && info.RefType == RefType.Alignment)
{
itemIndex = i;
break;
}
}
if (itemIndex >= 0)
{
// Create the reference in the current drawing
dsMgr.CreateReference(itemIndex, doc.Database);
ed.WriteMessage("Reference created for alignment 'Main Road CL'.\n");
}
dsMgr.Dispose();
int projectId = 0;
DataShortcutManager dsMgr = DataShortcuts.CreateDataShortcutManager(ref projectId);
RefType[] typesToImport = {
RefType.Surface,
RefType.Alignment,
RefType.PipeNetwork
};
int imported = 0;
int count = dsMgr.GetPublishedItemsCount();
for (int i = 0; i < count; i++)
{
DSEntityInfo info = dsMgr.GetPublishedItemAt(i);
if (Array.IndexOf(typesToImport, info.RefType) >= 0)
{
try
{
dsMgr.CreateReference(i, doc.Database);
imported++;
ed.WriteMessage("Imported: {0} ({1})\n", info.Name, info.RefType);
}
catch (System.Exception ex)
{
ed.WriteMessage("Failed to import {0}: {1}\n", info.Name, ex.Message);
}
}
}
ed.WriteMessage("Total imported: {0}\n", imported);
dsMgr.Dispose();
using (Transaction ts = db.TransactionManager.StartTransaction())
{
Alignment align = ts.GetObject(alignId, OpenMode.ForRead) as Alignment;
// Check if this entity is a data reference (read-only cross-drawing ref)
if (align.IsReferenceObject)
{
ed.WriteMessage("'{0}' is a data reference.\n", align.Name);
// Get reference information
DataShortcutKey dsKey = align.GetReferenceInfo();
ed.WriteMessage(" Source drawing: {0}\n", dsKey.SourceDrawing);
ed.WriteMessage(" Source entity: {0}\n", dsKey.SourceEntityName);
ed.WriteMessage(" Ref type: {0}\n", dsKey.RefType);
}
// Check for sub-objects (e.g., profiles that came along with an alignment ref)
if (align.IsReferenceSubObject)
{
ed.WriteMessage("'{0}' is a reference sub-object.\n", align.Name);
}
ts.Commit();
}
CivilDocument doc = CivilApplication.ActiveDocument;
using (Transaction ts = db.TransactionManager.StartTransaction())
{
// Check surfaces
foreach (ObjectId surfId in doc.GetSurfaceIds())
{
var surf = ts.GetObject(surfId, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Surface;
if (surf.IsReferenceObject)
ed.WriteMessage("DREF Surface: {0}\n", surf.Name);
}
// Check alignments
foreach (ObjectId alignId in doc.GetAlignmentIds())
{
var align = ts.GetObject(alignId, OpenMode.ForRead) as Alignment;
if (align.IsReferenceObject)
ed.WriteMessage("DREF Alignment: {0}\n", align.Name);
}
// Check pipe networks
foreach (ObjectId netId in doc.GetPipeNetworkIds())
{
var network = ts.GetObject(netId, OpenMode.ForRead) as Network;
if (network.IsReferenceObject)
ed.WriteMessage("DREF Network: {0}\n", network.Name);
}
ts.Commit();
}
When the source drawing changes, data references in host drawings must be synchronized. References auto-synchronize on drawing open, but can also be forced programmatically.
using Autodesk.Civil.DataShortcuts;
// Synchronize all data references in the active drawing
DataShortcuts.SynchronizeImport(doc.Database);
ed.WriteMessage("All data references synchronized.\n");
using (Transaction ts = db.TransactionManager.StartTransaction())
{
Alignment align = ts.GetObject(alignId, OpenMode.ForRead) as Alignment;
if (align.IsReferenceObject)
{
// Synchronize this specific reference entity
DataShortcuts.SynchronizeImport(db, alignId);
ed.WriteMessage("Synchronized reference: {0}\n", align.Name);
}
ts.Commit();
}
References break when the source drawing is moved, renamed, or deleted. The API provides repair methods.
int projectId = 0;
DataShortcutManager dsMgr = DataShortcuts.CreateDataShortcutManager(ref projectId);
int brokenCount = dsMgr.GetBrokenDRefCount(doc.Database);
ed.WriteMessage("Broken references: {0}\n", brokenCount);
for (int i = 0; i < brokenCount; i++)
{
ObjectId brokenId = dsMgr.GetBrokenDRefEntityId(doc.Database, i);
Entity ent = ts.GetObject(brokenId, OpenMode.ForRead) as Entity;
ed.WriteMessage(" Broken: {0} (ObjectId: {1})\n", ent.Name, brokenId);
}
dsMgr.Dispose();
// Repair a broken DREF by pointing it to a new source drawing path
DataShortcuts.RepairBrokenDRef(
brokenEntityId, // ObjectId of the broken reference entity
@"C:\Projects\Source\Design.dwg", // new target drawing full path
true // auto-repair other broken refs to the same source
);
int projectId = 0;
DataShortcutManager dsMgr = DataShortcuts.CreateDataShortcutManager(ref projectId);
// Repair broken shortcut by index (in the project XML, not the drawing)
bool repaired = DataShortcuts.RepairBrokenDataShortcut(
shortcutIndex, // index of the broken shortcut
@"C:\Projects\Source\Design.dwg", // new target drawing full path
true // auto-repair others pointing to same source
);
if (repaired)
ed.WriteMessage("Data shortcut repaired.\n");
else
ed.WriteMessage("Repair failed.\n");
dsMgr.Dispose();
int projectId = 0;
DataShortcutManager dsMgr = DataShortcuts.CreateDataShortcutManager(ref projectId);
int brokenCount = dsMgr.GetBrokenDRefCount(doc.Database);
if (brokenCount > 0)
{
// Repair first broken ref with autoRepairOther = true to fix all from same source
ObjectId firstBrokenId = dsMgr.GetBrokenDRefEntityId(doc.Database, 0);
DataShortcuts.RepairBrokenDRef(firstBrokenId, newSourceDrawingPath, true);
ed.WriteMessage("Attempted repair of {0} broken reference(s).\n", brokenCount);
}
dsMgr.Dispose();
DataShortcutManager holds unmanaged resources; always call Dispose() or use a using blockSynchronizeImport requires the source drawing to be accessible at the stored path; if moved, repair firstSetWorkingFolderPath and SetProjectFolderPath do not validate the path; invalid paths cause failures on next shortcut operationRepairBrokenDRef with autoRepairOther = true only repairs entities referencing the same source drawing; entities from other sources need separate repair callsIsReferenceObject first_Shortcuts subfolder is created automatically by Civil 3D in the project folder; do not manually create or modify its XML filesAECCFORCESYNCHRONIZEREFERENCES built-in command can synchronize all references interactively, but the API method SynchronizeImport is the programmatic equivalentPipeNetworkc3d-root-objects — CivilDocument, transactions, and collection access patterns used with reference entitiesc3d-alignments — Alignment creation and queries; alignment DREFs are the most common reference typec3d-surfaces — Surface objects that can be published and referenced across drawingsc3d-profiles — Profiles that accompany alignment references as sub-objectsc3d-pipe-networks — Gravity and pressure pipe networks publishable via data shortcuts