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

A little problem with Model Space

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
nedeljko.sovljanski
490 Views, 10 Replies

A little problem with Model Space

Hello,

How to list all entities in Model Space? I used some examples from documentation but result is always same. I have got only one (first) entity.

 Using acTrans As Transaction = modelSpaceDb.TransactionManager.StartTransaction()
                Dim blockTable As BlockTable = acTrans.GetObject(blockTableId, OpenMode.ForRead)
                Dim blockTableRecord As BlockTableRecord = acTrans.GetObject(blockTable(BlockTableRecord.ModelSpace), OpenMode.ForRead)
                For Each entity As ObjectId In blockTableRecord
                   ' Do something
                Next
            End Using

 

10 REPLIES 10
Message 2 of 11

Have a look at this thread.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 3 of 11

Hi Ed, still is the same result. Only one entity, but I have five lines and text.

Message 4 of 11

I do not see any issue with your code. Are you saying there are multiple entities in the ModelSpace of the drawing?

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 11

Hi,

Yes, I have five lines and single line text in model space.

Message 6 of 11

In this code from Autodesk documentation

https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-034504F8-59F8-4D6D-8777-3EF8A9C251DF

in section "Retrieve entities from Model space" there is stated "The following example returns the first entity object in Model space". It is so confusing.

Message 7 of 11

Did you actually run the code? Or you only take the word of the said documentation as as truth?

 

The statement of that of that said documentation is clearly not correct unless the ModelSpace only has one entity, or there is a "Exit For" statement inside the "For Each ..." loop that lets the code execution jumps out the loop after getting the first entity.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 8 of 11

Hi, Norman. I am running code almost six hours. I tried different scenarios. If I first put text and than lines I will get text. If I draw circle and then place single line text I will get only circle, and so on. 

Message 9 of 11

Incredible,

There was some bug with Visual studio debugger. When I put some code in for each loop it shows all entity

Message 10 of 11

@nedeljko.sovljanski 

 

That's why it's best to post enough code to allow people to say , "Hey, you need there to be a block of code in the if statement"   🙂

 

It's a bit cheeky to award yourself credit for solving this problem  😂


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.
Sometimes the question is more important than the answer.

class keyThumper<T> : Lazy<T>;      another  Swamper

Message 11 of 11


@nedeljko.sovljanski wrote:

Incredible,

There was some bug with Visual studio debugger. ...


It is indeed incredible 😄

Norman Yuan

Drive CAD With Code

EESignature

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report