Exemple #1
0
        /// <summary>
        /// Створює елементи вектору з данними виносу.
        /// </summary>
        private void CreateDrawingStakeOut()
        {
            if (this.PointStation == null)
            {
                return;
            }

            AcGe.Point3d pntStart = new AcGe.Point3d(this.PointStation.E, this.PointStation.N, this.PointStation.H);
            AcGe.Point3d pntEnd   = new AcGe.Point3d(this.Coordinates.X, this.Coordinates.Y, 0);

            AcDb.Line line = new AcDb.Line(pntStart, pntEnd);
            line.Visible = this.Visible;

            AcGe.Point3d pntMiddle = new AcGe.LineSegment3d(pntStart, pntEnd).MidPoint;

            double angleTXT = line.Angle;

            if (angleTXT > Math.PI / 2 && angleTXT < Math.PI * 3 / 2)
            {
                angleTXT += Math.PI;
            }

            AcDb.MText text = new AcDb.MText();
            text.Contents = this.DistanceToString(AcRx.DistanceUnitFormat.Decimal) + "\r\n"
                            + "л.к. " + ServiceTable.FormatAngleValue(this.LeftlAngleToString(AcRx.AngularUnitFormat.DegreesMinutesSeconds));
            text.Rotation   = angleTXT;
            text.Location   = pntMiddle;
            text.Attachment = AcDb.AttachmentPoint.MiddleCenter;
            text.Width      = 25;
            text.TextHeight = 1.8 * this.ScaleDrawing;


            this.lineID = ServiceCAD.InsertObject(line);
            this.txtID  = ServiceCAD.InsertObject(text);
        }
Exemple #2
0
        private void insertLine(_Ge.Point3d ptPos, double dir, double rotation)
        {
            _Db.BlockTableRecord btr = _c.trans.GetObject(_c.modelSpace.Id, _Db.OpenMode.ForWrite) as _Db.BlockTableRecord;

            _Ge.Point3d ptEnd = new _Ge.Point3d();

            if (rotation == 0.0)
            {
                double newX = ptPos.X - (bigCircleOffset - bigCircleRadius) * dir;
                double newY = ptPos.Y;
                ptEnd = new _Ge.Point3d(newX, newY, ptPos.Z);
            }
            else
            {
                double newX = ptPos.X;
                double newY = ptPos.Y - (bigCircleOffset - bigCircleRadius) * dir;
                ptEnd = new _Ge.Point3d(newX, newY, ptPos.Z);
            }

            using (_Db.Line line = new _Db.Line(ptPos, ptEnd))
            {
                btr.AppendEntity(line);
                _c.trans.AddNewlyCreatedDBObject(line, true);
            }
        }
