Jump to content

copy/edit text


masterfal

Recommended Posts

^C^C._SELECT;$M=$(if,$(eq,$(getvar,cmdnames),SELECT),_SI;\,(ssget);_SI;\)._COPY;_P;;\\._TEXTEDIT;_L;;

 

Hi All,

 

The simple macro above copies text and then after pasting brings up the edit text box. Is it possible to set this up as a lisp routine so i can set up a shortcut for quick use? Or does anyone have a similar lisp routine they can share? Thanks in advance!

Link to comment
Share on other sites

This should work.

(defun c:pp()
  (setq txt (car (entsel)))
  (cond ((and txt (= (cdr (assoc 0 (entget txt))) "TEXT"))
	 (command "copy" txt "" pause pause)
	 (command "textedit" "L" "")
	 )
	(t "wrong selection"))
  )

It can be improved... 

  • Like 1
Link to comment
Share on other sites

yeh that works good. how can i amend so it includes "MTEXT" also? it works with MTEXT when i change the TEXT to that. i thought adding MTEXT there would add that option but it stops it working properly..  🤔

Link to comment
Share on other sites

The macro copies the Mtext, and then, after pasting, opens the text editor

^C^C_Copy;\;@;\_MTEDIT;_Last

 

Edited by Nikon
Link to comment
Share on other sites

3 minutes ago, Nikon said:

The macro copies the Mtext, and then, after pasting, opens the edit Mtext field
 

^C^C_Copy;\;@;\_MTEDIT;_Last

 

 

yeh the macro i pasted in original post did that as well as working with single line text

i'm trying to work out how to achieve the same via lisp

Link to comment
Share on other sites

On 4/20/2024 at 8:22 AM, masterfal said:

yeh the macro i pasted in original post did that as well as working with single

there is a slight difference between macros for MTEXT...

2024-04-21_08-50-19.png

 

2024-04-21_08-48-27.png

Edited by Nikon
Link to comment
Share on other sites

Fuccaros code tests for text being selected, if you want text OR mtext you need to change the check line:

(cond ((and txt (= (cdr (assoc 0 (entget txt))) "TEXT"))

 

to include (or....)

Untested replace with something like this:

 

(cond ((and txt 
  (or
    (= (cdr (assoc 0 (entget txt))) "TEXT")
    (= (cdr (assoc 0 (entget txt))) "MTEXT")
  ) ; endor
 ) ; end and

 

  • Like 1
Link to comment
Share on other sites

I wrote the Lisp above to deal with texts according to OP's request. So the program checks first if there is anything selected, next it looks for the type of the selected entity.

Yes, you can expand that second check by adding some ORs, or you could use wildcards.

Another option could be to skip all these checks. Of course, in this case it is the user's responsibility to make correct selections.

  • Like 1
Link to comment
Share on other sites

i tweaked the code to include the (or...) as per Steven P suggestion and now it works perfect 👍

thanks for the help guys. much appreciated

  • Like 1
Link to comment
Share on other sites

another way as fuccaro stated using wildcards:

(cond ((and txt (wcmatch (cdr (assoc 0 (entget txt))) "TEXT,MTEXT"))

 

  • Like 1
Link to comment
Share on other sites

There are many ways to skin this cat :)

(cond ((and txt (wcmatch (cdr (assoc 0 (entget txt))) "*TEXT"))

also works.

  • Like 2
Link to comment
Share on other sites

If you replace this string 

(command "textedit" "L" "")

with

(command "MTEDIT" "L" "")

a copy of the mtext in the editor will be highlighted

(defun c:cpMTedit()
 (setq txt (car (entsel)))
(cond ((and txt (wcmatch (cdr (assoc 0 (entget txt))) "*TEXT"))
 (command "copy" txt "" pause pause)
;; (command "textedit" "L" "")
 (command "MTEDIT" "L" "")
 )
 (t "wrong selection"))
(princ)
 )

But it doesn't work for text

Edited by Nikon
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...