MergeCells in AutocCAD table

Hi All,

I’m tying to Merge cells in a table, but I’m receiving this error:

  • TypeError: No method matches given arguments for MergeCells: (<class ‘int’>, <class ‘int’>, <class ‘int’>, <class ‘int’>)

import clr

clr.AddReference(‘AcMgd’)
clr.AddReference(‘AcDbMgd’)

from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *

def table_mergecells(tableObj):
errorReport = None

if not tableObj:
    return

adoc = Application.DocumentManager.MdiActiveDocument
output = []

with adoc.LockDocument():
    with adoc.Database as db:
        with db.TransactionManager.StartTransaction() as t:
            #oid = tableObj.InternalDBObject
            #acTbl = t.GetObject(oid, OpenMode.ForWrite)
            try:
                print("MergeCells")
                acTbl = tableObj.InternalDBObject
                acTbl.UpgradeOpen()
                acTbl.MergeCells(0,1,0,3)
                acTbl.DowngradeOpen()
                t.Commit()
            # Error handling
            except:
                import traceback
                errorReport = traceback.format_exc()
                print("The process failed")
                output.append(errorReport)
            else:
                errorReport = "The process completed"
                print("errorReport: The process completed")
                #print(selObjects)
                output.append(tableObj)
            finally:
                #print("finally")
                return errorReport	

tableObj = IN[0]

print(“=== table_mergecells ===”)
retvalue = table_mergecells(tableObj)

OUT = retvalue

see:

What is issue here?

Try

acTbl.MergeCells(CellRange.Create(acTbl, 0, 1, 0, 3))

Or

CdacTbl = acTbl.AcadObject

CdacTbl.MergeCells(0,1,0,3)

Hi Hosneyalaa,

Thanks for your fast answer :slight_smile: :+1:

1 Like