Exemple #3
0
        public void DisplayAlongLine(AcGe.Point3d directionPoint, double offset, double step)
        {
            AcDb.Line line   = new AcDb.Line(this.BasePointArrays, directionPoint);
            double    length = offset;

            while (line.Length > length)
            {
                ServiceBlockElements.InsertBlock(this.NameBlock, line.GetPointAtDist(length), this.ScaleBlock, this.RotationBlock);
                length += step;
            }
        }
        public void TestTrans()
        {
            try
            {
                //System.Windows.Forms.MessageBox.Show(string.Format(CultureInfo.InvariantCulture, "_test = {0}", _test));
                //_test = 0;



                _AcDb.Database           db      = _AcAp.Application.DocumentManager.MdiActiveDocument.Database;
                _AcDb.TransactionManager dbTrans = db.TransactionManager;
                using (_AcDb.Transaction trans = dbTrans.StartTransaction())
                {
                    // create a line
                    _AcDb.Line       ln = new _AcDb.Line(new _AcGe.Point3d(0.0, 0.0, 0.0), new _AcGe.Point3d(1.0, 1.0, 0.0));
                    _AcDb.BlockTable bt = dbTrans.GetObject(db.BlockTableId, _AcDb.OpenMode.ForRead, false) as _AcDb.BlockTable;
                    if (bt == null)
                    {
                        return;
                    }
                    //ObjectId id = bt[BlockTableRecord.ModelSpace];
                    _AcDb.BlockTableRecord btr = dbTrans.GetObject(bt[_AcDb.BlockTableRecord.ModelSpace], _AcDb.OpenMode.ForWrite, false) as _AcDb.BlockTableRecord;
                    if (btr == null)
                    {
                        return;
                    }
                    //Add it to the model space block table record.
                    btr.AppendEntity(ln);
                    //Make sure that the transaction knows about this new object.    tm.AddNewlyCreatedDBObject(line, True)
                    dbTrans.AddNewlyCreatedDBObject(ln, true);


                    //'Add some hyperlinks.    Dim hyper As New HyperLink()    hyper.Name = "www.autodesk.com"    line.Hyperlinks.Add(hyper)
                    _AcDb.HyperLink hyper = new _AcDb.HyperLink();
                    hyper.Name = "www.facebook.com";
                    ln.Hyperlinks.Add(hyper);
                    if (ln.Hyperlinks.Contains(hyper))
                    {
                        hyper.Name = "www.gotdotnet.com";
                    }
                    ln.Hyperlinks.Add(hyper);
                    foreach (var hl in ln.Hyperlinks)
                    {
                        System.Diagnostics.Debug.WriteLine(hl.ToString());
                    }
                    trans.Commit();
                }
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
Exemple #5
0
        private void AddLengthLine()
        {
            //AcDb.DBText oText;
            AcDb.MText oMText;

            AcDb.Line     lineCur = null;
            AcDb.ObjectId idLineCur;

            AcGe.Point2d startPoint = this.Parcel.Points.ToArray()[this.Parcel.Points.Count - 1];
            AcGe.Point3d midPoint;

            foreach (AcGe.Point2d endPoint in this.Parcel.Points)
            {
                midPoint = new AcGe.Point3d((endPoint.X + startPoint.X) / 2, (endPoint.Y + startPoint.Y) / 2, 0);



                lineCur = new AcDb.Line(new AcGe.Point3d(startPoint.X, startPoint.Y, 0),
                                        new AcGe.Point3d(endPoint.X, endPoint.Y, 0));

                lineCur.ColorIndex = 222;
                lineCur.LineWeight = AcDb.LineWeight.LineWeight030;
                idLineCur          = ServiceCAD.InsertObject(lineCur);

                ServiceCAD.ZoomCenter(midPoint, 1);

                /*
                 * oText = new AcDb.DBText();
                 * oText.Height = 2 * this.SettingsForm.ScaleDrawing;
                 * oText.TextString = startPoint.GetDistanceTo(endPoint).ToString("0.00").Replace(",",".");
                 * //oText.Layer = settingsDrawing.Plan.LengthLine.Layer;
                 *
                 * ServiceCAD.ManualInsertText(oText);
                 */

                oMText            = new AcDb.MText();
                oMText.TextHeight = 2 * this.SettingsForm.ScaleDrawing;
                oMText.Attachment = AcDb.AttachmentPoint.MiddleCenter;
                //oMText.Layer = settingsDrawing.Plan.LengthLine.Layer;

                oMText.Contents = startPoint.GetDistanceTo(endPoint).ToString("0.00").Replace(",", ".");

                ServiceCAD.ZoomCenter(midPoint, 1);
                ServiceSimpleElements.ManualInsertMText(oMText);
                ServiceCAD.DeleteObject(idLineCur);

                startPoint = endPoint;
            }
        }
Exemple #6
0
        private List <_Ge.Point3d> getLinePoints(_Db.Line line)
        {
            List <_Ge.Point3d> points = new List <_Ge.Point3d>();

            _Ge.Point3d start = line.StartPoint;
            _Ge.Point3d end   = line.EndPoint;

            double midX = start.X + ((end.X - start.X) / 2);
            double midY = start.Y + ((end.Y - start.Y) / 2);

            _Ge.Point3d mid = new _Ge.Point3d(midX, midY, 0);

            points.Add(start);
            points.Add(end);
            points.Add(mid);

            return(points);
        }
Exemple #7
0
        public static void Zoom(AcGe.Point3d pMin, AcGe.Point3d pMax, AcGe.Point3d pCenter, double dFactor)
        {
            int nCurVport = System.Convert.ToInt32(AcApp.GetSystemVariable("CVPORT"));

            if (db.TileMode == true)
            {
                if (pMin.Equals(new AcGe.Point3d()) == true &&
                    pMax.Equals(new AcGe.Point3d()) == true)
                {
                    pMin = db.Extmin;
                    pMax = db.Extmax;
                }
            }
            else
            {
                // Check to see if Paper space is current
                if (nCurVport == 1)
                {
                    // Get the extents of Paper space
                    if (pMin.Equals(new AcGe.Point3d()) == true &&
                        pMax.Equals(new AcGe.Point3d()) == true)
                    {
                        pMin = db.Pextmin;
                        pMax = db.Pextmax;
                    }
                }
                else
                {
                    // Get the extents of Model space
                    if (pMin.Equals(new AcGe.Point3d()) == true &&
                        pMax.Equals(new AcGe.Point3d()) == true)
                    {
                        pMin = db.Extmin;
                        pMax = db.Extmax;
                    }
                }
            }

            using (AcDb.Transaction acTrans = db.TransactionManager.StartTransaction())
            {
                using (AcDb.ViewTableRecord acView = ed.GetCurrentView())
                {
                    AcDb.Extents3d eExtents;

                    AcGe.Matrix3d matWCS2DCS;
                    matWCS2DCS = AcGe.Matrix3d.PlaneToWorld(acView.ViewDirection);
                    matWCS2DCS = AcGe.Matrix3d.Displacement(acView.Target - AcGe.Point3d.Origin) * matWCS2DCS;
                    matWCS2DCS = AcGe.Matrix3d.Rotation(-acView.ViewTwist,
                                                        acView.ViewDirection,
                                                        acView.Target) * matWCS2DCS;

                    if (pCenter.DistanceTo(AcGe.Point3d.Origin) != 0)
                    {
                        pMin = new AcGe.Point3d(pCenter.X - (acView.Width / 2),
                                                pCenter.Y - (acView.Height / 2), 0);

                        pMax = new AcGe.Point3d((acView.Width / 2) + pCenter.X,
                                                (acView.Height / 2) + pCenter.Y, 0);
                    }

                    using (AcDb.Line acLine = new AcDb.Line(pMin, pMax))
                    {
                        eExtents = new AcDb.Extents3d(acLine.Bounds.Value.MinPoint,
                                                      acLine.Bounds.Value.MaxPoint);
                    }

                    double dViewRatio;
                    dViewRatio = (acView.Width / acView.Height);

                    matWCS2DCS = matWCS2DCS.Inverse();
                    eExtents.TransformBy(matWCS2DCS);

                    double       dWidth;
                    double       dHeight;
                    AcGe.Point2d pNewCentPt;

                    if (pCenter.DistanceTo(AcGe.Point3d.Origin) != 0)
                    {
                        dWidth  = acView.Width;
                        dHeight = acView.Height;

                        if (dFactor == 0)
                        {
                            pCenter = pCenter.TransformBy(matWCS2DCS);
                        }

                        pNewCentPt = new AcGe.Point2d(pCenter.X, pCenter.Y);
                    }
                    else
                    {
                        dWidth  = eExtents.MaxPoint.X - eExtents.MinPoint.X;
                        dHeight = eExtents.MaxPoint.Y - eExtents.MinPoint.Y;

                        pNewCentPt = new AcGe.Point2d(((eExtents.MaxPoint.X + eExtents.MinPoint.X) * 0.5),
                                                      ((eExtents.MaxPoint.Y + eExtents.MinPoint.Y) * 0.5));
                    }

                    if (dWidth > (dHeight * dViewRatio))
                    {
                        dHeight = dWidth / dViewRatio;
                    }

                    if (dFactor != 0)
                    {
                        acView.Height = dHeight * dFactor;
                        acView.Width  = dWidth * dFactor;
                    }
                    acView.CenterPoint = pNewCentPt;
                    ed.SetCurrentView(acView);
                }
                acTrans.Commit();
            }
        }
Exemple #8
0
        private void AddNeighbors()
        {
            this.allTextNeighbors.Clear();

            Dictionary <string, string> tags = new Dictionary <string, string>();

            this.currentLetterNeighbor = -1;
            TextNeighbors textNeighbors;

            foreach (NeighborsAlongContour contour in this.Parcel.ContoursNeighbors)
            {
                textNeighbors = new TextNeighbors(this.currentLetterNeighbor);

                foreach (LandPolygon neighbor in contour.Neighbors)
                {
                    textNeighbors.addText(neighbor.FindInfo("NM").Value.Replace("|", " | "));

                    if (SettingsForm.DisplayFillNeighbors)
                    {
                        AcGe.Point2d[] points = neighbor.Points.ToArray();

                        AcGe.Point2d bPnt;
                        AcGe.Point2d mPnt;
                        AcGe.Point2d fPnt;

                        AcGe.Point3d directionPoint;

                        if (
                            contour.Neighbors.Count > 1 ||
                            this.Parcel.ContoursNeighbors.Count == 1
                            )
                        {
                            bPnt = points[0];
                            mPnt = points[1];
                            fPnt = points[2];

                            directionPoint = new AcGe.Point3d(bPnt.X, bPnt.Y, 0.0);
                        }
                        else
                        {
                            bPnt = points[points.Length - 1];
                            mPnt = points[0];
                            fPnt = points[1];

                            //if (this.Parcel.ContoursNeighbors.Count == 1)
                            {
                                double angLeft  = ServiceGeodesy.GetLeftAngle(fPnt, mPnt, bPnt);
                                double dirFront = ServiceGeodesy.GetDirAngle(mPnt, fPnt);

                                double dirBisector = dirFront + angLeft / 2;
                                if (dirBisector >= Math.PI * 2)
                                {
                                    dirBisector -= Math.PI * 2;
                                }

                                directionPoint = new AcGe.Point3d
                                                 (
                                    mPnt.X + Math.Sin(dirBisector),
                                    mPnt.Y + Math.Cos(dirBisector),
                                    0
                                                 );
                            }
                        }

                        AcGe.Point3d insertPoint = new AcGe.Point3d(mPnt.X, mPnt.Y, 0.0);

                        AcDb.Line lineNeighbor = new AcDb.Line(insertPoint, directionPoint);

                        tags.Clear();

                        tags.Add("NEIGHBOR", textNeighbors.GetLastText().Key);
                        ServiceBlockElements.InsertBlock
                        (
                            settingsDrawing.Plan.Neighbors.NameBlock,
                            insertPoint,
                            this.SettingsForm.ScaleDrawing,
                            lineNeighbor.Angle,
                            tags
                        );
                    }
                }
                this.currentLetterNeighbor = textNeighbors.Count - 1;
                this.allTextNeighbors.Add(textNeighbors);
            }
        }
Exemple #9
0
        /// <summary>
        /// Створює коллекцію текстових обектів значень данних таблиці обмежень земельної ділянки.
        /// </summary>
        /// <param name="parcel">Ділянка, що є вихідною для таблиці.</param>
        /// <param name="settingTable">Налаштування таблиці.</param>
        /// <returns>
        ///  Повертає <see cref="T:AcDb.DBObjectCollection"/>, що містить текстові значення данний таблиці обмежень земельної ділянки.
        /// </returns>

        internal static AcDb.DBObjectCollection GetDataTableLimiting(LandParcel parcel, SettingTable settingTable)
        {
            AcDb.DBObjectCollection objects = new AcDb.DBObjectCollection();

            AcDb.MText   valueMText;
            AcGe.Point3d insertPoint;
            AcDb.Line    lineRows;

            LandPolygon polygonLimiting;

            double steepRow    = settingTable.TextHeight * 6;
            double heightTable = settingTable.GetHeightCapTable() * -1;

            List <HatchPolygon> listMissingHatch = new List <HatchPolygon>();

            for (int index = 0; index < parcel.Limiting.Count; index++)
            {
                polygonLimiting = parcel.Limiting.ToArray()[index];

                double colWidth = 0;

                if (index > 0)
                {
                    lineRows = new AcDb.Line(
                        new AcGe.Point3d(0, heightTable, 0),
                        new AcGe.Point3d(settingTable.GetWidthTable(), heightTable, 0));

                    objects.Add(lineRows);
                }

                heightTable -= steepRow;



                foreach (ColumnTable col in settingTable.Columns)
                {
                    colWidth += col.Width;

                    insertPoint = new AcGe.Point3d();
                    insertPoint = new AcGe.Point3d(colWidth - col.Width / 2, (heightTable + steepRow / 2), 0);

                    valueMText                   = new AcDb.MText();
                    valueMText.Width             = col.Width * 0.9;
                    valueMText.TextHeight        = settingTable.TextHeight;
                    valueMText.LineSpaceDistance = settingTable.TextHeight * 1.5;
                    valueMText.Attachment        = AcDb.AttachmentPoint.MiddleCenter;
                    valueMText.Location          = insertPoint;

                    if (col.Format.IndexOf("LegendLimiting") > -1)
                    {
                        AcGe.Point2dCollection pointsHatch = new AcGe.Point2dCollection(new AcGe.Point2d[]
                        {
                            new AcGe.Point2d(insertPoint.X - col.Width / 2 + 2, heightTable + steepRow - 2),
                            new AcGe.Point2d(insertPoint.X - col.Width / 2 + 2, heightTable + 2),
                            new AcGe.Point2d(insertPoint.X - col.Width / 2 + col.Width - 2, heightTable + 2),
                            new AcGe.Point2d(insertPoint.X - col.Width / 2 + col.Width - 2, heightTable + steepRow - 2)
                        });

                        AcDb.Polyline2d polylineLimiting = ServiceSimpleElements.CreatePolyline2d(pointsHatch, true);
                        AcDb.Hatch      hatch            =
                            ServiceSimpleElements.CreateHatch(ServiceCAD.InsertObject(polylineLimiting), true);

                        HatchPolygon hatchLimiting = HatchPolygon.GetHatchLimiting(polygonLimiting);

                        if (hatchLimiting != null)
                        {
                            hatch.ColorIndex = hatchLimiting.ColorIndex;
                            hatch.SetHatchPattern(AcDb.HatchPatternType.UserDefined, hatchLimiting.Pattern.Name);
                            hatch.PatternAngle = hatchLimiting.Pattern.Angle;
                            hatch.PatternSpace = hatchLimiting.Pattern.Space;
                        }
                        else
                        {
                            string type = polygonLimiting.FindInfo("OK").Value;
                            string name = polygonLimiting.FindInfo("OX").Value;
                            listMissingHatch.Add(new HatchPolygon(type, name, 0, PatternHatch.DEFAULT));
                        }

                        objects.Add(hatch);
                        polylineLimiting = ServiceSimpleElements.CreatePolyline2d(pointsHatch, true);
                        objects.Add(polylineLimiting);
                    }
                    else if (col.Format.IndexOf("CodeLimiting") > -1)
                    {
                        valueMText.Contents = polygonLimiting.FindInfo("OK").Value;
                        objects.Add(valueMText);
                    }
                    else if (col.Format.IndexOf("NameLimiting") > -1)
                    {
                        valueMText.Contents = polygonLimiting.FindInfo("OX").Value;
                        objects.Add(valueMText);
                    }
                    else if (col.Format.IndexOf("LegalActsLimiting") > -1)
                    {
                        valueMText.Contents = polygonLimiting.FindInfo("OD").Value;
                        objects.Add(valueMText);
                    }
                    else if (col.Format.IndexOf("AreaLimiting") > -1)
                    {
                        double area = Convert.ToDouble(polygonLimiting.FindInfo("AO").Value.Replace(".", ","));
                        valueMText.Contents = (area / 10000).ToString("0.0000").Replace(",", ".");;
                        objects.Add(valueMText);
                    }
                }
            }

            if (listMissingHatch.Count > 0)
            {
                CurrentCAD.Editor.WriteMessage("\n\nПобудова таблиці омеженнь\n Не визначено штриховку: \n");
                CurrentCAD.Editor.WriteMessage(ServiceXml.GetStringXml <List <HatchPolygon> >(listMissingHatch));
            }

            return(objects);
        }
        protected override bool WorldDraw(AcGi.WorldDraw draw)
        {
            AcGi.WorldGeometry geo = draw.Geometry;
            if (geo != null)
            {
                geo.PushModelTransform(UCS);

                AcGe.Point3dCollection tempPts = new AcGe.Point3dCollection();
                foreach (AcGe.Point3d pt in allVertexes)
                {
                    tempPts.Add(pt);
                }
                if (lastVertex != null)
                {
                    if (tempPts.Count > 1)
                    {
                        AcDb.Line lastLine      = new AcDb.Line(allVertexes[allVertexes.Count - 2], allVertexes[allVertexes.Count - 1]);
                        double    offsetForward = ServiceGeodesy.GetProjectionOnLine(lastLine, lastVertex) - lastLine.Length;
                        double    offsetTowards = ServiceGeodesy.GetOffsetFromLine(lastLine, lastVertex);

                        AcDb.Xline xLine = new AcDb.Xline();
                        xLine.BasePoint = allVertexes[allVertexes.Count - 1];
                        xLine.UnitDir   = lastLine.Delta;

                        System.Windows.Forms.Keys mods = System.Windows.Forms.Control.ModifierKeys;
                        if ((mods & System.Windows.Forms.Keys.Control) > 0)
                        {
                            if (isMovingTowards)
                            {
                                lastVertex = xLine.GetPointAtDist(offsetForward);
                            }
                            else
                            {
                                xLine.TransformBy(AcGe.Matrix3d.Rotation(Math.PI / 2 * -1, AcGe.Vector3d.ZAxis, xLine.BasePoint));
                                lastVertex = xLine.GetPointAtParameter(offsetTowards);
                            }
                        }
                        else
                        {
                            if (Math.Abs(offsetForward) > Math.Abs(offsetTowards))
                            {
                                isMovingTowards = true;
                                lastVertex      = xLine.GetPointAtDist(offsetForward);
                            }
                            else
                            {
                                isMovingTowards = false;
                                xLine.TransformBy(AcGe.Matrix3d.Rotation(Math.PI / 2 * -1, AcGe.Vector3d.ZAxis, xLine.BasePoint));
                                lastVertex = xLine.GetPointAtParameter(offsetTowards);
                            }
                        }
                    }
                    tempPts.Add(lastVertex);
                }
                if (tempPts.Count > 0)
                {
                    geo.Polyline(tempPts, AcGe.Vector3d.ZAxis, IntPtr.Zero);
                }

                geo.PopModelTransform();
            }

            return(true);
        }
Exemple #11
0
 public static double GetProjectionOnLine(AcDb.Line line, AcGe.Point3d point)
 {
     return(GetProjectionOnLine(line.StartPoint, line.EndPoint, point));
 }
Exemple #12
0
 public static double GetOffsetFromLine(AcDb.Line line, AcGe.Point3d point)
 {
     return(GetOffsetFromLine(line.StartPoint, line.EndPoint, point));
 }