Cell contents to Mtext (small steps for a bigger project)

Cell contents to Mtext (small steps for a bigger project)

christine_caga-anan
Explorer Explorer
687 Views
9 Replies
Message 1 of 10

Cell contents to Mtext (small steps for a bigger project)

christine_caga-anan
Explorer
Explorer

Hi everyone, I am new to using LISP, and I can't find a lisp file that works on my end. 

I just want to create a lisp that can automate my workflow. It is a bit complex automation but I want to start first by getting the content of a selected cell and then changing the mtext's content with the copied value.  Hope that you guys/girls can help me with this. Thank you

0 Likes
688 Views
9 Replies
Replies (9)
Message 2 of 10

komondormrex
Mentor
Mentor

hey, 

which mtext exactly? 

0 Likes
Message 3 of 10

pbejse
Mentor
Mentor

@christine_caga-anan wrote:

... but I want to start first by getting the content of a selected cell and then changing the mtext's content with the copied value.  


Hi @christine_caga-anan Welcome to this forum.

 

Are you referring to ACAD_TABLE object? what is the source of the "copied value"?

 

0 Likes
Message 4 of 10

h_s_walker
Mentor
Mentor

Here is the OPs original post in the LT forums. Please note that she only uses LT, so no commands which don't work in LT please.

Solved: Visual LISP, AutoLISP and General Customization - Autodesk Community - AutoCAD LT

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 5 of 10

pbejse
Mentor
Mentor

@h_s_walker wrote:

Here is the OPs original post in the LT forums. Please note that she only uses LT, so no commands which don't work in LT please.


Good to know that bit information @h_s_walker , thanks

@christine_caga-anan  Is it an ACAD_TABLE where you're referring to  cell?

 

0 Likes
Message 6 of 10

christine_caga-anan
Explorer
Explorer

Yes, for the first step, I would like to use the Acad Table cell content, then copy that content to an Mtext by running a lisp, 

 

My goal here is to link that acad table to a datalink (excel) and use the contents of the cell to select the visibility states of a specific block that is also on the acad table. (hope you could picture what's goal)

0 Likes
Message 7 of 10

christine_caga-anan
Explorer
Explorer

Yes, for the first step, I would like to use the Acad Table cell content, then copy that content to an Mtext by running a lisp

0 Likes
Message 8 of 10

christine_caga-anan
Explorer
Explorer

Hi Komodormrex,

My goal here is to link that acad table to a datalink (excel) and use the contents of the cell to select the visibility states of a specific block that is also on the acad table. (hope you could picture what's goal)

but for now, I would like to copy first a value/text from a cell (acad table) then use that to change the content of an Mtext.

 

0 Likes
Message 9 of 10

Sea-Haven
Mentor
Mentor

Ok 1st for clarification you have access to LISP, so LT 2024 at least. 

 

A function called Hit test it reads a cell in a table by just clicking inside the table cell. 

 

;; Example shows how to pick a single table cell on screen and change its value.
;; This example demonstrates the ActiveX properties/methods HitTest,
;; GetCellType, GetText and SetText.
(defun SelectTableCell ( / pick vHeight vWidth lwrLeft uprRight vector
                                           SS_TABLES cnt eMax  cellValueOrg)
  
  ;; Ask the user for a point on screen
  (if (/= (setq pick (vlax-3d-point (getpoint "\nSelect Cell to START sum from: "))) nil)
    (progn

      ;; Get the corners of the screen display to build our selection set
      (setq vHeight (getvar "viewsize"))
      (setq vWidth (* (/ (nth 0 (getvar "screensize")) (nth 1 (getvar "screensize"))) vHeight))

      (setq lwrLeft (list (- (nth 0 (getvar "viewctr")) (/ vWidth 2)) (- (nth 1 (getvar "viewctr")) (/ vHeight  2)) 0))
      (setq uprRight (list (+ (nth 0 (getvar "viewctr")) (/ vWidth 2)) (+ (nth 1 (getvar "viewctr")) (/ vHeight  2)) 0))

      ;; Get the current display orientation
      (setq vector (vlax-make-safearray vlax-vbDouble '(0 . 2)))
      (vlax-safearray-fill vector '(1 1 1))
      (setq vector (vlax-make-variant vector))
      
      ;; Select all the table objects visible on screen
      (if (setq SS_TABLES (ssget "C" lwrleft uprright (list (cons 0 "ACAD_TABLE"))))
        (progn
   
          (setq cnt 0
                eMax (sslength SS_TABLES)
          )

          ;; Step through all the items in the selection set
          (while (> eMax cnt) 
            ;; Geta table object from the selection set
            (setq tableObj (vlax-ename->vla-object (ssname SS_TABLES cnt)))
  
            ;; Return values for what cell was picked in
            (setq row 0
                  col 0)

            ;; Below is also a sample to see if a valid cell is picked
            ;; (vla-select table pick vector vector 5 5 :vlax-false 'row 'col)
     
            ;; Check to see if a valid cell was picked
            (if (= (vla-hittest tableObj pick vector 'row 'col) :vlax-true)
              (progn

                ;; Get out of the loop
                (setq cnt (1+ eMax))
  
                ;; Check to see what the Cell Type is (Text or Block)
                (if (= (vla-GetCellType tableObj row col) acTextCell)
                                    ;; Let's get the value out exit with row - col 
                    (setq cnt eMax)
                 )
              )
            )
            (setq cnt (1+ cnt))
          )
        )
      )
    )
  ) 
 (princ)
) ; defun
0 Likes
Message 10 of 10

christine_caga-anan
Explorer
Explorer

Thanks Sea-haven, I will look into that hit test. 

0 Likes