public void PlotAxisLines(float xOffsetLeft = 0, float xOffsetRight = 0, float yOffsetBottom = 0, float yOffsetTop = 0, bool isRectangle = true, float lineWeight = 0.01f)
        {
            //построение обоих осей
            //xOffsetLeft - величина отступа от графика влево. по умолчанию стоит 0 (указаны через равно)
            //xOffsetRight -                            вправо
            //yOffsetBottom -                           вниз
            //yOffsetTop -                              вверх
            //isRectangle - сетка углом или прямоугольником. По умолчанию стоит прямоугольник
            //lineWeight - толщина линии осей

            this.leftBottom  = transGeom.CreatePoint2d(ToPlotCoordX(xMin), ToPlotCoordY(yMin));
            this.rightBottom = transGeom.CreatePoint2d(ToPlotCoordX(xMax), ToPlotCoordY(yMin));
            this.leftTop     = transGeom.CreatePoint2d(ToPlotCoordX(xMin), ToPlotCoordY(yMax));
            this.rightTop    = transGeom.CreatePoint2d(ToPlotCoordX(xMax), ToPlotCoordY(yMax));

            List <SketchLine> axisLines = new List <SketchLine>();

            Transaction plotTransaction = this.app.TransactionManager.StartTransaction(this.app.ActiveDocument, "Plotting");

            sketch.Edit();
            axisLines.Add(sketch.SketchLines.AddByTwoPoints(this.leftBottom, this.rightBottom));
            axisLines.Add(sketch.SketchLines.AddByTwoPoints(this.leftBottom, this.leftTop));

            if (isRectangle)
            {
                axisLines.Add(sketch.SketchLines.AddByTwoPoints(this.leftTop, this.rightTop));
                axisLines.Add(sketch.SketchLines.AddByTwoPoints(this.rightBottom, this.rightTop));
            }
            sketch.ExitEdit();

            foreach (SketchLine line in axisLines)
            {
                line.LineWeight = lineWeight;
            }
            plotTransaction.End();
        }
Exemple #2
0
        private static bool CreateCircle(DataRow iRow, Sheet iSheet, DrawingSketch iSketch, TransientGeometry tg)
        {
            bool isCircleCreated = false;

            try
            {
                int      circleInst = Int32.Parse(iRow.ItemArray[iRow.ItemArray.Count() - 1].ToString());
                int      startNum   = 0;
                string   tempCoord  = iRow.ItemArray[4].ToString();
                string[] coord      = tempCoord.Split(',');
                Double   initX      = Double.Parse(coord[0]);
                Double   initY      = Double.Parse(coord[1]);
                Double   hOffset    = Double.Parse(iRow.ItemArray[5].ToString());
                Double   vOffset    = Double.Parse(iRow.ItemArray[6].ToString());
                Double   radius     = Double.Parse(iRow.ItemArray[3].ToString()) / 2;
                do
                {
                    iSketch.Edit();
                    Point2d cen;
                    if (startNum < circleInst / 2)
                    {
                        cen = tg.CreatePoint2d(initX + (hOffset * startNum), initY);
                    }
                    else
                    {
                        cen = tg.CreatePoint2d(initX + (hOffset * (startNum - 4)), initY + vOffset);
                    }
                    SketchCircle   iCircle = iSketch.SketchCircles.AddByCenterRadius(cen, 2);
                    GeometryIntent oGeo1   = iSheet.CreateGeometryIntent(iCircle, null);
                    iSketch.ExitEdit();
                    iSheet.DrawingDimensions.GeneralDimensions.AddDiameter(cen, oGeo1, false, false, false);
                    isCircleCreated = true;
                    startNum       += 1;
                } while (startNum < circleInst);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(isCircleCreated);
        }
Exemple #3
0
        public void CreateSketch()
        {
            DrawingDocument oDoc = (DrawingDocument)_InvApplication.ActiveDocument;

            Sheet oSheet = default(Sheet);

            oSheet = oDoc.ActiveSheet;

            // Create the sketch.
            DrawingSketch oSketch = default(DrawingSketch);

            oSketch = oSheet.Sketches.Add();

            // Open the sketch for edit in the user interface.
            oSketch.Edit();

            oSketch.SketchCircles.AddByCenterRadius(_InvApplication.TransientGeometry.CreatePoint2d(8, 8), 2);

            // Exit edit.
            oSketch.ExitEdit();
        }
Exemple #4
0
        private static bool CreateRectangle(DataRow iRow, Sheet iSheet, DrawingSketch iSketch, TransientGeometry tg)
        {
            bool isRectangleCreated = false;

            try
            {
                string   tempCoord = iRow.ItemArray[4].ToString();
                string[] coord     = tempCoord.Split(',');
                Double   initX     = Double.Parse(coord[0]);
                Double   initY     = Double.Parse(coord[1]);
                Double   height    = Double.Parse(iRow.ItemArray[1].ToString());
                Double   width     = Double.Parse(iRow.ItemArray[2].ToString());
                iSketch.Edit();
                Point2d    pt1 = tg.CreatePoint2d(initX, initY);
                Point2d    pt2 = tg.CreatePoint2d(initX + width, initY);
                Point2d    pt3 = tg.CreatePoint2d(initX + width, initY + height);
                Point2d    pt4 = tg.CreatePoint2d(initX, initY + height);
                SketchLine l1  = iSketch.SketchLines.AddByTwoPoints(pt1, pt2);
                SketchLine l2  = iSketch.SketchLines.AddByTwoPoints(pt2, pt3);
                iSketch.SketchLines.AddByTwoPoints(pt3, pt4);
                iSketch.SketchLines.AddByTwoPoints(pt4, pt1);
                iSketch.ExitEdit();
                GeometryIntent         oGeo1  = iSheet.CreateGeometryIntent(l1, null);
                GeometryIntent         oGeo2  = iSheet.CreateGeometryIntent(l2, null);
                LinearGeneralDimension iDim   = iSheet.DrawingDimensions.GeneralDimensions.AddLinear(pt1, oGeo1);
                DimensionStyle         iStyle = iDim.Style;
                iStyle.PartOffset        = 45.0;
                iStyle.ShowDimensionLine = true;
                iSheet.DrawingDimensions.GeneralDimensions.AddLinear(pt2, oGeo2).Style = iStyle;
                isRectangleCreated = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(isRectangleCreated);
        }