this piece of code always gives "invalidcode exception". I tried both Ctype and DIrectCast.
Dim currentEntity As Entity = Nothing
' currentEntity = CType(myT.GetObject(id, OpenMode.ForRead), Entity)
currentEntity = DirectCast(myT.GetObject(id, OpenMode.ForRead), Entity)
Catch exp As OverflowException
Catch exp As InvalidCastException
Attached is the full function, I am trying to read all the " coincidence constraints" in a drawing
Thanks in advance!
Your loop scans through the BlockTable, so <id> represents the ObjectID for a BlockTableRecord. A BlockTableRecord is no entity (not derived from ...), so it can't be casted from DbObject to Entity.
- alfred -
>> How do I go about converting a blocktable reference to a block entity?
It's difficult, if we don't use the wordingbased on the API.
If you want to search for the blockdefinition (= BlockTableRecord) then you can use your loop through the BlockTable as you do and verify the ObjectID or the Name or whatever you need to find the correct block-definition,
If you want to search for block-insertions (= BlockReference) then you might
HTH, - alfred -