.NET

Reply
Distinguished Contributor
RolandF
Posts: 172
Registered: ‎11-19-2003
Message 11 of 12 (74 Views)

Re: How do i find a block in the BlockTable

05-24-2006 12:01 AM in reply to: *Matt
If i delete all blockreferences in the drawing and then i purge the drawing
i do not get an error.
So the error just occours when i delete it in the programm, dosn't it?

--
Roland Feletic
Ingenieurbuero A. Pauser Ges.m.b.H.
http://www.pauser.at

hp workstation xw4200, 3GB
quadro fx1400
AutoCAD 2007, 3DSMax 8.0 SP 2
Distinguished Contributor
RolandF
Posts: 172
Registered: ‎11-19-2003
Message 12 of 12 (74 Views)

Re: How do i find a block in the BlockTable

05-24-2006 02:37 AM in reply to: *Matt

Now i changed the function a little bit. This
should work now.

 

public bool IsBlockInDrawing(string BlockName, out ObjectId BlockId)

{

    bool BlockIsInDrawing = false;

    BlockId =

new ObjectId();

    using (Transaction tr = db.TransactionManager.StartTransaction())

    using (BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false))

    {

        try

        {

            BlockId = bt[BlockName];

            using (BlockTableRecord btr = (BlockTableRecord)tr.GetObject(BlockId, OpenMode.ForRead, false))

            {

                if (!btr.IsLayout && !btr.IsAnonymous)

                    BlockIsInDrawing =

true;

            }

        }

        catch

        {

        }

        tr.Commit();

        return BlockIsInDrawing;

    }

}



--
Roland
Feletic
Ingenieurbuero A. Pauser Ges.m.b.H.

href="http://www.pauser.at">
size=2>http://www.pauser.at

 

hp workstation xw4200, 3GB
quadro
fx1400
AutoCAD 2007, 3DSMax 8.0 SP 2
Announcements
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 or visit the Installation and Licensing Forum to get help installing your software.