internal static void AddPartsList(SheetParameters parameters, Sheet sheet) { sheet.Activate(); if (parameters.Model.DocumentType != DocumentTypeEnum.kAssemblyDocumentObject) { return; } var x = 2.0; var y = parameters.SheetFormat.Name == "А4" ? 4.5 : 0.5; var oPlacementPoint = CAddIn.App.TransientGeometry.CreatePoint2d(x, y); PartsList oPartsList; try { oPartsList = sheet.PartsLists.Add( ViewOrModel: parameters.Model, PlacementPoint: oPlacementPoint, Level: PartsListLevelEnum.kStructuredAllLevels, NumberingScheme: null, WrapLeft: false); } catch { oPartsList = sheet.PartsLists.Add( ViewOrModel: parameters.Model, PlacementPoint: oPlacementPoint, Level: PartsListLevelEnum.kPartsOnly, NumberingScheme: null, WrapLeft: false); } var vSize = oPartsList.RangeBox.MaxPoint.Y - oPartsList.RangeBox.MinPoint.Y; oPartsList.Position = CAddIn.App.TransientGeometry.CreatePoint2d(x, y + vSize); }
private void AddSheetMetaData(Sheet sheet) { if (sheet.TitleBlock != null) { sheet.TitleBlock.Delete(); } if (sheet.Border != null) { sheet.Border.Delete(); } TitleBlockDefinition tempTitleBlockDef = GetTitleBlock(); TitleBlockLocationEnum titleBlockLocation = GetTitleBlockLocation(); string[] promptStrings = new string[] { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }; TitleBlock titleBlockForCreatedSheet = sheet.AddTitleBlock(tempTitleBlockDef, titleBlockLocation, promptStrings); if (SelectedBorder.Equals("Default Border")) { sheet.AddDefaultBorder(); } else { sheet.AddBorder(BorderDefinition: GetBorderDefinition(SelectedBorder)); } sheet.ExcludeFromCount = ExcludeFromCount; sheet.ExcludeFromPrinting = ExcludeFromPrinting; sheet.Name = SheetName; sheet.Orientation = this.GetPageOrientation(); if (drawDoc.ActiveSheet != sheet) { sheet.Activate(); } }
public void Activate() => _sheet.Activate();
private void InternalGenerateDrawings(string templateDrawingPath, string masterDrawingPath) { PersistenceManager.InventorApplication.Visible = false; if (_testMode) { if (ModulesList.Count < 3) { for (int i = 0; i < ModulesList.Count; i++) { ModulesList[i].GenerateDrawings(templateDrawingPath); } } else { for (int i = 0; i < 3; i++) { ModulesList[i].GenerateDrawings(templateDrawingPath); } } } else { for (int i = 0; i < ModulesList.Count; i++) { ModulesList[i].GenerateDrawings(templateDrawingPath); } } if (masterDrawingPath != null && masterDrawingPath != "" && System.IO.File.Exists(masterDrawingPath)) { //TODO: test extension is .idw DrawingDocument masterDrawing = (DrawingDocument)PersistenceManager.InventorApplication.Documents.Open(masterDrawingPath, true); for (int p = 0; p < UniqueModules.DetailDocumentPaths.Count; p++) { //Get quantity of this module. //TODO: Look at changing this. It feels brittle. int moduleQuantity = UniqueModules.InstanceGeometryMap.Where(q => q.Item2 == p).Count(); DrawingDocument moduleDoc = (DrawingDocument)PersistenceManager.InventorApplication.Documents.Open(UniqueModules.DetailDocumentPaths[p], true); //Iterate through the collection in case the template detail contains many sheets. Sheets detailSheets = moduleDoc.Sheets; for (int q = 0; q < detailSheets.Count; q++) { Sheet currentSheet = detailSheets[q + 1]; currentSheet.Activate(); DrawingNotes notes = currentSheet.DrawingNotes; foreach (DrawingNote note in notes) { //This is an idea. Having 'template tags' available to the user that lets them place comments in drawing templates that Dynamo can //swap out for the desired instance value. if (note.Text == "<DynamoUnitNumber>") { int unitNumber = p + 1; string moduleLabelNote = String.Format("<StyleOverride FontSize='.6096'>ITEM: {0}</StyleOverride>", unitNumber.ToString()); note.FormattedText = moduleLabelNote; } if (note.Text == "<DynamoModuleQuantity>") { string moduleCountNote = String.Format("<StyleOverride FontSize='.6096'>QUANTITY: {0}</StyleOverride>", moduleQuantity.ToString()); note.FormattedText = moduleCountNote; } } currentSheet.CopyTo(masterDrawing as _DrawingDocument); } moduleDoc.Close(true); } masterDrawing.Save2(); masterDrawing.Close(true); } PersistenceManager.InventorApplication.Visible = true; }