Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using Autodesk.AutoCAD.Runtime;
Using Autodesk.AutoCAD.EditorInput;
Using Autodesk.AutoCAD.ApplicationServices;
Using Autodesk.Civil.DatabaseServices;
Using Autodesk.Civil;
Using Autodesk.AutoCAD.DatabaseServices;
Namespace OffsetAlignmentDemo {
Public Class OffsetDemo
{
[CommandMethod("TTD")]
Public void CreateAlignment()
{
var doc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
// Ask the user To Select a polyline To convert To an alignment
PromptEntityOptions opt = New PromptEntityOptions("\nSelect a polyline To convert To an Alignment");
opt.SetRejectMessage("\nObject must be a polyline.");
opt.AddAllowedClass(TypeOf(Polyline), False);
PromptEntityResult res = ed.GetEntity(opt);
Form1 od = New Form1();
od.ShowDialog();
// create some polyline options For creating the New alignment
PolylineOptions plops = New PolylineOptions();
plops.AddCurvesBetweenTangents = True;
plops.EraseExistingEntities = True;
plops.PlineId = res.ObjectId;
// uses an existing Alignment Style And Label Set Style named "Basic" (For example, from
// the Civil 3D (Imperial) NCS Base.dwt template. This Call will fail If the named styles
// don’t exist.
ObjectId testAlignmentID = Alignment.Create(doc, plops, a, null, "0", "Basic", "All Labels");
}
}
}