public static PartsList AddPartsList(this Sheet sheet, object viewOrModel, PartsListLevelEnum level) { if (sheet == null) { throw new ArgumentNullException(nameof(sheet)); } if (viewOrModel == null) { throw new ArgumentNullException(nameof(viewOrModel)); } var partsList = sheet.PartsLists.Add( ViewOrModel: viewOrModel, PlacementPoint: sheet.TopRightCorner(), Level: level, NumberingScheme: Type.Missing, NumberOfSections: 1, WrapLeft: true ); partsList.ShowTitle = false; //MessageBox.Show(GetColumnIds(partsList)); partsList.ClearColumnsExcept( new Dictionary <string, int> { { "{32853F0F-3444-11D1-9E93-0060B03C1CA6}", 5 }, // "PART NUMBER" //{ "{32853F0F-3444-11D1-9E93-0060B03C1CA6}", 29 } // "DESCRIPTION" }, PropertyTypeEnum.kItemPartsListProperty, PropertyTypeEnum.kQuantityPartsListProperty ); partsList.AddCustomPropertyColumn("Lengte"); partsList.AddCustomPropertyColumn("Breedte"); partsList.AddCustomPropertyColumn("Dikte"); partsList.SetColumnValuesHorizontalJustification(HorizontalTextAlignmentEnum.kAlignTextCenter); return(partsList); }
public static PartsList AddPartsList(this Sheet sheet, object viewOrModel, PartsListLevelEnum level) { if (sheet == null) throw new ArgumentNullException(nameof(sheet)); if (viewOrModel == null) throw new ArgumentNullException(nameof(viewOrModel)); var partsList = sheet.PartsLists.Add( ViewOrModel: viewOrModel, PlacementPoint: sheet.TopRightCorner(), Level: level, NumberingScheme: Type.Missing, NumberOfSections: 1, WrapLeft: true ); partsList.ShowTitle = false; //MessageBox.Show(GetColumnIds(partsList)); partsList.ClearColumnsExcept( new Dictionary<string, int> { { "{32853F0F-3444-11D1-9E93-0060B03C1CA6}", 5 }, // "PART NUMBER" //{ "{32853F0F-3444-11D1-9E93-0060B03C1CA6}", 29 } // "DESCRIPTION" }, PropertyTypeEnum.kItemPartsListProperty, PropertyTypeEnum.kQuantityPartsListProperty ); partsList.AddCustomPropertyColumn("Lengte"); partsList.AddCustomPropertyColumn("Breedte"); partsList.AddCustomPropertyColumn("Dikte"); partsList.SetColumnValuesHorizontalJustification(HorizontalTextAlignmentEnum.kAlignTextCenter); return partsList; }
/// <summary> /// creation of a balloon. Select a linear drawing curve and run the sample /// </summary> /// <remarks></remarks> public void CreateBalloon() { // Set a reference to the drawing document. // This assumes a drawing document is active. DrawingDocument oDrawDoc = (DrawingDocument)_InvApplication.ActiveDocument; // Set a reference to the active sheet. Sheet oActiveSheet = oDrawDoc.ActiveSheet; // Set a reference to the drawing curve segment. // This assumes that a drwaing curve is selected. DrawingCurveSegment oDrawingCurveSegment = oDrawDoc.SelectSet[1]; // Set a reference to the drawing curve. DrawingCurve oDrawingCurve = oDrawingCurveSegment.Parent; // Get the mid point of the selected curve // assuming that the selection curve is linear Point2d oMidPoint = oDrawingCurve.MidPoint; // Set a reference to the TransientGeometry object. TransientGeometry oTG = _InvApplication.TransientGeometry; ObjectCollection oLeaderPoints = _InvApplication.TransientObjects.CreateObjectCollection(); // Create a couple of leader points. oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 10)); oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 5)); // Add the GeometryIntent to the leader points collection. // This is the geometry that the balloon will attach to. GeometryIntent oGeometryIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve); oLeaderPoints.Add(oGeometryIntent); // Set a reference to the parent drawing view of the selected curve DrawingView oDrawingView = oDrawingCurve.Parent; // Set a reference to the referenced model document Document oModelDoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument; // Check if a partslist or a balloon has already been created for this model bool IsDrawingBOMDefined = false; IsDrawingBOMDefined = oDrawDoc.DrawingBOMs.IsDrawingBOMDefined(oModelDoc.FullFileName); Balloon oBalloon = null; if (IsDrawingBOMDefined) { // Just create the balloon with the leader points // All other arguments can be ignored oBalloon = oDrawDoc.ActiveSheet.Balloons.Add(oLeaderPoints); } else { // First check if the 'structured' BOM view has been enabled in the model // Set a reference to the model's BOM object AssemblyDocument oAssDoc = (AssemblyDocument)oModelDoc; AssemblyComponentDefinition oComDef = oAssDoc.ComponentDefinition; BOM oBOM = oComDef.BOM; if (oBOM.StructuredViewEnabled) { // Level needs to be specified // Numbering options have already been defined // Get the Level ('All levels' or 'First level only') // from the model BOM view - must use the same here PartsListLevelEnum Level = default(PartsListLevelEnum); if (oBOM.StructuredViewFirstLevelOnly) { Level = PartsListLevelEnum.kStructured; } else { Level = PartsListLevelEnum.kStructuredAllLevels; } // Create the balloon by specifying just the level oBalloon = oActiveSheet.Balloons.Add(oLeaderPoints, null, Level); } else { // Level and numbering options must be specified // The corresponding model BOM view will automatically be enabled NameValueMap oNumberingScheme = _InvApplication.TransientObjects.CreateNameValueMap(); // Add the option for a comma delimiter oNumberingScheme.Add("Delimiter", ","); // Create the balloon by specifying the level and numbering scheme oBalloon = oActiveSheet.Balloons.Add(oLeaderPoints, null, PartsListLevelEnum.kStructuredAllLevels, oNumberingScheme); } } }