Create an orthographic view via the C# API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear All!
How can I create an orthographic view via the C# API? I'm trying to use the PnP3dOrthoDrawingsUI.dll, which has a CreateOrthos() function. However, I'm having some problems: I cannot programmatically select the viewport placement points on the drawing using the C# API. Currently, I have to use the mouse to pick the points manually.
public static void CreateOrthoView()
{
var doc = Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
try
{
var selectedModels = new StringCollection();
selectedModels.Add(@"D:\Annh\Plant3D Tool\Plant 3D Project\Test_Project_001\Plant 3D Models\001.dwg");
string viewName = "FrontView";
double scale = 0.5;
double viewportWidth = 250;
double viewportHeight = 250;
double viewportDepth = 500.0;
Commands.ViewType viewType = Commands.ViewType.Front;
string strViewType = "FrontView";
Vector3d viewDir = new Vector3d(1, 0, 0);
Vector3d upVector = new Vector3d(0, 0, 1);
Point3d lowerLeftPt = new Point3d(0, 0, -250);
Point3d upperRightPt = new Point3d(500, 500, 250);
var cubeSolid = new Solid3d();
cubeSolid.CreateBox(500, 500, 500);
var orthoView = new PlantOrthoView();
orthoView.CreateOrthos(
selectedModels, viewName, scale, viewportWidth, viewportHeight, viewportDepth, viewType,
strViewType, viewDir, upVector, lowerLeftPt, upperRightPt, cubeSolid);
}
catch (Exception ex)
{
ed.WriteMessage("\n❌ Error: " + ex.Message);
}
}
Thank you very much for your support!