//뷰를 세로 만들고 현제로 설정
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
[CommandMethod("CreateNamedView")]
public static void CreateNamedView()
{
// Get the current database
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
// Start a transaction
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// Open the View table for read
ViewTable acViewTbl;
acViewTbl = acTrans.GetObject(acCurDb.ViewTableId,
OpenMode.ForRead) as ViewTable;
// Check to see if the named view 'View1' exists
//"VIEW1"이라는 뷰가있는지 먼저 확인을 한다.
if (acViewTbl.Has("View1") == false)
{
// Open the View table for write
acViewTbl.UpgradeOpen();
// Create a new View table record and name the view 'View1'
ViewTableRecord acViewTblRec = new ViewTableRecord();
acViewTblRec.Name = "View1";
// Add the new View table record to the View table and the transaction
acViewTbl.Add(acViewTblRec);
acTrans.AddNewlyCreatedDBObject(acViewTblRec, true);
// Set 'View1' current
acDoc.Editor.SetCurrentView(acViewTblRec);
// Commit the changes
acTrans.Commit();
}
// Dispose of the transaction
}
}
댓글 없음 :
댓글 쓰기