Jump to content

Copy text in sequence to a table cells


joemcanciller

Recommended Posts

Hello guys, I'm here again asking for help to this routine. I want to copy the text in the leader and paste it on the table cells in this manner (See photos):

1. pick leader with text

2. select cell 1 to paste the first line of text with.

3. select cell 2 to paste the second line of text with.

4. select cell 3 to paste the third line of text with.

and so on and so forth.

PIC1.JPG.7d18563544a73a1eb156d59676bdcc0a.JPG 

PIC2.thumb.JPG.744f8a0fa3db31b40c445de23d9c1d9b.JPG

 

 

 

I have this code in mleader, i dont know if it will help. This leader comes from combination of block attributes and dimension entities.

(defun gav ( blk tag / val enx )
    (while
        (and
            (null val)
            (setq blk (entnext blk))
            (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk)))))
        )
        (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
            (setq val (cdr (assoc 1 (reverse enx))))
        )
    )
)

(defun c:pp()
	(setq obj (car(entsel "\nSelect Object: ")))
	(setq dim1(entget (car(entsel "\nSelect Dimension: "))))
	(setq dimval1(cdr (assoc 42 dim1)))
	(setq d (strcat (rtos dimval1 2 2)))
	(setq dim2(entget (car(entsel "\nSelect Dimension: "))))
	(setq dimval2(cdr (assoc 42 dim2)))
	(setq e (strcat (rtos dimval2 2 2)))
	(setq c (gav obj "LWI-0000"))
	(setq b (gav obj "CL"))
	(setq a (cdr(assoc 2 (entget obj))))
	(setq txt (strcat a "\n" b "\n" c "\n" d "\n" e))
	(setvar "cmleaderstyle" "PP")
	(command "_mleader" pause pause txt "")

)

BTW. I used the getattributevalue for block entities created by @Lee Mac. Thanks to this. It really helped me a lot.

 

Thanks in advance. :)

 

PS: Please do it as simple as my code. Im new learning this lisp thing. Thanks ^^. hehe

Link to comment
Share on other sites

If you look at Lee Macs Copy or Swap text which might give you a start ( http://www.lee-mac.com/copytext.html )

 

Using it, if you create your table and complete each row with something (for example a '.' or a '-'), copy the multileader and explode the text twice (to give just plain text, not mtext) and then use Lees Copy Text selecting each line of text from the copied-and-exploded multileader and put into the appropriate table cell.

 

Someone will be cleverer than me and work out how to split up the multileader text into individual lines and paste them where you want, but this LISP might help you on your way

Link to comment
Share on other sites

1 hour ago, Steven P said:

If you look at Lee Macs Copy or Swap text which might give you a start ( http://www.lee-mac.com/copytext.html )

 

Using it, if you create your table and complete each row with something (for example a '.' or a '-'), copy the multileader and explode the text twice (to give just plain text, not mtext) and then use Lees Copy Text selecting each line of text from the copied-and-exploded multileader and put into the appropriate table cell.

 

Someone will be cleverer than me and work out how to split up the multileader text into individual lines and paste them where you want, but this LISP might help you on your way

thanks @Steven P. That would be possible, but it takes time to click back and forth. Maybe my last resort. hehe

Link to comment
Share on other sites

Btw. I used data extraction. But it gives me this since it only have 1 content. PIC3.thumb.JPG.df14f1fa0d0571e0a3d449980626d1bd.JPG

 

Is it possible to break it as individual content to have distinct cells for each content? Thanks. :)

Link to comment
Share on other sites

You could have a look at this - its not perfect and you might need to add things like checking you select text but it sort of works on my machine here.

 

Also you need to get Lee Macs String to List routing ( LM:str->lst ) and put that in the same file

(defun c:splitmtexts( /  mytxt txtlst txtlen acount newtxt)
;;add in here check if you hit a text or not
  (setq mytext (vla-get-TextString(vlax-ename->vla-object (car (entsel)))))
  (setq txtlst (LM:str->lst mytext "\\P"))
  (setq txtlen (length txtlst))
  (setq acount 0)
  (princ txtlst)

;;write to table items
  (while ( < acount txtlen)
    (setq newtxt (nth acount txtlst))
    (setq ent (car (nentsel "\nSelect Table Text Letter:")))
    (setq entlst (entget ent))
;;check here if you hit text object
    (setq entlst (subst (cons 1 newtxt) (assoc 1 entlst) entlst))
    (entmod entlst)
    (entupd ent)
    (princ newtxt)
    (setq acount (+ 1 acount))
  )

(princ)
)

 

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...