コード例 #1
0
        public static bool HasXrefsInPSpace(this Document doc)
        {
            bool value = false;

            var btrlist  = ProjectSetup.GetAllBtrs();
            var xreflist = ProjectSetup.Xref_List(doc);

            List <ObjectId> listoflayids = ProjectSetup.Project_ListOfLayoutIds(doc);
            var             pspaces      = listoflayids.GetRange(1, (listoflayids.Count() - 1));

            if (xreflist.Count() > 0)
            {
                foreach (BlockTableRecord x in xreflist)
                {
                    ObjectId[] xref_layids = ProjectSetup.Xref_LayoutFinder(x);
                    if (xref_layids.Any().Equals(pspaces.Any()))
                    {
                        value = true;
                        return(value);
                    }
                }
            }

            return(value);
        }
コード例 #2
0
        public static bool HasXrefsInMSpace(this Document doc)
        {
            // retrieve a list of external references in entire document
            var xreflist = ProjectSetup.Xref_List(doc);

            // retrieve a list of the layouts in the document
            List <ObjectId> listoflayids = ProjectSetup.Project_ListOfLayoutIds(doc);

            // the first layout is apparently ALWAYS Model Space??
            var mspace = listoflayids[0];

            // if there are external references in the list
            if (xreflist.Count() > 0)
            {
                // cycle through each
                foreach (BlockTableRecord x in xreflist)
                {
                    // find out which Layout they have Block References in
                    ObjectId[] xref_layids = ProjectSetup.Xref_LayoutFinder(x);
                    if (xref_layids.Any().Equals(mspace))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #3
0
        static void Main()
        {
            //Access and lock the current document and database
            Document     doc    = Application.DocumentManager.MdiActiveDocument;
            Database     db     = doc.Database;
            DocumentLock lckdoc = doc.LockDocument();
            Editor       ed     = doc.Editor;

            //Gather all the xrefs from the document, if there are any
            List <BlockTableRecord> xlist = ProjectSetup.Xref_List(doc);

            //Get a list of layouts/layoutids
            List <Layout>   listoflayouts = new List <Layout>();
            List <ObjectId> listoflayids  = ProjectSetup.Project_ListOfLayoutIds(doc);

            ed.WriteMessage("\n There are {0} layouts in this model", listoflayids.Count);

            // The objectIDs for the BlockTableRecords of the Model and PaperSpace layouts
            var mspace  = listoflayids[0];
            var pspaces = listoflayids.GetRange(1, (listoflayids.Count() - 1));

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                foreach (Layout l in listoflayouts)
                {
                    var              l_name         = l.LayoutName;
                    var              layout_extents = l.Extents;
                    var              layout_limits  = l.Limits;
                    ObjectId         lbtr_id        = l.BlockTableRecordId;
                    BlockTableRecord l_btr          = tr.GetObject(lbtr_id, OpenMode.ForRead) as BlockTableRecord;

                    List <ObjectId> objs_inLayout = new List <ObjectId>();
                    foreach (ObjectId x in l_btr)
                    {
                        objs_inLayout.Add(x);
                    }

                    int o = objs_inLayout.Count();

                    foreach (BlockTableRecord x in xlist)
                    {
                        ObjectIdCollection BlockRefIdsColl = x.GetBlockReferenceIds(true, true);
                        List <ObjectId>    BRI_list        = new List <ObjectId>();
                        foreach (ObjectId objid in BlockRefIdsColl)
                        {
                            BRI_list.Add(objid);
                        }
                        ObjectId       BlockId = BRI_list[0];
                        BlockReference blref   =
                            tr.GetObject(BlockId, OpenMode.ForRead) as BlockReference;
                        var block_bounds     = blref.Bounds;
                        var block_geoextents = blref.GeometricExtents;
                        //var block_xtra = blref.Wb
                    }
                }
            }
        }
コード例 #4
0
        public static bool HasEmptyLayouts(this Document doc)
        {
            bool value = false;

            Database     db     = doc.Database;
            DocumentLock lckdoc = doc.LockDocument();
            Editor       ed     = doc.Editor;

            //Gather all the xrefs from the document, if there are any
            List <BlockTableRecord> xlist = ProjectSetup.Xref_List(doc);

            //Get a list of layouts/layoutids
            List <Layout>   listoflayouts = new List <Layout>();
            List <ObjectId> listoflayids  = ProjectSetup.Project_ListOfLayoutIds(doc);

            ed.WriteMessage("\n There are {0} layouts in this model", listoflayids.Count);

            // The objectIDs for the BlockTableRecords of the Model and PaperSpace layouts
            var mspace  = listoflayids[0];
            var pspaces = listoflayids.GetRange(1, (listoflayids.Count() - 1));

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                foreach (Layout l in listoflayouts)
                {
                    ObjectId         lbtr_id = l.BlockTableRecordId;
                    BlockTableRecord l_btr   = tr.GetObject(lbtr_id, OpenMode.ForRead) as BlockTableRecord;

                    List <ObjectId> objs_inLayout = new List <ObjectId>();
                    foreach (ObjectId x in l_btr)
                    {
                        objs_inLayout.Add(x);
                    }

                    int o = objs_inLayout.Count();

                    if (o <= 1)
                    {
                        value = true;
                        return(value);
                    }
                }
            }
            return(value);
        }