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
Solved! Go to Solution.
Solved by nedeljko.sovljanski. Go to Solution.
Have a look at this thread.
Hi Ed, still is the same result. Only one entity, but I have five lines and text.
I do not see any issue with your code. Are you saying there are multiple entities in the ModelSpace of the drawing?
Norman Yuan
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.
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
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.
Incredible,
There was some bug with Visual studio debugger. When I put some code in for each loop it shows all entity
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
@nedeljko.sovljanski wrote:
Incredible,
There was some bug with Visual studio debugger. ...
It is indeed incredible 😄
Norman Yuan
Can't find what you're looking for? Ask the community or share your knowledge.