Dear All,
Why my LINQ query always returns nothing ?
There is already some block refernces in the current drawing.
Please advise me where i am worng?
<CommandMethod("BlockList")> _ Public Sub BlockList() '' Get the current document and database Dim acDoc As Object = Application.DocumentManager.MdiActiveDocument Dim acCurDb As Object = HostApplicationServices.WorkingDatabase Dim acCurBlkTbl As Object = acCurDb.BlockTableId Dim blkrefs = From b In CType(CTypeDynamic(acCurBlkTbl, GetType(IEnumerable(Of Object))), _ IEnumerable(Of Object)) Where (b.GetRXClass().Name = "AcDbBlockReference") Select b For Each blk As BlockReference In blkrefs acDoc.Editor.WriteMessage(vbCrLf + blk.Name + vbCrLf) Next End Sub
FYI : There are many goodways to list all block references. But here i am trying to study Dynamic and LINQ features of .NET.
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Hi Gilles,
Thanks for point out the Error.
Below is corrected one.
<CommandMethod("BlockList")> _ Public Sub BlockList() '' Get the current document and database Dim acDoc As Object = Application.DocumentManager.MdiActiveDocument Dim acCurDb As Object = HostApplicationServices.WorkingDatabase Dim acCurSpace = acCurDb.CurrentSpaceId Dim blkrefs = From b In CType(CTypeDynamic(acCurSpace, GetType(IEnumerable(Of Object))), _ IEnumerable(Of Object)) Where (b.GetRXClass().Name = "AcDbBlockReference") Select b For Each blk As Object In blkrefs acDoc.Editor.WriteMessage(vbCrLf + blk.Name + vbCrLf) Next End Sub
Can't find what you're looking for? Ask the community or share your knowledge.