COM interface with Python: Cant access the Name property of an AcadBlockReference object

I try to find out the which block is refferenced by a AcadBlockReference

    import comtypes.client

    acad = comtypes.client.GetActiveObject("BricscadApp.AcadApplication")

    doc = acad.ActiveDocument

    model = doc.ModelSpace

    model(121).ObjectName

This gives the result: 'AcDbBlockReference' - 121 is indeed a block reference

Now I try to acces the name of the referenced block:

    model(121).Name

I get the errormessage

    Traceback (most recent call last):
      File "C:\KBApps\Python34\lib\site-packages\comtypes-1.1.1-py3.4.egg\comtypes\__init__.py", line 275, in __getattr__
        fixed_name = self.__map_case__[name.lower()]
    KeyError: 'name'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "", line 1, in
        model(121).Name;
      File "C:\KBApps\Python34\lib\site-packages\comtypes-1.1.1-py3.4.egg\comtypes\__init__.py", line 277, in __getattr__
        raise AttributeError(name)
    AttributeError: Name

I cant find the reason for this. The COM documentation says that an AcadBlockReference object has the property Name. 

Best regards

Heinz-Otto

(Win7 x64 SP1, Bricscad V14.2.11 (x64), Python 3.4.3 64 bit)

Comments

  • Is it only the Name property that causes an error, or do other properties cause the same error? For example, what happens if you access the EffectiveName or ObjectName properties?
  • It is not only the Name property, the EffectiveName property shows the same errror. The Objectname property is available. The python ide show a list of available properties and methods while entering code. For the block reference the properties Name and Effectivename are missing in this list (see screenshot).
    imagePythonPickList.jpg
This discussion has been closed.