Posts: 212
Registered: ‎08-24-2010
Message 1 of 2 (114 Views)

Block parent layout name

114 Views, 1 Replies
06-05-2013 02:19 AM

Hi every one ..


How Can I know the name of Block parent Layout?

*Expert Elite*
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 2 (104 Views)

Re: Block parent layout name

06-05-2013 03:30 AM in reply to: Amremad

Try this code, wriiten in a hurry, so check on possible errors:

        public void LayoutNameOfBlockRef()
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
         Transaction tr = doc.TransactionManager.StartTransaction();

         using (tr)

             PromptEntityOptions peo = new PromptEntityOptions("\nSelect block >>");
             peo.SetRejectMessage("\nSelect block only >>");
             peo.AddAllowedClass(typeof(BlockReference), false);
             PromptEntityResult res;
             res = ed.GetEntity(peo);
             if (res.Status != PromptStatus.OK)
             Entity ent = (Entity)tr.GetObject(res.ObjectId, OpenMode.ForRead);
             if (ent == null)
             BlockReference br = (BlockReference)ent as BlockReference;
             DBObject obj = tr.GetObject(br.OwnerId, OpenMode.ForRead);
             BlockTableRecord lbtr = tr.GetObject(br.OwnerId, OpenMode.ForRead) as BlockTableRecord;
             ObjectId ltId = lbtr.LayoutId;
             Layout lt = tr.GetObject(ltId, OpenMode.ForRead) as Layout;
             Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("BlockReference belongs to tab: " + lt.LayoutName);




You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community