ObjectDBX Error "Method 'ContentBlockName' of object 'IAcadMLeader' failed

ObjectDBX Error "Method 'ContentBlockName' of object 'IAcadMLeader' failed

Anonymous
Not applicable
826 Views
4 Replies
Message 1 of 5

ObjectDBX Error "Method 'ContentBlockName' of object 'IAcadMLeader' failed

Anonymous
Not applicable

Long time reader first time poster.
I have this program that pulls all Layers, Text, and Blocks (including attribute values) from a set dwgs into Access. I used to use AcadDocument method (keeping the app hidden in the background) and everything worked great. However, out of speed complaints, I switched over to ObjectDBX. Everything, is working great until I try to pull blocks that are embedded in MLeaders. It seems to me that the ContentBlockName property of the MLeader does not work in ObjectDBX. Can anyone else confirm this? If so, does anyone have and clever ideas to get around it?

A short code sample is below. I am using late binding. The code is running in Access 2013 (32-bit) and hitting AutoCAD 2015 (64-bit) on a Win 8.1 machine.
Any help is much appreciated so that I can stop banging my head against the wall.

 

Dim acadApp As Object 'AcadApplication
Dim acadDBX As Object 'AxDbDocument
Dim acadEnt As Object 'AcadEntity
Dim sBlock As String
Dim O As Object       'AcadEntity

Set acadApp = CreateObject("AutoCAD.Application")

For Each vFile In colFiles
    'This was the old method of opening the document (which worked) Set acadDoc = acadApp.Documents.Open(vFile, False)
    Set acadDBX = acadApp.GetInterfaceObject("ObjectDBX.AxDbDocument." & Left(acadApp.Version, 2))
    acadDBX.Open vFile
    
    For Each acadEnt In acadDBX.ModelSpace
        Select Case acadEnt.EntityType
            Case 21, 32
                'Do Stuff
            Case 7
                'Do Stuff
            Case 48
                sBlock = acadEnt.ContentBlockName '<<<< This is the line where the error occurs
                For Each O In acadDBX.Blocks(sBlock)
                    If O.ObjectName = "AcDbAttributeDefinition" Then
                        MsgBox acadEnt.GetBlockAttributeValue(O.ObjectID)
                    End If
                Next
        End Select
    Next
Next vFile

 

 

0 Likes
Accepted solutions (1)
827 Views
4 Replies
Replies (4)
Message 2 of 5

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

it might help to upload a drawing that contains elements forcing that error.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 5

Anonymous
Not applicable

I've been out traveling. I'll try to attach a sample file today.

0 Likes
Message 4 of 5

Anonymous
Not applicable

Alright. I apologize for my long delay. Here is a test file with a block that is embeded into a multileader.

The ContentBlockName method of the multileader object fails when accessed via DBX. Is this similar to the DBX issue that causes the save method to fail?

If so then I guess there is not a workaround other than looping through all of the ObjectId's of all the Block attributes to see which one matches.

0 Likes
Message 5 of 5

Anonymous
Not applicable
Accepted solution

I was actually able to get around this issue by byassing the ContentBlockName property all together.

I created a function that iterated through every attribute of every block in the blocks collection and attempted the GetBlockAttributeValue method. If it returned a value then I had found my block name, if it returned an error then then it kept looking.

0 Likes