.NET

.NET

Reply
Distinguished Contributor
VB_Autocad_guy
Posts: 136
Registered: ‎07-24-2009
Message 1 of 2 (327 Views)
Accepted Solution

Looping Thru all objects (Blocks) in drawing

327 Views, 1 Replies
01-17-2012 08:01 AM

I want to loop through all blockreferences and entities in Model Space and Layout space... 

Can I do that in one loop? 

 

Can I do something like for each object in Drawing database? 

What's the object set I'm looking for here? 

 

Here's the beginning of my current code. 

 

       'Start(Transaction)
        Using myTrans As Transaction = DatabaseIn.TransactionManager.StartTransaction

            Dim myBT As BlockTable = DatabaseIn.BlockTableId.GetObject(OpenMode.ForRead)
            Dim myModelSpace As BlockTableRecord = myBT(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForRead)

            'For Each Object in ModelSpace
            For Each myObjID As ObjectId In myModelSpace
                Dim myEnt As Entity = myObjID.GetObject(OpenMode.ForRead)

                If TypeOf myEnt Is Autodesk.AutoCAD.DatabaseServices.Line Then

 

One thing you could do is loop through the blocktable then get the entites in blocktablerecords that are layouts(IsLayout = true).

or get modelspace then get the blocktablerecords through the LayoutDictionary.

 

Valued Mentor
jeff
Posts: 338
Registered: ‎05-12-2009
Message 2 of 2 (318 Views)

Re: Looping Thru all objects (Blocks) in drawing

01-17-2012 09:55 AM in reply to: VB_Autocad_guy

One thing you could do is loop through the blocktable then get the entites in blocktablerecords that are layouts(IsLayout = true).

or get modelspace then get the blocktablerecords through the LayoutDictionary.

 

You can also find your answers @ TheSwamp
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.