Author Topic: ID of Mtext in a table  (Read 2228 times)

0 Members and 1 Guest are viewing this topic.

Patrick_35

  • Guest
ID of Mtext in a table
« on: March 06, 2008, 07:14:53 AM »
Hi,

Everything is in the subject.
How to retrieve the ID of Mtext in a table ?
I find value of Mtext, the height of the cell, even the colour of the background, but nothing on ID.

I have this code, but if the zoom is too small, the lisp not works.

Code: [Select]
(setq tab (vlax-ename->vla-object (car (entsel))))
(setq pt (vlax-invoke tab 'GetAttachmentPoint 0 0)) ; rangée 1 colonne 1
(vla-get-ObjectID (vlax-ename->vla-object (car (nentselp pt))))

The solution is a total zoom, but if we could do without it for the rest lisp transparent.

Thanks in advance.

@+
« Last Edit: March 07, 2008, 03:25:00 AM by Patrick_35 »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ID of Mtext in a table
« Reply #1 on: March 06, 2008, 11:12:15 AM »
I think you would have to use 'nentsel' to select an mtext object that is within a table.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Patrick_35

  • Guest
Re: ID of Mtext in a table
« Reply #2 on: March 06, 2008, 11:21:10 AM »
Thank you,
but I don't want use nentsel. Just select the table and then search the ID of mtext.

@+

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ID of Mtext in a table
« Reply #3 on: March 06, 2008, 11:36:51 AM »
I don't see any direct way.

You could use HitTest to find out which row, column the selection was made at.  Then step through the block definition (assoc 2 of the table dxf code) and see if each mtext, or block I guess, fits within the window of the cell.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

kozmos

  • Newt
  • Posts: 114
Re: ID of Mtext in a table
« Reply #4 on: March 06, 2008, 08:47:28 PM »
Have a look at http://www.atablex.com/htmls/resource.htm#AcDbTable


Hi,

Everything is in the subject.
How to retrieve the ID of Mtext in a table ?
I find value of Mtext, the height of the cell, even the colour of the background, but nothing on ID.

I have this code, but if the zoom is too small, the lisp not works.

Code: [Select]
(setq tab (vlax-ename->vla-object (car (entsel))))
(setq pt (vlax-invoke tab 'GetAttachmentPoint 0 0)) ; rangée 1 colonne 1
(vla-get-ObjectID (vlax-ename->vla-object (car (nentselp pt))))

The solution is a total zoom, but if we could do without it for the rest lisp transparent.

Thanks in advance.

@+
KozMos Inc.

Patrick_35

  • Guest
Re: ID of Mtext in a table
« Reply #5 on: March 07, 2008, 03:18:20 AM »
Thanks
But it's work with nentselp and with a small zoom, that's not good.

I find with another

Code: [Select]
(setq lst nil tab (entget (car (entsel))))
(setq ent (entget (cdr (assoc -2 (tblsearch "block" (cdr (assoc 2 tab)))))))
(while (assoc 71 ent)
  (and (eq (logand (cdr (assoc 71 ent)) 2) 2)
    (setq lst (cons (cdr (assoc -1 ent)) lst))
  )
  (setq ent (entget (entnext (cdr (assoc -1 ent)))))
)
(reverse lst)
or
Code: [Select]
(setq lst nil tab (entget (car (entsel))))
(setq ent (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (cdr (assoc 2 tab))))
(vlax-map-collection ent '(lambda (x) (and (vlax-property-available-p x 'AttachmentPoint) (eq (vla-get-AttachmentPoint x) 2) (setq lst (cons x lst)))))
(reverse lst)

It remains to find mtext to associate with row and column.

@+
« Last Edit: March 07, 2008, 04:31:43 AM by Patrick_35 »

mkweaver

  • Bull Frog
  • Posts: 352
Re: ID of Mtext in a table
« Reply #6 on: March 11, 2008, 08:56:59 AM »
Given row and column numbers a lot of information is available for the contents of a cell:
Code: [Select]
(setq objTable (vlax-ename->vla-object (car (entsel))))
#<VLA-OBJECT IAcadTable2 0a886714>
_$ (setq temp (vla-gettext objtable 1 2))
"DESCRIPTION"

But I don't see any way, without nentsel, to get the object id for the mtext entity buried there.

Patrick_35

  • Guest
Re: ID of Mtext in a table
« Reply #7 on: March 11, 2008, 11:15:51 AM »
Hi
I find the solution

Code: [Select]
(defun IdMtextTable(tab / col ent fus id lig lst)
  (setq ent (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (cdr (assoc 2 (entget tab)))))
  (vlax-map-collection ent '(lambda (x) (and (vlax-property-available-p x 'AttachmentPoint) (setq lst (cons x lst)))))
  (setq lst (reverse lst) lig 0 tab (vlax-ename->vla-object tab))
  (while (< lig (vla-get-rows tab))
    (setq col 0)
    (while (< col (vla-get-columns tab))
      (or (eq (vla-ismergedcell tab lig col 0 0 0 0) :vlax-false)
  (eq lig 0)
  (eq (vla-ismergedcell tab (1- lig) col 0 0 0 0) :vlax-false)
  (not (eq (cadr (vlax-invoke tab 'GetAttachmentPoint lig col))(cadr (vlax-invoke tab 'GetAttachmentPoint (1- lig) col))))
        (setq fus T)
      )
      (or (eq (vla-ismergedcell tab lig col 0 0 0 0) :vlax-false)
  (eq col 0)
  (eq (vla-ismergedcell tab lig (1- col) 0 0 0 0) :vlax-false)
  (not (eq (car (vlax-invoke tab 'GetAttachmentPoint lig col))(car (vlax-invoke tab 'GetAttachmentPoint lig (1- col)))))
        (setq fus T)
      )
      (or fus
  (eq (vla-gettext tab lig col) "")
(setq id (cons (list lig col (car lst)) id)
      lst (cdr lst)
)
      )
      (setq col (1+ col) fus nil)
    )
    (setq lig (1+ lig))
  )
  (reverse id)
)

Select a table
Code: [Select]
(setq id (IdMtextTable (car (entsel))))
To find at row 4 and column 1
Code: [Select]
(setq ent (mapcar 'caddr (vl-remove-if-not '(lambda (x) (and (eq (car x) 4) (eq (cadr x) 1))) id)))
(vla-get-objectid (car ent))

@+

edit : Correcting a mistake
« Last Edit: March 12, 2008, 12:39:57 PM by Patrick_35 »