Exemple #1
0
        public void CheckPolyRpoints()
        {
            TypedValue[] types = new TypedValue[]
            {
                new TypedValue(0, "LWPOLYLINE")
            };
            DBObjectCollection dBObjectCollection = utils.SelectDBObjectCollection("请选择删除重点的多段线", types);

            using (Transaction transaction = utils.GetDabase().TransactionManager.StartTransaction())
            {
                foreach (DBObject dBObject in dBObjectCollection)
                {
                    if (dBObject is Polyline)
                    {
                        Polyline          polyline          = (Polyline)dBObject;
                        Point3dCollection point3dCollection = new Point3dCollection();
                        polyline.GetStretchPoints(point3dCollection);
                        Polyline polyline2 = CADUtils.PCToPolyline(PolyService.utils.RePoint(point3dCollection), polyline.GetEndWidthAt(0), polyline.Closed);
                        CADUtils.CopyAttribute(polyline, polyline2);
                        CADUtils.SaveEntity(transaction, polyline2);
                        CADUtils.DeleteEntity(transaction, dBObject.ObjectId);
                    }
                }
                transaction.Commit();
            }
        }
Exemple #2
0
 public static void SetText(DBText dbText, string text, string fontName, double height, double width)
 {
     dbText.TextString  = text;
     dbText.TextStyle   = CADUtils.GetTextStyle(fontName);
     dbText.Height      = height;
     dbText.WidthFactor = width;
 }
Exemple #3
0
        public void TextAdd()
        {
            PlanMapService planMapService = new PlanMapService();
            Utils          utils          = new Utils();
            IList <DBText> list           = CADUtils.SeletTexts();

            if (list != null && list.Count > 1)
            {
                using (Transaction transaction = utils.GetDabase().TransactionManager.StartTransaction())
                {
                    DBText dBText = transaction.GetObject(list[0].ObjectId, OpenMode.ForWrite) as DBText;
                    string text   = dBText.TextString;
                    for (int i = 1; i < list.Count; i++)
                    {
                        text = text + "、" + list[i].TextString;
                    }
                    if (dBText.Height == 1.0)
                    {
                        dBText.Height      = (0.8);
                        dBText.WidthFactor = (0.8);
                    }
                    text = text.Replace("(户)、", "、");
                    dBText.TextString = (text);
                    transaction.Commit();
                }
            }
        }
Exemple #4
0
        public void MergeGeometry()
        {
            TypedValue[] types = new TypedValue[]
            {
                new TypedValue(0, "LWPOLYLINE")
            };
            Utils utils            = new Utils();
            DBObjectCollection dbc = utils.SelectDBObjectCollection("请选择要合并的线", types);

            CADUtils.MergeGeometrys(dbc);
        }
Exemple #5
0
        /// <summary>
        /// 检查 pl 是否包含 jmdPL
        /// </summary>
        /// <param name="pl"></param>
        /// <param name="jmdPL"></param>
        /// <returns></returns>
        public static bool CheckPLContains(Polyline pl, Polyline jmdPL)
        {
            if (pl == jmdPL)
            {
                return(false);
            }
            Autodesk.AutoCAD.DatabaseServices.Region plRegion = CreateRegion(pl);
            Region re = CADUtils.CreateRegion(jmdPL);

            if (re != null && re.Area != 0)
            {
                double area = plRegion.Area;
                if (plRegion.Area == 0)
                {
                    return(false);
                }
                try
                {
                    plRegion.BooleanOperation(BooleanOperationType.BoolUnite, re);
                }
                catch
                {
                    return(false);
                }

                if (plRegion.Area < area + 0.1)
                {
                    return(true);
                }
            }
            else
            {
                return(true);
            }
            return(false);
        }