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 an Auxiliary View for the current part to the active sheet of a newly created drawing document.
public static List<DrawingView> CreateDrawingAuxiliaryViewForPart(DrawingDocument dwgDoc, PartDocument partDoc)
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)partDoc, pos4, 1, ViewOrientationTypeEnum.kIsoTopRightViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle);
List<DrawingCurve> lines = (from DrawingCurve p in view4.DrawingCurves where p.CurveType == CurveTypeEnum.kLineSegmentCurve select p).ToList<DrawingCurve>();
DrawingCurve dc = lines;
Point2d pos1 = AddinGlobal.InventorApp.TransientGeometry.CreatePoint2d(sheet.Width * 5 / 8, sheet.Height / 1.5);
DrawingView view1 = sheet.DrawingViews.AddAuxiliaryView(
PartDocument partDoc = AddinGlobal.InventorApp.ActiveDocument as PartDocument;
DrawingDocument idwDoc = IDWCreation.CreateOrOpenIDW();
After the environment is made ready and the test code is run, the Auxiliary View for another view created from the current part document, e.g. the sample Vertical Plate.ipt, will be properly created into the active sheet of the new drawing.
As can be seen, the Auxiliary View has been successfully created into the active sheet of the new drawing from an isometric base view, which is also created on the fly. Of course, the parent view and the orientation edge object can be programmatically selected from the screen.
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.