Results 1 to 8 of 8

Thread: Setting a cellrange creates error

  1. #1
    Member
    Join Date
    2000-11
    Location
    Roanoke, Va.
    Posts
    28
    Login to Give a bone
    0

    Default Setting a cellrange creates error

    I am trying to merge cells in an AutoCAD Table.

    My Code is:

    Dim CellRng as CellRange = New CellRange(0,0,0,3)
    Tbl.MergeCells(CellRng)

    It generates this error:

    'Autodesk.AutoCAD.DatabaseServices.CellRange.Protected Sub New(table As Autodesk.AutoCAD.DatabaseServices.Table, topRow As Integer, leftColumn As Integer, bottomRow As Integer, rightColumn As Integer)' is not accessible in this context because it is 'Protected'.

    How do I define a CellRange to feed to the MergeCells method?

    Thanks for your help.

  2. #2
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Setting a cellrange creates error

    Quote Originally Posted by pcs View Post
    I am trying to merge cells in an AutoCAD Table.

    My Code is:

    Dim CellRng as CellRange = New CellRange(0,0,0,3)
    Tbl.MergeCells(CellRng)

    It generates this error:

    'Autodesk.AutoCAD.DatabaseServices.CellRange.Protected Sub New(table As Autodesk.AutoCAD.DatabaseServices.Table, topRow As Integer, leftColumn As Integer, bottomRow As Integer, rightColumn As Integer)' is not accessible in this context because it is 'Protected'.

    How do I define a CellRange to feed to the MergeCells method?

    Thanks for your help.
    Just an idea

    Set this table state to write-enabled state before:
    Code:
    Tbl.UpgradeOpen();
    ~'J'~

  3. #3
    Member
    Join Date
    2000-11
    Location
    Roanoke, Va.
    Posts
    28
    Login to Give a bone
    0

    Default Re: Setting a cellrange creates error

    The problem lies in defining the cellrange, not in the MergeCells method. I never get to the MergeCells method.

  4. #4
    Member
    Join Date
    2000-11
    Location
    Roanoke, Va.
    Posts
    28
    Login to Give a bone
    0

    Default Re: Setting a cellrange creates error

    So now I'm using:

    Dim CellRng As CellRange
    CellRng = CellRange.Create(Tbl, 0,0,0,3)
    Tbl.MergeCells(CellRng)

    I get past the cellrange definition but it still craps out on the MergeCells method with:
    Autodesk.AutoCAD.Runtime.Exception was unhandled by user code
    Message="eInvalidInput"
    Source="acdbmgd"
    StackTrace:
    at Autodesk.AutoCAD.DatabaseServices.Table.MergeCells(CellRange range)
    at SFCSKitSched.Commands.KitSched() in C:\Documents and Settings\pstarkey\My Documents\Visual Studio 2008\Projects\KitchenSchedule.dll\KitchenSchedule.dll\Commands.vb:line 118
    at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
    at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
    at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
    at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()
    InnerException:

  5. #5
    Member
    Join Date
    2000-11
    Location
    Roanoke, Va.
    Posts
    28
    Login to Give a bone
    0

    Default Re: Setting a cellrange creates error

    Sorry, I found another error that created that problem.
    Thanks everyone for your help.

  6. #6
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Setting a cellrange creates error

    Quote Originally Posted by pcs;[COLOR="Black"
    1043651]Sorry, I found another error that created that problem.
    Thanks everyone for your help.
    In case if somebody else would be interesting to solve this problem
    here is a working example that was tested on A2008 only:
    Code:
        Public Sub addTable()
            Dim adoc As Document = AcadApp.DocumentManager.MdiActiveDocument
            Dim ed As Editor = adoc.Editor
            Using lock As DocumentLock = adoc.LockDocument()
                Dim dbase As Database = HostApplicationServices.WorkingDatabase
    
                Using trans As Transaction = dbase.TransactionManager.StartTransaction()
    
                    Try
     
                        Dim arr(,) As String = New String(9, 3) {}
                        For i As Integer = 0 To UBound(arr, 1)
                            For j As Integer = 0 To UBound(arr, 2)
                                arr(i, j) = CStr((i + 1) * (j + 1))
    
                            Next
                        Next
                        Dim nmRows As Integer = UBound(arr, 1) + 4
                        Dim nmColumns As Integer = UBound(arr, 2) + 1
                        Dim position As Point3d = New Point3d(50.0, 25.0, 0.0) 'dummy point
    
                        Dim rowHeight As Double = 0.2
                        Dim blkTbl As BlockTable = CType(trans.GetObject(dbase.BlockTableId, OpenMode.ForRead), BlockTable)
                        Dim blkTblRec As BlockTableRecord = CType(trans.GetObject(blkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
                        'Dim styDef As ObjectId = makeTableStyle() 'create table style
                        Dim myTable As Table = New Table()
    
                        myTable.IsHeaderSuppressed = False
                        myTable.IsTitleSuppressed = False
    
                        myTable.NumColumns = nmColumns
                        myTable.NumRows = nmRows
                        myTable.Height = nmRows * rowHeight
    
                        myTable.Position = position
                        'myTable.TableStyle = styDef 'set custom table style here
    
                        myTable.RecomputeTableBlock(False)
                        myTable.GenerateLayout()
                        myTable.SetTextString(0, 0, "Title goes here")
                        myTable.SetColumnWidth(0, 2)
                        myTable.SetColumnWidth(1, 3)
                        myTable.SetColumnWidth(2, 3)
                        myTable.SetColumnWidth(3, 3)
                        myTable.SetTextHeight(0.2, RowType.TitleRow) 'title row
                        myTable.SetTextHeight(0.15, RowType.HeaderRow) 'header row
                        myTable.SetTextHeight(0.1, RowType.DataRow) 'data row
    
                        Dim hdl(3) As String
                        hdl(0) = "Header A"
                        hdl(1) = "Header B"
                        hdl(2) = "Header C"
                        hdl(3) = "Header D"
                        For i As Integer = 0 To UBound(hdl)
                            Dim s As String
                            s = hdl(i)
                            myTable.SetTextString(1, i, s)
                        Next
    
                        For i As Integer = 0 To UBound(arr, 1)
                            For j As Integer = 0 To UBound(arr, 2)
                                Dim s As String = arr(i, j)
                                myTable.SetTextString(i + 2, j, s)
                            Next
                        Next
    
                        'e.g. merge cells in the the very last row
                        Dim trg As CellRange = New CellRange(nmRows - 1, 0, nmRows - 1, 3)
    
                        myTable.MergeCells(trg)
                        myTable.SetTextString(nmRows - 1, 0, "Merged cells are goes here")
                        myTable.RecomputeTableBlock(True)
                        blkTblRec.AppendEntity(myTable)
                        trans.AddNewlyCreatedDBObject(myTable, True)
                        ed.Regen()
                        myTable.Dispose()
                        blkTbl.Dispose()
                        blkTblRec.Dispose()
                    Catch ex As System.Exception
                        ed.WriteMessage(ex.Message & vbCrLf & ex.StackTrace)
                    End Try
                    trans.Commit()
                End Using
            End Using
        End Sub[/COLOR]
    ~'J'~
    Last edited by fixo; 2010-02-07 at 03:45 PM. Reason: spell check

  7. #7
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Setting a cellrange creates error

    Quote Originally Posted by tony.tanzillo View Post
    You might want to read the entire thread again.

    The constructor for CellRange() is no longer public in 2010

    You *must* use the Create() method.
    Dear Tony,

    Thanks for the info

    But I'm still in A2008 and there is no Create() method in there

    Regards,

    ~'J'~

  8. #8
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Setting a cellrange creates error

    Quote Originally Posted by tony.tanzillo View Post
    Right, and that's why I suggested reading the thread again, because
    the OP is not using 2008, and doesn't have access to the contstructor
    in the release they're using.
    Yep, you're right

    My bad, sorry

    Regards,

    ~'J'~

Similar Threads

  1. 2011: Publish pdf creates new dwg in c:/temp...
    By bryce.saunders in forum AutoCAD Plotting
    Replies: 0
    Last Post: 2012-05-01, 01:55 PM
  2. FLIP PARAMETER CREATES A SKEW
    By Ammon in forum Dynamic Blocks - Technical
    Replies: 2
    Last Post: 2008-04-09, 10:12 PM
  3. Replies: 3
    Last Post: 2006-12-27, 07:35 PM
  4. fatal error when rendering or setting up a new view
    By CADBIMManager in forum Revit Architecture - General
    Replies: 2
    Last Post: 2005-09-22, 01:09 AM
  5. Save reminder - system setting or project setting?
    By patricks in forum Revit Architecture - General
    Replies: 4
    Last Post: 2005-07-08, 01:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •