Text and Block in One Table Cell

Text and Block in One Table Cell

DGCSCAD
Collaborator Collaborator
1,661 Views
15 Replies
Message 1 of 16

Text and Block in One Table Cell

DGCSCAD
Collaborator
Collaborator

I have a cell with text and a block, and when I select it and check it's properties (Ctrl+1) I'm seeing:

 

Content

Cell Type | Multi (greyed out/non-selectable)

Layout | Flow (selectable with options for Horz/Vert Stacked)

 

How would I set a cell to this (Multi) using LISP?

 

I know there's vla-SetCellType, which is either acBlockCell, acTextCell, or acUnknownCell, but that sets it to only one of those.

 

I've been combing through this and haven't found what I need:

http://entercad.ru/acadauto.en/

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Accepted solutions (2)
1,662 Views
15 Replies
Replies (15)
Message 2 of 16

Sea-Haven
Mentor
Mentor

Post dwg need to look at it sounds like a merged cell.

0 Likes
Message 3 of 16

komondormrex
Mentor
Mentor

in fact it is not.

0 Likes
Message 4 of 16

komondormrex
Mentor
Mentor
Accepted solution

check this

 

(setq table (vlax-ename->vla-object (car (entsel "\nPick your table: "))))
(setq b (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) "111")) ;getting the block record "111"
(setq bid (vla-get-objectid b))	;getting the block record "111" id
(vla-setblocktablerecordId table 1 1 bid :vlax-true)	;inserting the block record "111" into the cell 1 1 with autofitting set to true
(setq sid1 (vla-createcontent table 1 1 0))	;creating content id for the cell 1 1
(vla-settextstring table 1 1 sid1 "Multi")	; adding text "Multi" to the text content of the cell 11 

 

 

0 Likes
Message 5 of 16

Sea-Haven
Mentor
Mentor

As I often say learn something new every day, knew about insert block into cells.

 

Just a comment needed to do (vla-put-regeneratetablesuppressed table :vlax-false) to see result, somewhere regenerate is turned off.

0 Likes
Message 6 of 16

DGCSCAD
Collaborator
Collaborator

@komondormrex wrote:

check this

 

 

(setq table (vlax-ename->vla-object (car (entsel "\nPick your table: "))))
(setq b (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) "111")) ;getting the block record "111"
(setq bid (vla-get-objectid b))	;getting the block record "111" id
(vla-setblocktablerecordId table 1 1 bid :vlax-true)	;inserting the block record "111" into the cell 1 1 with autofitting set to true
(setq sid1 (vla-createcontent table 1 1 0))	;creating content id for the cell 1 1
(vla-settextstring table 1 1 sid1 "Multi")	; adding text "Multi" to the text content of the cell 11 

 

 

 


Thank you!

Not sure why it's not accepting formatting in the text string though.

 

Here's the end result of what I'm trying to accomplish:

Note_CCTS.PNG

The red outline (the cell border), and the green block are both colored just for explanation purposes, but the text needs to have everything bylayer except for the blue string in parenthesis. It needs to be blue.

 

The text string would be:

"NOTE:\\PTHIS LINE AND AND THEN THIS {\\C5;(BLUE STUFF)} SOME OTHER STUFF HERE."

 

It's formatted correctly in a text cell, but it seems to behave differently when it's a mixed cell.

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 7 of 16

komondormrex
Mentor
Mentor

dunno, it does for me.

komondormrex_0-1715629332710.pngkomondormrex_1-1715629366509.png

 

Message 8 of 16

DGCSCAD
Collaborator
Collaborator

Well... I guess I had something funky going on in my test string when ran it earlier. It's fully functional now. Thank you again, komondormrex.

AutoCad 2018 (full)
Win 11 Pro
Message 9 of 16

dvertz
Collaborator
Collaborator

komondormrex,

Thank you for commenting the section ";inserting the block record "111" into the cell 1 1 with autofitting set to true"

 

The autofit part is just what I was looking for.

Civil 3D 2022,
Windows 10 Pro, x64, Nvidia Quadro P1000
Intel Core i9-11900k; 3.50GHz, 32 GB RAM, 500GB WD BLACK M.2


0 Likes
Message 10 of 16

DGCSCAD
Collaborator
Collaborator

How would I retrieve the block name from a table cell?

 

 

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 11 of 16

DGCSCAD
Collaborator
Collaborator

Here's where I'm stuck:

 

Command: (setq IMG_name (vlax-invoke-method tbl_ename 'GetCellValue 5 4))
#<variant 0 >

 

Command: (setq IMG_name (vlax-invoke-method tbl_ename 'GetCellType 5 4))
2

 

Not sure what 'Get... to use, or do I have to dig deeper?

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 12 of 16

komondormrex
Mentor
Mentor
Accepted solution

the following will retrieve block name from a table cell, row 1 column 3. where table is a table like in message 6.

(vla-get-name (vla-objectidtoobject (vla-get-activedocument (vlax-get-acad-object)) (itoa (vla-getblocktablerecordId table 1 3))))

 

0 Likes
Message 13 of 16

dvertz
Collaborator
Collaborator

I was hoping someone would pop in and answer this for you. There are certainly people better at lisp than myself. But here's what I have. Code to set the block. Maybe it can help you come up the getting the block.

 

(vla-SetBlockTableRecordId VLA:ACTABLE INT:TBLROW 1 (vla-get-objectid (vla-item (vla-get-blocks VLA:ACTDOC) (vl-filename-base PATHFILENAME))) :vlax-true)

 

I know the command "vla-GetBlockTableRecordId" exists, but I have not used it.

 

Civil 3D 2022,
Windows 10 Pro, x64, Nvidia Quadro P1000
Intel Core i9-11900k; 3.50GHz, 32 GB RAM, 500GB WD BLACK M.2


0 Likes
Message 14 of 16

DGCSCAD
Collaborator
Collaborator

@komondormrex 

 

Once again, you've found the solution. I was way off. Thanks again!

 

@dvertz 

 

Thank you! I appreciate any and all help I can get. 🙂

AutoCad 2018 (full)
Win 11 Pro
Message 15 of 16

dvertz
Collaborator
Collaborator

komondormrex, Thanks for getting this for DGCSCAD.

I had the "vla-getblocktablerecordId". I had no clue about the "vla-objectidtoobject" part.

Civil 3D 2022,
Windows 10 Pro, x64, Nvidia Quadro P1000
Intel Core i9-11900k; 3.50GHz, 32 GB RAM, 500GB WD BLACK M.2


Message 16 of 16

komondormrex
Mentor
Mentor

hey guys, you are much welcome!)

when it sets, it undeniably gets!