Inventor has four kinds of primary documents, assembly (.IAM), part (.IPT), drawing (.IDW or .DWG) and presentation (.IPN). A drawing (.IDW/.DWG) document contains some views/sheets, sketch graphics, borders, title blocks, BOM tables, and other drawing/detailing specific stuffs. An assembly drawing (.IDW/.DWG generated from the assembly) can embed some part drawings (.IDW/.DWG). Each part (.IPT) can have its standalone drawing (.IDW/.DWG) file as well.
In this series of articles, we talk about Inventor Drawing and its various elements such as drawing sketch lines, circles, arcs, rectangles, polygons, splines, text boxes, images, regions, title blocks, borders, views, BOMs and so on.
In this particular article, we are going to add a Section View for the current part to the active sheet of a newly created drawing document.
public static List<DrawingView> CreateDrawingSectionView(DrawingDocument dwgDoc, Document doc)
List<DrawingView> views = new List<DrawingView>();
Sheet sheet = dwgDoc.Sheets.Add(DrawingSheetSizeEnum.kA0DrawingSheetSize, PageOrientationTypeEnum.kLandscapePageOrientation, "MainSheet");
DefaultBorder border = sheet.AddDefaultBorder();
TitleBlock titleBlk = sheet.AddTitleBlock(dwgDoc.TitleBlockDefinitions);
Point2d pos4 = AddinGlobal.InventorApp.TransientGeometry.CreatePoint2d(sheet.Width * 7 / 8, sheet.Height / 1.8);
DrawingView view4 = sheet.DrawingViews.AddBaseView((_Document)doc, pos4, 0.5, ViewOrientationTypeEnum.kIsoTopRightViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle);
DrawingSketch sketch = view4.Sketches.Add();
Point2d pt1 = AddinGlobal.InventorApp.TransientGeometry.CreatePoint2d(1, 1);
Point2d pt2 = AddinGlobal.InventorApp.TransientGeometry.CreatePoint2d(2, 2);
Point2d pos1 = AddinGlobal.InventorApp.TransientGeometry.CreatePoint2d(view4.Center.X + view4.Width / 2, view4.Center.Y + view4.Height);
SectionDrawingView view1 = sheet.DrawingViews.AddSectionView(
"Sample Section View",
views.Add(view1 as DrawingView);
After the environment is made ready and the test code is run, the Section View for the current document, either part or assembly such as the sample Flower.ipt, will be properly created into the active sheet of the new drawing.
The leading edge Inventor .NET Addin Wizard (InventorNetAddinWizard) can help create Inventor .NET addins in great convenience. It can be found and downloaded from the A Wizard for Inventor .NET Addin page.