예제 #1
0
        public List <AcadDB.Region> GetSubRegions()
        {
            List <AcadDB.Region> regions = new List <AcadDB.Region>();

            AcadGeo.Vector3d tmp_vec = up_vector.CrossProduct(normal_vector);

            AcadDB.DBObjectCollection objs = new AcadDB.DBObjectCollection();

            AcadGeo.Vector3d hf = up_vector * height * 0.5;
            AcadGeo.Vector3d wf = tmp_vec * (width * 0.5 - thickness);
            AcadGeo.Vector3d tf = up_vector * thickness;
            objs.Add(new AcadDB.Line(base_point + hf + wf, base_point + hf - wf));
            objs.Add(new AcadDB.Line(base_point + hf - wf, base_point - hf - wf + tf));
            objs.Add(new AcadDB.Line(base_point - hf - wf + tf, base_point - hf + wf + tf));
            objs.Add(new AcadDB.Line(base_point - hf + wf + tf, base_point + hf + wf));

            {
                AcadDB.DBObjectCollection regs = AcadDB.Region.CreateFromCurves(objs);

                foreach (var reg in regs)
                {
                    if (reg is AcadDB.Region)
                    {
                        regions.Add(reg as AcadDB.Region);
                    }
                }
            }

            return(regions);
        }
예제 #2
0
        /// <summary>
        /// 检查宗地图
        /// </summary>
        /// <param name="jsyd"></param>
        /// <param name="entitys">图框内的所有实体</param>
        internal static void CheckZDT(Jsyd jsyd, Autodesk.AutoCAD.DatabaseServices.DBObjectCollection entitys)
        {
            Utils  utils     = new Utils();
            string layerName = "宗地图检查错误";

            foreach (DBObject dBObject in entitys)
            {
                if (dBObject is DBText)
                {
                    DBText  dBText2 = (DBText)dBObject;
                    string  text    = dBText2.TextString;
                    Point3d pt      = dBText2.Position;
                    if (text.Contains("宗地面积"))
                    {
                        if (jsyd.Zdmj != GetArea(text))
                        {
                            utils.CreateCircle(pt, 1, layerName);
                        }
                    }
                    else if (text.Contains("-"))//地籍图号
                    {
                        if (text != jsyd.TFH)
                        {
                            utils.CreateCircle(pt, 1, layerName);
                        }
                    }
                    else if (text.Contains("宅基地面积"))
                    {
                        if (jsyd.Syqmj != GetArea2(text))
                        {
                            utils.CreateCircle(pt, 1, layerName);
                        }
                    }
                    else if (text.Contains("建设用地面积"))
                    {
                        if (jsyd.Czmj != GetArea2(text))
                        {
                            utils.CreateCircle(pt, 1, layerName);
                        }
                    }
                    else if (text.Contains("土地权利人"))
                    {
                        if (!text.Contains("、"))
                        {
                            text = text.Replace("土地权利人:", "").Replace("(户)", "").Replace("(户)", "").Trim();
                            if (jsyd.QLRMC != text)
                            {
                                utils.CreateCircle(pt, 1, layerName);
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        public static ACADDB.Region AddRegion(ACADDB.ObjectId acadObjectId)
        {
            ACADDB.Region returnvalue = null;
            // Get the current document and database
            Document acDoc = Application.DocumentManager.MdiActiveDocument;

            ACADDB.Database acCurDb = acDoc.Database;

            // Start a transaction
            using (ACADDB.Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Open the Block table for read
                ACADDB.BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                             ACADDB.OpenMode.ForRead) as ACADDB.BlockTable;

                // Open the Block table record Model space for write
                ACADDB.BlockTableRecord acBlkTblRec;
                acBlkTblRec = acTrans.GetObject(acBlkTbl[ACADDB.BlockTableRecord.ModelSpace],
                                                ACADDB.OpenMode.ForWrite) as ACADDB.BlockTableRecord;

                ACADDB.Polyline polyline = acTrans.GetObject(acadObjectId,
                                                             ACADDB.OpenMode.ForRead) as ACADDB.Polyline;
                if (polyline != null)

                {
                    ACADDB.DBObjectCollection acDBObjColl = new ACADDB.DBObjectCollection();
                    acDBObjColl.Add((ACADDB.DBObject)polyline.AcadObject);

                    // Calculate the regions based on each closed loop
                    ACADDB.DBObjectCollection myRegionColl = new ACADDB.DBObjectCollection();
                    myRegionColl = ACADDB.Region.CreateFromCurves(acDBObjColl);
                    ACADDB.Region acRegion = myRegionColl[0] as ACADDB.Region;
                    returnvalue = acRegion;
                    // Add the new object to the block table record and the transaction
                    acBlkTblRec.AppendEntity(acRegion);
                    acTrans.AddNewlyCreatedDBObject(acRegion, true);

                    // Dispose
                }

                // Save the new object to the database
                acTrans.Commit();
            }
            return(returnvalue);
        }