Author Topic: mtext entity inside a table  (Read 2242 times)

0 Members and 1 Guest are viewing this topic.

vladimirzm

  • Guest
mtext entity inside a table
« on: March 01, 2009, 01:34:26 PM »
i can get the block's entity name inside a cell with 340 DXF code but only with blocks.
how can i get the mtext entity name inside a cell? -no text string-

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: mtext entity inside a table
« Reply #1 on: March 01, 2009, 05:27:57 PM »
Code: [Select]
((lambda (EntName)
   (while (setq EntName (entnext EntName))
     (print (entget EntName))
   )
 )
  (tblobjname
    "BLOCK"
    (cdr (assoc 2 (entget (car (entsel "\nSelect table: ")))))
  )
)
as you can see, no text string - no entity
why not vla- ?

vladimirzm

  • Guest
Re: mtext entity inside a table
« Reply #2 on: March 02, 2009, 10:17:02 AM »
the idea was an specific mtext in col X, row Y and it doesn't matter ename or vla entity

yes, block table entity

I think I got it.
returns the vla mtext, if the cell is empty or there's a block returns nil.

Code: [Select]
(if cal () (arxload "geomcal")) ; for calculator

(DEFUN GetVlaMtext (Table row col / InsPt lst mtxt n npt PtoMtxt TableBlkDef vector xcol xrow zero)
  (SETQ TableBlkDef
(VLA-ITEM
   (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
   (CDR (ASSOC 2 (ENTGET (VLAX-VLA-OBJECT->ENAME Table))))
)
  )
  (SETQ InsPt  (VLAX-SAFEARRAY->LIST ; table's insertion point
(VLAX-VARIANT-VALUE
   (VLA-GET-INSERTIONPOINT TABLE)
)
       )
vector (VLAX-3D-POINT 1 1 1)
zero   '(0.0 0.0 0.0)
n 0
  )

  (vlax-for x TableBlkDef
    (IF (= "AcDbMText" (VLA-GET-OBJECTNAME x))
      (SETQ lst (CONS x lst))
    )
  )
 
  (WHILE
    (AND
      (SETQ mtxt (NTH n lst))
      (SETQ PtoMtxt (VLAX-SAFEARRAY->LIST
      (VLAX-VARIANT-VALUE
(VLA-GET-INSERTIONPOINT mtxt)
      )
    )
    npt     (CAL "INSPT+vec(zero,PtoMtxt)") ; i don't like coords functions
    n     (1+ n)
      )     
      (VLA-HITTEST table (VLAX-3D-POINT npt) vector 'xrow 'xcol)
      (NOT
(AND (= xrow row)
     (= xcol col)
)
      )
    )
    (SETQ mtxt nil)
  )
  mtxt
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: mtext entity inside a table
« Reply #3 on: March 03, 2009, 09:27:50 AM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

kozmos

  • Newt
  • Posts: 114
Re: mtext entity inside a table
« Reply #4 on: March 03, 2009, 09:21:03 PM »
KozMos Inc.

vladimirzm

  • Guest
Re: mtext entity inside a table
« Reply #5 on: March 04, 2009, 12:24:26 PM »
Quote
  • By dividing the cell Length and Height into 10 parts, we can build a 10x10 points list;
  • Map the points list to (nentselp point) function to see if we can get a return value

i think this is dangerous...

kozmos

  • Newt
  • Posts: 114
Re: mtext entity inside a table
« Reply #6 on: March 04, 2009, 08:37:39 PM »
Quote
  • By dividing the cell Length and Height into 10 parts, we can build a 10x10 points list;
  • Map the points list to (nentselp point) function to see if we can get a return value

i think this is dangerous...

It might be if we do not use additional checking rules. But we will be able to filter out all the wrong objects if we have rules. The codes now might get wrong result only in case an individual MTEXT is located in the cell region with the same content as the cell content while that should be very rare chance. Placing an individual MTEXT into the Table cell is not good idea in creating a integrated table. But an additional check by tracing down the MTEXT's DXF code 330.331 (it should be a Table record), we can make sure if the MTEXT should be in the Table definition records.

As what I know, there is not much options for us if we have the ename or vla-object id for the cell content, becoz we can not modify the content by manipulating the cell content object as such change will be ignored by AcDbTable while next table update.
KozMos Inc.