Get cell data/value by pick point in cell

Get cell data/value by pick point in cell

Anonymous
Not applicable
2,032 Views
4 Replies
Message 1 of 5

Get cell data/value by pick point in cell

Anonymous
Not applicable

Hello, 

(Disclaimer - I am not an expert in lisp, I just get by)

I have been scanning the internet for a routine or stuff i might be able to piece together to get a table cell's value/data.

I have had no luck on finding what i need. 

I am looking for a routine that will allow me to pick a point in any given cell will return the data attached to it. 

I don't want to pick the border but use point to pick inside, similar to if you used the command tabledit.

I am also looking for it to get the border boundaries of that cell... Maybe similar to a get bounding box, how it returns the min and max points...???

If anyone has a function that does these thing or any info on this that would be greatly appreciated! 

 

 

Thank you, 

Seth  

0 Likes
Accepted solutions (1)
2,033 Views
4 Replies
Replies (4)
Message 2 of 5

pbejse
Mentor
Mentor
Accepted solution

@Anonymous wrote:

... I am looking for a routine that will allow me to pick a point in any given cell will return the data attached to it. 


 

  
(defun _hit-test (pt obj / vd)
  (setq	pt (vlax-3D-point (trans pt 1 0))
	vd (vlax-3D-point (trans (getvar 'VIEWDIR) 1 0))
  )
  (if (eq :vlax-true (vla-hittest obj pt vd 'row 'col))
    (list obj row col)
  )
)
 (setq data (_hit-test (getpoint) table))
        (Vla-getText (car data) (cadr data)(caddr data))
	(vla-GetColumnWidth (Car data) (Caddr data));<---
  	(vla-GetRowHeight (CAr data) (cadr data));<---

HTH

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

Is table being defined? I seem to be having an issue with it. 

Do i need to pass it the vla-object of the table with --->

"(setq ent (car (entsel)))
(setq obj (vlax-ename->vla-object ent))

"?

 

 


@pbejse wrote:

@Anonymous wrote:

... I am looking for a routine that will allow me to pick a point in any given cell will return the data attached to it. 


 

  
(defun _hit-test (pt obj / vd)
  (setq	pt (vlax-3D-point (trans pt 1 0))
	vd (vlax-3D-point (trans (getvar 'VIEWDIR) 1 0))
  )
  (if (eq :vlax-true (vla-hittest obj pt vd 'row 'col))
    (list obj row col)
  )
)
 (setq data (_hit-test (getpoint) table))
        (Vla-getText (car data) (cadr data)(caddr data))
	(vla-GetColumnWidth (Car data) (Caddr data));<---
  	(vla-GetRowHeight (CAr data) (cadr data));<---

HTH

 


 

0 Likes
Message 4 of 5

Sea-Haven
Mentor
Mentor

Yes need to pick table 1st

(setq tobj (vlax-ename->vla-object (car (entsel "\nPick table "))))
(setq data (_hit-test (getpoint) tobj))

 

0 Likes
Message 5 of 5

Anonymous
Not applicable

Okay, so here is my end result I came up with.

This program is for our team to use in coordination with another program that allows a user to select their ceiling with all of their custom ceiling panels in blocks and will put the block into a table as well as the name and the qty similar to a data extract. 

(DEFUN C:TEST (/ *ERROR* ENT LAYER VALUE OBJ DATA ROW COL E X)
  (DEFUN *ERROR* (MSG)
    (SB:RESET_VARS)
    (IF
      (NOT
	(WCMATCH
	  (STRCASE MSG)
	  "*BREAK,*CANCEL*,*EXIT*"
	)
      )
       (PRINC
	 (STRCAT "\nERROR: " MSG)
       )
       (SB:RESET_VARS)
    )
    (COMMAND "UNDO" "_END")
    (PRINC)
  )
  (SB:GET_VARS)
  (setvar "OSMODE" 0)
  (SETQ LAYER "VIEW_BOUNDRY")
  (SETQ ENT (CAR (ENTSEL)))
  (SETQ OBJ (VLAX-ENAME->VLA-OBJECT ENT))
  (WHILE T
    (PRINC "\nPRESS ESC TO EXIT...")
    (SETQ DATA (_HIT-TEST (GETPOINT) OBJ))
    (IF
      (SETQ VALUE
		  (VLA-GETTEXT (CAR DATA) (CADR DATA) (CADDR DATA))
	    COL	  (1- (CADDR DATA))
	    ROW	  (CADR DATA)
      )
       (PROGN
	 (SETQ X (CADR (CELLEXTENTS OBJ ROW COL))
	       Y (CADDR (CELLEXTENTS OBJ ROW COL))
	 )
	 (TEST_LAYER LAYER)
	 (COMMAND "RECTANGLE" X Y)
	 (COMMAND "-VIEW" "_WINDOW" VALUE X Y)
       )
    )
  )
  (SB:RESET_VARS)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(DEFUN _HIT-TEST (PT OBJ /)		;VD)
  (SETQ	PT (VLAX-3D-POINT (TRANS PT 1 0))
	VD (VLAX-3D-POINT (TRANS (GETVAR 'VIEWDIR) 1 0))
  )
  (IF (EQ :VLAX-TRUE (VLA-HITTEST OBJ PT VD 'ROW 'COL))
    (LIST OBJ ROW COL)
  )
)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;<------GET TABLE CELL COORDINATES --------->;;;

(DEFUN CELLEXTENTS (OBJ ROW COL / LST RTN)
  (SETQ LST (VLAX-INVOKE OBJ 'GETCELLEXTENTS ROW COL :VLAX-TRUE))
  (REPEAT 4
    (SETQ RTN (CONS (LIST (CAR LST) (CADR LST) (CADDR LST)) RTN)
	  LST (CDDDR LST)
    )
  )
  RTN
)


;;;(DEFUN CELLEXTENTS ( OBJ ROW COL / A B C D LST RTN );USE FOR MERGED CELLS IF SOMETHING GOES SOUTH 
;;;    (IF (= :VLAX-TRUE (VLA-ISMERGEDCELL OBJ ROW COL 'A 'B 'C 'D))
;;;        (SETQ ROW A COL C)
;;;    )
;;;    (SETQ LST (VLAX-INVOKE OBJ 'GETCELLEXTENTS ROW COL :VLAX-TRUE))
;;;    (REPEAT 4 (SETQ RTN (CONS (LIST (CAR LST) (CADR LST) (CADDR LST)) RTN) LST (CDDDR LST)))
;;;    (REVERSE RTN)
;;;)

(DEFUN TEST_LAYER (LAYER)

  (IF
    (TBLSEARCH "LAYER" LAYER)
     (SETVAR "CLAYER" LAYER)
     (COMMAND "_.-LAYER" "_N" LAYER "_COLOR" 16	LAYER "PLOT" "_N" LAYER
	      "")
  )
  (SETVAR "CLAYER" LAYER)
)


(DEFUN SB:GET_VARS ()
  (SETQ	HIGHLIGHT	 (GETVAR "HIGHLIGHT")
	CMDDIA		 (GETVAR "CMDDIA")
	FILEDIA		 (GETVAR "FILEDIA")
	MIRRTEXT	 (GETVAR "MIRRTEXT")
	PICKADD		 (GETVAR "PICKADD")
	PICKAUTO	 (GETVAR "PICKAUTO")
	PICKFIRST	 (GETVAR "PICKFIRST")
	SELECTIONPREVIEW (GETVAR "SELECTIONPREVIEW")
	CMDECHO		 (GETVAR "CMDECHO")
	OSMODE		 (GETVAR "OSMODE")
  )
  (PRINC)
)

(DEFUN SB:RESET_VARS ()
  (SETVAR "HIGHLIGHT" HIGHLIGHT)
  (SETVAR "CMDDIA" CMDDIA)
  (SETVAR "FILEDIA" FILEDIA)
  (SETVAR "MIRRTEXT" MIRRTEXT)
  (SETVAR "PICKADD" PICKADD)
  (SETVAR "PICKAUTO" PICKAUTO)
  (SETVAR "PICKFIRST" PICKFIRST)
  (SETVAR "SELECTIONPREVIEW" SELECTIONPREVIEW)
  (SETVAR "CMDECHO" CMDECHO)
  (SETVAR "OSMODE" OSMODE)
)

This one will let the user select that table then uses the get point to pick inside of the name column, it sets the value of the name and sets the min and max point of the cell containing the block, then it creates a new view with those points that can then be inserted into paper space. 

 

Thanks for helping me get here!

 

0 Likes