ProfileView クラスには、図面に新規 ProfileView オブジェクトを追加するための 2 つのバージョンの Profil View::Create() メソッドがあります。各メソッド オーバーロードは、CivilDrawing オブジェクトへの参照、新規縦断ビューの名前、および縦断ビューが挿入された図面内の Point3d の場所を取得します。これら 2 つのバージョンは、帯セット スタイルと線形も取得します。一方のバージョンは、線形を ObjectId として取得し、もう一方のバージョンは、文字列として取得します。
この例では、新規 ProfileView の作成について説明します。
[CommandMethod("CreateProfileView")]
public void CreateProfileView()
{
doc = CivilApplication.ActiveDocument;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
{
// Ask the user to select an alignment
PromptEntityOptions opt = new PromptEntityOptions("\nSelect an Alignment");
opt.SetRejectMessage("\nObject must be an alignment.\n");
opt.AddAllowedClass(typeof(Alignment), false);
ObjectId alignID = ed.GetEntity(opt).ObjectId;
// Create insertion point:
Point3d ptInsert = new Point3d(100, 100, 0);
// Get profile view band set style ID:
ObjectId pfrVBSStyleId = doc.Styles.ProfileViewBandSetStyles["Standard"];
// If this doesn't exist, get the first style in the collection
if (pfrVBSStyleId == null) pfrVBSStyleId = doc.Styles.ProfileViewBandSetStyles[0];
ObjectId ProfileViewId = ProfileView.Create(doc, "New Profile View", pfrVBSStyleId, alignID, ptInsert);
ts.Commit();
}
}