.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Looping Thru all objects (Blocks) in drawing

1 REPLY 1
SOLVED
Reply
Message 1 of 2
VB_Autocad_guy
809 Views, 1 Reply

Looping Thru all objects (Blocks) in drawing

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

 

1 REPLY 1
Message 2 of 2
jeff
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost