示例#1
0
        public static Parcel ByNumber(Autodesk.AutoCAD.DynamoNodes.Document document, Site siteObject, int parcelNumber)
        {
            Autodesk.Civil.DatabaseServices.Parcel retParcel = null;
            //get the current document and database
            AcadApp.Document doc = document.AcDocument;
            Database         db  = doc.Database;

            Autodesk.Civil.DatabaseServices.Site site = (Autodesk.Civil.DatabaseServices.Site)siteObject._curCivilObject;
            Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection parcelIds = site.GetParcelIds();
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                foreach (Autodesk.AutoCAD.DatabaseServices.ObjectId objectId in parcelIds)
                {
                    retParcel = (Autodesk.Civil.DatabaseServices.Parcel)trans.GetObject(objectId, OpenMode.ForRead);
                    if (retParcel.Number != parcelNumber)
                    {
                        retParcel = null;
                    }
                    else
                    {
                        return(new Parcel(retParcel, true));
                    }
                }
            }
            return(null);
        }
示例#2
0
        public static Parcel ByIndex(Autodesk.AutoCAD.DynamoNodes.Document document, Site siteObject, int index)
        {
            Parcel retParcel = null;

            //get the current document and database
            AcadApp.Document doc = document.AcDocument;
            Database         db  = doc.Database;

            Autodesk.Civil.DatabaseServices.Site site = (Autodesk.Civil.DatabaseServices.Site)siteObject._curCivilObject;
            Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection parcelIds = site.GetParcelIds();
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                retParcel = new Parcel((Autodesk.Civil.DatabaseServices.Entity)trans.GetObject(parcelIds[index], OpenMode.ForRead), true);
            }
            return(retParcel);
        }