this piece of code always gives "invalidcode exception". I tried both Ctype and DIrectCast.
Dim currentEntity As Entity = Nothing
Try
' currentEntity = CType(myT.GetObject(id, OpenMode.ForRead), Entity)
currentEntity = DirectCast(myT.GetObject(id, OpenMode.ForRead), Entity)
Catch exp As OverflowException
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("OverflowException")
Catch exp As InvalidCastException
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("InvalidCastException")
End Try
Attached is the full function, I am trying to read all the " coincidence constraints" in a drawing
Thanks in advance!
Hi,
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 -
Thank you for the response . How do I go about converting a blocktable reference to a block entity? I need the entity to find its dependencies.
Hi,
>> 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 -