AutoCAD .NET API :プリセットビューの変更

Autodesk Support

2020年2月24日


Issue

ViewCube のようにプリセットされたビューの切り替え​を AutoCAD .NET API でおこなう方法を教えてください。

Solution

次のコードでプリセットされたビューの切り替えが可能です。なお、太字部分の OrthographicView 列挙値で切り替えるプリセットビューを変更することが出来ます設定可能な値は、次のとおりです。

  NonOrthoView
  TopView
  BottomView
  FrontView
  BackView
  LeftView
  RightView

 

C# コード

            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Database db = Application.DocumentManager.MdiActiveDocument.Database;

            ed.UpdateTiledViewportsInDatabase();

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                ViewportTable tbl = tr.GetObject(db.ViewportTableId, OpenMode.ForRead) as ViewportTable;
                ViewportTableRecord rec = tr.GetObject(tbl["*Active"], OpenMode.ForWrite) as ViewportTableRecord;
                rec.SetViewDirection(OrthographicView.LeftView);
                tr.Commit();
            }

            ed.UpdateTiledViewportsFromDatabase();

 

VB.NET コード

            Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
            Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database

            ed.UpdateTiledViewportsInDatabase()

            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim tbl As ViewportTable = TryCast(tr.GetObject(db.ViewportTableId, OpenMode.ForRead), ViewportTable)
                Dim rec As ViewportTableRecord = TryCast(tr.GetObject(tbl("*Active"), OpenMode.ForWrite), ViewportTableRecord)
                rec.SetViewDirection(OrthographicView.LeftView)
                tr.Commit()
            End Using

            ed.UpdateTiledViewportsFromDatabase()



この情報は役に立ちましたか?


サポートが必要な場合は、Autodesk Assistant にお問い合わせください!

Assistant が回答を見つけたり、担当者に連絡するお手伝いをします。


オートデスクではどのようなサポートが提供されますか?

ご利用可能なサポートの種類は、サブスクリプションのプランによって異なります。現在のプランでご利用可能なサポート レベルをご確認ください。

サポート レベルを確認