Jump to content

Please help!! Mutiple selection (Text or Mtext) copy to table cell....


Sinabro

Recommended Posts

I am looking for an LSP file for multiple selections to copy into table cells.

For example: If I have two separate texts, '851' and 'Davidson RD", can I use a command to pick '851' and 'Davidson Rd' and automatically fill up a table cell? after click cell?

Does anyone have any ideas? Please help and provide the lsp file...

 

image.png.2064c0cefee9f3065d71a050440f49e9.png

Link to comment
Share on other sites

Is there a routine that anyone knows of that allows picking a single piece of TEXT/MTEXT and having it copied to a Table Cell?

Something that someone has come across in their travels?

 

image.thumb.png.49d8deb2e9a9742941c991a82844f7ec.png
 

Years ago I came across some code that APPEARED to work on screen, but a regen revealed the text was not truly in the table.
Need to see if I can find it in case it can be fixed.

Edited by ILoveMadoka
Link to comment
Share on other sites

The author of Lisp is koMon

Select the TEXT (MTEXT, MULTILEADER) and paste the field into a table cell.

 

mltxt_cell.lsp

 

tabl-cell.png

Edited by Nikon
Link to comment
Share on other sites

Export the texts to a *.CSV file and open it in Excel.  Edit, format the worksheet as you like and save the file. Return in AutoCAD, create a data-link to the excel file. AutoCAD will draw the table for you.

Link to comment
Share on other sites

Fuccaro,

I do something like that now.
Looking to see if there was a lisp that lets me pick.

 

It's not just one one or two lines.

never hurts to ask...
 
 

Link to comment
Share on other sites

1st step is lee-mac has a pick cell that returns the row column of the cell which is what you need. 

 

Then its easy to, (setcelltext objtable row column text)

 

So pick a start cell, then  run inside a while for multiple rows to be filled in.

 

pick cell in table.lsp

Link to comment
Share on other sites

 LISP Lee Mac CopySwapTextV1-8.lsp   https://lee-mac.com/copytext.html 

To copy text, the program may be called with ctx at the AutoCAD command line. The user may then select either a Text, MText, Attribute, Dimension, Table Cell, or Multileader object and proceed to copy the associated text content to a selection of any of the aforementioned objects.

 

 

Edited by Nikon
Link to comment
Share on other sites

A bit on the longer side, but maybe this:

 

(defun c:fo ( / a c dir ent i pt r ss sstb txt)
    (cond
        (   (not 
                (setq sstb
                    (ssget "_X"
                        (append
                            (list 
                                '(0 . "ACAD_TABLE")
                                '(-4 . "<OR")
                            )
                            (mapcar
                                '(lambda (a)
                                    (cons 8 (LM:escapewildcards a))
                                )
                                (JH:GetLockedFrozenOffLayers nil nil nil nil)
                            )
                            (list
                                '(-4 . "OR>")
                                (cons 410 (if (= (getvar "cvport") 1) (getvar "ctab") "Model"))
                            )
                        )
                    )
                )
            )
            (princ (if (= (getvar "cvport") 1) "\nNo tables in current paper space." "\nNo tables in model space."))
        )
        (   (not (setq ss (ssget '((0 . "TEXT,MTEXT"))))))
        (   (setq sstb (JH:selset-to-list-vla sstb))
            (repeat 
                (setq i (sslength ss)) 
                (setq i   (1- i)
                      ent (ssname ss i)
                      txt (cons (vla-get-TextString (vlax-ename->vla-object ent)) txt)
                )
            )
            (setq txt (LM:lst->str txt " "))
            (while
                (progn
                    (setvar "errno" 0)
                    (initget "Exit")
                    (setq pt (getpoint "\nSpecify table cell [Exit] <exit>: "))
                    (cond
                        (   (= (getvar "errno") 7) (princ "\nNothing selected."))
                        (   (member pt '("Exit" nil)) nil)
                        (   (progn
                                (setq pt (vlax-3d-point (trans pt 1 0)) dir (vlax-3d-point (getvar "viewdir")))
                                (vl-some
                                    (function
                                        (lambda (a)
                                            (if (eq (vla-hittest a pt dir 'r 'c) :vlax-true)
                                                (progn 
                                                    (if 
                                                        (not (zerop (logand accellstatecontentlocked (vla-getcellstate a r c))))
                                                        (princ "\nTable cell is locked.")
                                                        (vla-settext a r c txt)
                                                    )
                                                    t
                                                )
                                            )
                                        )
                                    )
                                    sstb
                                )
                            )
                        )
                        (   (princ "\nNo table cell detected."))
                    )
                )
            )
        )
    )
)

;; JH:GetLockedFrozenLayers --> Jonathan Handojo
;; Gets a list of layers that are locked and/or frozen.
;; lck - T to get locked layers, nil to get unlocked layers
;; frz - T to get frozen layers, nil to get thawed layers
;; off - T to get 'off' layers, nil to get 'on' layers
;; xref - T to include xref, nil to exclude xref

(defun JH:GetLockedFrozenOffLayers (lck frz off xref / nm nx rtn) 
    (while (setq nx (tblnext "layer" (null nx))) 
        (setq nm (cdr (assoc 2 nx)))
        (if (not (and (not xref) (wcmatch nm "*|*"))) 
            (if 
                (and 
                    (or 
                        (and lck (= 4 (logand 4 (cdr (assoc 70 nx)))))
                        (and (not lck) (zerop (logand 4 (cdr (assoc 70 nx)))))
                    )
                    (or 
                        (and frz (= 1 (logand 1 (cdr (assoc 70 nx)))))
                        (and (not frz) (zerop (logand 1 (cdr (assoc 70 nx)))))
                    )
                    (or 
                        (and off (minusp (cdr (assoc 62 nx))))
                        (and (not off) (> (cdr (assoc 62 nx)) 0))
                    )
                )
                (setq rtn (cons nm rtn))
            )
        )
    )
    (reverse rtn)
)

;; JH:selset-to-list-vla --> Jonathan Handojo
;; Returns a list of vla objects from a selection set
;; ss - selection set

(defun JH:selset-to-list-vla (ss / rtn i)
    (if ss
        (repeat (setq i (sslength ss))
            (setq rtn (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) rtn))
        )
    )
)

;; Escape Wildcards  -  Lee Mac
;; Escapes wildcard special characters in a supplied string

(defun LM:escapewildcards ( str )
    (vl-list->string
        (apply 'append
            (mapcar
               '(lambda ( c )
                    (if (member c '(35 64 46 42 63 126 91 93 45 44))
                        (list 96 c)
                        (list c)
                    )
                )
                (vl-string->list str)
            )
        )
    )
)

;; List to String  -  Lee Mac
;; Concatenates each string in a supplied list, separated by a given delimiter
;; lst - [lst] List of strings to concatenate
;; del - [str] Delimiter string to separate each item

(defun LM:lst->str ( lst del / str )
    (setq str (car lst))
    (foreach itm (cdr lst) (setq str (strcat str del itm)))
    str
)

 

The selected text will be concatenated together, using spaces. You may need to select the text by picking instead of window or crossing to get the text in order.

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...