/// <summary> /// Create a new sheet with some default views according to the format type. /// </summary> /// <param name="name">The name for the sheet.</param> /// <param name="units">The measurement system type for the sheet.</param> /// <param name="formatType">The <see cref="formatType"/>.</param> /// <remarks> /// It builds the format block and it adds the created BlockReference to the Sheet and the block to the Drawings Blocks collection. /// </remarks> public void AddSheet(string name, linearUnitsType units, formatType formatType, bool addDefaultView = true) { Tuple <double, double> size = DrawingsPanel.GetFormatSize(units, formatType); Sheet sheet = new Sheet(units, size.Item1, size.Item2, name); Block block; BlockReference br = drawingsPanel1.CreateFormatBlock(formatType, sheet, out block); drawings1.Blocks.Add(block); sheet.Entities.Add(br); // not possible adding the entity to Drawings because the control handle is not created yet. it will be added when this sheet will be set as the active one. drawings1.Sheets.Add(sheet); // adds a set of default views. if (addDefaultView) { AddDefaultViews(sheet); } }
private void AddDefaultViews(Sheet sheet) { // this samples uses values in millimeters to add views and it uses this factor to get converted values. double unitsConversionFactor = Utility.GetLinearUnitsConversionFactor(linearUnitsType.Millimeters, sheet.Units); double scaleFactor = drawingsPanel1.GetScaleComboValue(); // adds Front vector view sheet.Entities.Add(new VectorView(70 * unitsConversionFactor, 230 * unitsConversionFactor, viewType.Top, scaleFactor, DrawingsPanel.GetViewName(sheet, viewType.Top))); // adds Trimetric raster view sheet.Entities.Add(new RasterView(150 * unitsConversionFactor, 230 * unitsConversionFactor, viewType.Trimetric, scaleFactor, DrawingsPanel.GetViewName(sheet, viewType.Trimetric, true))); // adds Top vector view sheet.Entities.Add(new VectorView(70 * unitsConversionFactor, 130 * unitsConversionFactor, viewType.Front, scaleFactor, DrawingsPanel.GetViewName(sheet, viewType.Front))); // adds Right vector view sheet.Entities.Add(new VectorView(150 * unitsConversionFactor, 130 * unitsConversionFactor, viewType.Right, scaleFactor, DrawingsPanel.GetViewName(sheet, viewType.Right))); }