Partha,
Below is an extraction of the code that I am using. There are also some transient graphics that get drawn, but the code is below. The Regen and UpdateScreen was primarily used to get rid of any lingering temporary objects. Replace the station and elevation to a value that works with the profile you test this on.
private void RunCommand()
{
Database db = acadApp.Application.DocumentManager.MdiActiveDocument.Database;
Editor ed = acadApp.Application.DocumentManager.MdiActiveDocument.Editor;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
ObjectId profileObjId = civDoc.SelectProfile("Select profile section to edit: ", out profView);
Profile profSection = profileObjId.GetObject(OpenMode.ForRead) as Profile;
profSection.PVIs.AddPVI(editPtForm.PointStation, editPtForm.PointElevation);
ed.Regen();
ed.UpdateScreen();
tr.Commit();
}
}
public static ObjectId SelectProfile(this CivilDocument civDoc, string prompt, out ProfileView profView)
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptEntityOptions pops = new PromptEntityOptions("\n" + prompt);
profView = null;
PromptEntityResult profileRes = ed.GetEntity("AeccDbVAlignment", pops, "\nYou must select a Profile:");
if (profileRes.Status == PromptStatus.OK)
{
// Get the profile view of the profile.
Profile prof = profileRes.ObjectId.GetObject(OpenMode.ForRead) as Profile;
Alignment align = prof.AlignmentId.GetObject(OpenMode.ForRead) as Alignment;
profView = align.GetProfileViewByPoint(profileRes.PickedPoint).GetObject(OpenMode.ForRead) as ProfileView;
return profileRes.ObjectId;
}
return ObjectId.Null;
}
Thanks
Christopher
Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/

Alumni