1
.NET / Re: How to add breaklines to Civil-3D surface in C#.NET?
« Last post by eddybeerke on May 27, 2024, 03:19:12 AM »...Verry intresting topic.
I took some code from it to build my own solution to add multiple breaklines:
Code: [Select]
SelectionSet res = getSelectionSet();
if (res != null)
{
PromptKeywordOptions pKeyOpts = new PromptKeywordOptions("");
pKeyOpts.Message = "\nEnter the type of breakline to create: ";
pKeyOpts.Keywords.Add("Standard");
pKeyOpts.Keywords.Add("Non-Destructive");
pKeyOpts.Keywords.Add("Proximity");
pKeyOpts.Keywords.Default = "Standard";
pKeyOpts.AllowNone = true;
PromptResult pKeyRes = editor.GetKeywords(pKeyOpts);
ObjectId[] lines;
try
{
switch (pKeyRes.StringResult)
{
case "Non-Destructive":
// Step through the objects in the selection set
foreach (ObjectId acSSObj in res.GetObjectIds())
{
lines = new ObjectId[] { acSSObj };
oSurface.BreaklinesDefinition.AddNonDestructiveBreaklines(new ObjectIdCollection(lines), 1);
}
break;
case "Proximity":
// Step through the objects in the selection set
foreach (ObjectId acSSObj in res.GetObjectIds())
{
lines = new ObjectId[] { acSSObj };
oSurface.BreaklinesDefinition.AddProximityBreaklines(new ObjectIdCollection(lines), 1);
}
break;
case "Standard":
default:
// Step through the objects in the selection set
foreach (ObjectId acSSObj in res.GetObjectIds())
{
lines = new ObjectId[] { acSSObj };
//oSurface.BreaklinesDefinition.AddStandardBreaklines(new ObjectIdCollection(lines), 10, 5, 5, 0);
oSurface.BreaklinesDefinition.AddStandardBreaklines(new ObjectIdCollection(lines), 0.01, 2, 5, 0);
}
break;
}
}
catch (System.Exception e)
{
editor.WriteMessage("Operation failed: {0}", e.Message);
}
// commit the transaction
ts.Commit();
}
Code: [Select]
public SelectionSet getSelectionSet()
{
//CivilDocument doc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument;
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
// Request for objects to be selected in the drawing area
PromptSelectionResult acSSPrompt = ed.GetSelection();
// If the prompt status is OK, objects were selected
if (acSSPrompt.Status == PromptStatus.OK)
{
SelectionSet acSSet = acSSPrompt.Value;
return acSSet;
}
return null;
}