zintonio
Guest
Hello everyone,
I would like to try to insert, in vba, a block in a cell spencifica of a table.
I tried to write the following code but I can't figure out how .setblocktablerecordid works that allows me to insert the block into the cell.
Have you ever had to put a lock in a cell?
How can I do that?
Thank you.
public sub add_table()
dim minp as variant
dim maxp as variant
dim pt(2) as double
dim actable as acadtable
dim and as acadentity
dim pp(2) as variant
dim id as long_ptr
thisdrawing.utility.getentity e, pp, "pick a point"
set actable = thisdrawing.activelayout.block.addtable(pt, 10, 4, 10, 60)
id = e.objectid
with actable
.regeneratetablesuppressed = true
.recomputetableblock false
.titlesuppressed = false
.headersuppressed = false
dim i as double, j as double
dim with as new acadaccmcolor
col.setrgb 255, 0, 255
'title
.setcelltextheight i, j, 6.4
.setcellalignment i, j, acmiddlecenter
col.setrgb 194, 212, 235
.setcellbackgroundcolor i, j, col
col.setrgb 127, 0, 0
.setcellcontentcolor i, j, col
.setcelltype i, j, actextcell
.settext 0, 0, "table title"
i = i + 1
'headers'
for j = 0 to .columns - 1
col.setrgb 203, 220, 183
.setcellbackgroundcolor i, j, col
0, 0, 255
.setcellcontentcolor i, j, col
.setcelltextheight i, j, 5.2
.setcellalignment i, j, acmiddlecenter
.setcelltype i, j, actextcell
.settext i, j, "header" & cstr(j + 1)
next
'data rows
.setcelltype 3, 0, acblockcell.setblocktablerecordid 3, 0, id, true
.regeneratetablesuppressed = false
.recomputetableblock true
.update
.getboundingbox minp, maxp
zoomwindow minp, maxp
zoomscaled 0.9, aczoomscaledrelative
thisdrawing.setvariable "lwdisplay", 1
set col = nothing
end with
end sub
I would like to try to insert, in vba, a block in a cell spencifica of a table.
I tried to write the following code but I can't figure out how .setblocktablerecordid works that allows me to insert the block into the cell.
Have you ever had to put a lock in a cell?
How can I do that?
Thank you.
public sub add_table()
dim minp as variant
dim maxp as variant
dim pt(2) as double
dim actable as acadtable
dim and as acadentity
dim pp(2) as variant
dim id as long_ptr
thisdrawing.utility.getentity e, pp, "pick a point"
set actable = thisdrawing.activelayout.block.addtable(pt, 10, 4, 10, 60)
id = e.objectid
with actable
.regeneratetablesuppressed = true
.recomputetableblock false
.titlesuppressed = false
.headersuppressed = false
dim i as double, j as double
dim with as new acadaccmcolor
col.setrgb 255, 0, 255
'title
.setcelltextheight i, j, 6.4
.setcellalignment i, j, acmiddlecenter
col.setrgb 194, 212, 235
.setcellbackgroundcolor i, j, col
col.setrgb 127, 0, 0
.setcellcontentcolor i, j, col
.setcelltype i, j, actextcell
.settext 0, 0, "table title"
i = i + 1
'headers'
for j = 0 to .columns - 1
col.setrgb 203, 220, 183
.setcellbackgroundcolor i, j, col
0, 0, 255
.setcellcontentcolor i, j, col
.setcelltextheight i, j, 5.2
.setcellalignment i, j, acmiddlecenter
.setcelltype i, j, actextcell
.settext i, j, "header" & cstr(j + 1)
next
'data rows
.setcelltype 3, 0, acblockcell.setblocktablerecordid 3, 0, id, true
.regeneratetablesuppressed = false
.recomputetableblock true
.update
.getboundingbox minp, maxp
zoomwindow minp, maxp
zoomscaled 0.9, aczoomscaledrelative
thisdrawing.setvariable "lwdisplay", 1
set col = nothing
end with
end sub