public override void AddViews( Part part, int quantity, DrawingDocument drawingDocument, DrawingViewStyle viewStyle, double scale, double perspectiveScale ) { Part = part ?? throw new ArgumentNullException(nameof(part)); DrawingDocument = drawingDocument ?? throw new ArgumentNullException(nameof(drawingDocument)); if (viewStyle == null) { throw new ArgumentNullException(nameof(viewStyle)); } var baseViewPosition = DrawingDocument.ActiveSheet.CenterPoint(); AddFlatPatternBaseView(viewStyle, scale, baseViewPosition); var partsList = AddPartsList(quantity); var perspectiveView = AddPerspectiveView(viewStyle, perspectiveScale); if (partsList != null) { perspectiveView.Position = AddIn.CreatePoint2D( x: perspectiveView.Position.X, y: perspectiveView.Position.Y - partsList.RangeBox.Height() ); } // Next operation not necessary for GenerateSheetMetalDrawingsBehaviorType.BaseViewWithLeftThenThreeTopProjectedViews AddTopView(viewStyle, perspectiveScale); }
public override void AddViews( Part part, int quantity, DrawingDocument drawingDocument, DrawingViewStyle viewStyle, double scale, double perspectiveScale ) { Part = part ?? throw new ArgumentNullException(nameof(part)); DrawingDocument = drawingDocument ?? throw new ArgumentNullException(nameof(drawingDocument)); if (viewStyle == null) { throw new ArgumentNullException(nameof(viewStyle)); } var centerPoint = DrawingDocument.ActiveSheet.CenterPoint(); var baseViewPosition = AddIn.CreatePoint2D(x: centerPoint.X * 1.5, y: centerPoint.Y * 0.5); var baseView = AddFlatPatternBaseView(viewStyle, scale, baseViewPosition); baseView.AddLeftThenTopProjectedViews( numberOfTopViews: 3, addDimensions: false, drawingDistance: 5 ); var partsList = AddPartsList(quantity); var perspectiveView = AddPerspectiveView(viewStyle, perspectiveScale); if (partsList != null) { perspectiveView.Position = AddIn.CreatePoint2D( x: perspectiveView.Position.X, y: perspectiveView.Position.Y - partsList.RangeBox.Height() ); } }
protected DrawingView AddTopView(DrawingViewStyle viewStyle, double scale) { if (viewStyle == null) { throw new ArgumentNullException(nameof(viewStyle)); } if (DrawingDocument == null || Part == null) { return(null); } // TODO Add this view below the 'ISO Top Right' view: Implement extension method // 'BottomRightCorner()', and use that instead of BottomLeftCorner(). var sheet = DrawingDocument.ActiveSheet; var margin = sheet.Margin(); var topView = sheet.DrawingViews.AddBaseView( Model: (_Document)Part.Document, Position: DrawingDocument.ActiveSheet.BottomLeftCorner(), Scale: scale, ViewOrientation: ViewOrientationTypeEnum.kTopViewOrientation, ViewStyle: viewStyle.EnumValue, ModelViewName: string.Empty, ArbitraryCamera: System.Type.Missing, AdditionalOptions: System.Type.Missing ); topView.Position = AddIn.CreatePoint2D( x: margin.Left + topView.Width + 1, y: margin.Bottom + topView.Height + 1 ); return(topView); }
protected override void GenerateDrawings() { if (Subassemblies == null) { return; } var selectedSubassemblies = Subassemblies.Where(x => x.IsSelected == true).ToList(); if (selectedSubassemblies.Count == 0) { ShowWarningMessageBox("No subassemblies are selected."); return; } foreach (var assembly in selectedSubassemblies) { var drawingDocument = CreateDrawingDocument(); var sheet = drawingDocument.ActiveSheet; var topRightCorner = sheet.TopRightCorner(); try { // 1. Alter formatting of custom properties. SetCustomPropertyFormat(assembly.Parts); // 2. Add base view. var baseView = sheet.DrawingViews.AddBaseView( Model: (_Document)assembly.Document, Position: drawingDocument.ActiveSheet.CenterPoint(), Scale: Scale, ViewOrientation: ViewOrientationTypeEnum.kFrontViewOrientation, ViewStyle: SelectedViewStyle.EnumValue, ModelViewName: string.Empty, ArbitraryCamera: Type.Missing, AdditionalOptions: Type.Missing ); baseView.AddTopAndLeftProjectedViews( addDimensions: true, drawingDistance: 0.5 ); baseView.AddPartName( partName: baseView.ReferencedDocumentDescriptor.DisplayName.RemoveExtension(), drawingDistance: 0.5 ); // 3. Add part list to the top right corner. var partsList = sheet.AddPartsList(assembly.Document, PartsListLevelEnum.kStructured); // 4. Add base "ISO TOP Right", Hidden line removed, Shaded base view of the subassembly // in the drawing's top right corner. var perspectiveView = sheet.DrawingViews.AddBaseView( Model: (_Document)assembly.Document, Position: drawingDocument.ActiveSheet.TopRightPoint(), Scale: PerspectiveScale, ViewOrientation: ViewOrientationTypeEnum.kIsoTopRightViewOrientation, ViewStyle: SelectedViewStyle.EnumValue, ModelViewName: string.Empty, ArbitraryCamera: Type.Missing, AdditionalOptions: Type.Missing ); perspectiveView.FitToTopRightCorner(sheet); perspectiveView.Position = AddIn.CreatePoint2D( x: perspectiveView.Position.X, y: perspectiveView.Position.Y - partsList.RangeBox.Height() ); } catch (Exception ex) { ShowWarningMessageBox(ex.ToString()); } } }
protected override void GenerateDrawings() { if (Parts == null) { return; } var selectedParts = Parts.Where(x => x.IsSelected == true).ToList(); if (selectedParts.Count == 0) { ShowWarningMessageBox("No sheet metal parts are selected."); return; } var bom = Assembly.ComponentDefinition.BOM; if (bom != null && bom.RequiresUpdate) { AddIn.ShowWarningMessageBox( Title, "The BOM of assembly '{0}' requires an update.{1}Quantities displayed in the generated drawings might be incorrect.", Assembly.DisplayName, System.Environment.NewLine + System.Environment.NewLine ); } foreach (var part in selectedParts) { var drawingDocument = CreateDrawingDocument(); var dimensionStyle = drawingDocument.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.LinearDimensionStyle; var sheet = drawingDocument.ActiveSheet; var topRightCorner = sheet.TopRightCorner(); try { // 1. Alter formatting of custom properties. SetCustomPropertyFormat(part); // 2. Add flat pattern base view. var flatPatternView = sheet.DrawingViews.AddBaseView( Model: (_Document)part.Document, Position: drawingDocument.ActiveSheet.CenterPoint(), Scale: Scale, ViewOrientation: ViewOrientationTypeEnum.kDefaultViewOrientation, ViewStyle: DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, ModelViewName: string.Empty, ArbitraryCamera: Type.Missing, AdditionalOptions: AddIn.CreateNameValueMap("SheetMetalFoldedModel", false) ); flatPatternView.AddHorizontalBendLineDimensionSet(dimensionStyle); flatPatternView.AddVerticalBendLineDimensionSet(dimensionStyle); if (flatPatternView.VerticalLines().Any(x => x.IsBendLine())) { flatPatternView.AddHorizontalDimension(dimensionStyle, drawingDistance: 2.0); } if (flatPatternView.HorizontalLines().Any(x => x.IsBendLine())) { flatPatternView.AddVerticalDimension(dimensionStyle, drawingDistance: 2.0); } // 3. Add part list to the top right corner. var partsList = sheet.AddPartsList(part.Document, PartsListLevelEnum.kPartsOnly); var quantity = Assembly.GetPartQuantity(part.Document); if (quantity > 0) { partsList.PartsListRows[1]["QTY"].Value = quantity.ToString(); } // 4. Add base "ISO Top Right", hidden line removed, shaded base view of the part in the drawing's top right corner. var perspectiveView = sheet.DrawingViews.AddBaseView( Model: (_Document)part.Document, Position: drawingDocument.ActiveSheet.TopRightPoint(), Scale: 0.1, ViewOrientation: ViewOrientationTypeEnum.kIsoTopRightViewOrientation, ViewStyle: DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, ModelViewName: string.Empty, ArbitraryCamera: Type.Missing, AdditionalOptions: Type.Missing ); var margin = sheet.Margin(); perspectiveView.Fit( new Rectangle( AddIn.CreatePoint2D( ((sheet.Width - margin.Right) * 3 + margin.Left) / 4 + 1, ((sheet.Height - margin.Top) * 3 + margin.Bottom) / 4 + 1 ), AddIn.CreatePoint2D( topRightCorner.X - 1, topRightCorner.Y - 1 ) ) ); perspectiveView.Position = AddIn.CreatePoint2D( perspectiveView.Position.X, perspectiveView.Position.Y - partsList.RangeBox.Height() ); // 5. TODO Add 'Top View' below the 'ISO Top Right' view. // TODO Implement extension method 'BottomRightPoint'. var topView = sheet.DrawingViews.AddBaseView( Model: (_Document)part.Document, Position: drawingDocument.ActiveSheet.BottomLeftCorner(), Scale: 0.1, ViewOrientation: ViewOrientationTypeEnum.kTopViewOrientation, ViewStyle: DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, ModelViewName: string.Empty, ArbitraryCamera: Type.Missing, AdditionalOptions: Type.Missing ); topView.Position = AddIn.CreatePoint2D( margin.Left + topView.Width + 1, margin.Bottom + topView.Height + 1 ); } catch (Exception ex) { ShowWarningMessageBox(ex.ToString()); } } }