Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        protected DrawingView AddPerspectiveView(DrawingViewStyle viewStyle, double scale)
        {
            if (viewStyle == null)
            {
                throw new ArgumentNullException(nameof(viewStyle));
            }

            if (DrawingDocument == null || Part == null)
            {
                return(null);
            }

            var sheet = DrawingDocument.ActiveSheet;

            // Add base "ISO Top Right" base view in the drawing's top right corner.
            var perspectiveView = sheet.DrawingViews.AddBaseView(
                Model: (_Document)Part.Document,
                Position: DrawingDocument.ActiveSheet.TopRightPoint(),
                Scale: scale,
                ViewOrientation: ViewOrientationTypeEnum.kIsoTopRightViewOrientation,
                ViewStyle: viewStyle.EnumValue,
                ModelViewName: string.Empty,
                ArbitraryCamera: System.Type.Missing,
                AdditionalOptions: System.Type.Missing
                );

            perspectiveView.FitToTopRightCorner(sheet);
            return(perspectiveView);
        }
Ejemplo n.º 3
0
 public abstract void AddViews(
     Part part,
     int quantity,
     DrawingDocument drawingDocument,
     DrawingViewStyle viewStyle,
     double scale,
     double perspectiveScale
     );
Ejemplo n.º 4
0
        protected DrawingView AddFlatPatternBaseView(
            DrawingViewStyle viewStyle,
            double scale,
            Point2d position
            )
        {
            if (viewStyle == null)
            {
                throw new ArgumentNullException(nameof(viewStyle));
            }

            if (position == null)
            {
                throw new ArgumentNullException(nameof(position));
            }

            if (DrawingDocument == null || Part == null)
            {
                return(null);
            }

            var dimensionStyle = DrawingDocument
                                 .StylesManager.ActiveStandardStyle.ActiveObjectDefaults.LinearDimensionStyle;

            var flatPatternView = DrawingDocument.ActiveSheet.DrawingViews.AddBaseView(
                Model: (_Document)Part.Document,
                Position: position,
                Scale: scale,
                ViewOrientation: ViewOrientationTypeEnum.kDefaultViewOrientation,
                ViewStyle: viewStyle.EnumValue,
                ModelViewName: string.Empty,
                ArbitraryCamera: System.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);
            }

            return(flatPatternView);
        }
Ejemplo n.º 5
0
        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()
                        );
            }
        }
Ejemplo n.º 6
0
        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);
        }