Jump to content

Save text in clipboard windows


itacad

Recommended Posts

Hi, I use Lisp to get texts to use outside the Autocad program.
The operation that these lisp perform is to save the text in the windows clipboard.
Strangely, they no longer work, I fear it is due to the evolution that occurred with Windows 11 regarding the clipboard, which now has its own "chronology" (very convenient).
I'll show you one of these lisp and ask you if you have any suggestions to give me or propose alternative solutions?
Thank you in advance

catchattcum.LSP

Link to comment
Share on other sites

This worked for me with Bricscad and WIN 11.

 

(defun c:catchattcum (/ att html result)
 (vl-load-com)
 (setq stringa  "")
 (while (setq att (car (nentsel "\nSeleziona attributo: ")))
  (setq stringa (cdr(assoc 1 (entget att))))
 )
 
 (setq html   (vlax-create-object "htmlfile")
       result (vlax-invoke
	       (vlax-get (vlax-get html 'ParentWindow) 'ClipBoardData)
	       'setData
	       "Text"
	       stringa
	      )
 )
 (vlax-release-object html)
)

 

Link to comment
Share on other sites

Posted (edited)

This is what I have, basically the same thing posted.

 

(vlax-invoke (vlax-get (vlax-get (setq html (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData) 'setData "Text" sText)
(vlax-release-object html) ;release the html bad things could happen

 

another backwards way to do it if the htmlfile still isn't working for you.

Run a power shell to create a text file and output the clipboard with Get-Clipboard to a text file then just read the text file.

 

 

Edited by mhupp
  • Like 1
Link to comment
Share on other sites

(defun c:catchattcum (/ att html result)
 (vl-load-com)
 (setq stringa  "")
 (while (setq att(car(nentsel "\nSeleziona attributo: ")))
  (setq stringa(strcat stringa (cdr(assoc 1 (entget att))) " "))
 )

 (setq html (vlax-create-object "htmlfile"))
 (vlax-release-object html)

(setq stringa (substr stringa 1 (- (strlen stringa) 1)))
 (setq html   (vlax-create-object "htmlfile")
       result (vlax-invoke
	       (vlax-get (vlax-get html 'ParentWindow) 'ClipBoardData)
	       'setData
	       "Text"
	       stringa
	      )
 )
 (vlax-release-object html)
)

 

I don't remember when, I modified my code to do one more creation release before do that.

doesn't this work too?

Link to comment
Share on other sites

Good morning and thank you everyone.

I also tried the latest lisp and did some research but I didn't solve it.

I ask a courtesy: it is possible to modify the lisp so that after having acquired the texts (I hope of any type: text, mtext, attributes value, multileaders, quotas...), instead of trying to save them on the windows clipboard it simply writes them on the Autocad command line?

Thank you in advance

Link to comment
Share on other sites

(princ ....) will write to the command line, so add

 

(princ stringa)
(princ)

 

as the last line. You'll need the last (princ) to 'exit quietly' otherwise it will also report the last thing it does.. so the sting gets printed twice.. add the (princ) to get it only once

Link to comment
Share on other sites

Thank you all, I apologize and humbly ask if you can explain to me step by step how to modify lisp

 

Link to comment
Share on other sites

Try

 

(setq stringa  "")
(while (setq att (car (nentsel "\nSeleziona attributo: ")))
  (setq stringa (strcat stringa (cdr (assoc 1 (entget att))) " "))
)
(princ (strcat "\n" stringa)) ; command line

(alert stringa) ; message box

 

Link to comment
Share on other sites

Oh thanks! unfortunately, however, displaying it on a message box does not allow me to copy the text (or can it be done somehow?).
I need to copy the selected text to paste it into other programs.
Is it possible to display it on the status bar instead of a message box?
Or is it possible to view it in a type of window that allows text selection?

 

Thank you in advance

 

(defun c:catchattcum2 (/ att html result)
 (vl-load-com)
 (setq stringa  "")
(while (setq att (car (nentsel "\nSeleziona attributo: ")))
  (setq stringa (strcat stringa (cdr (assoc 1 (entget att))) " "))
)
(princ (strcat "\n" stringa)) ; command line

(alert stringa) ; message box
)

 

Link to comment
Share on other sites

Not sure if you can operate notepad like this but you could write the text to a temporary text file, open the file and copy / paste from there. Only thing I don't know is if you can automate the copy from notepad?

Link to comment
Share on other sites

Posted (edited)

Look at post 2

 

(while (setq att (car (nentsel "\nSeleziona attributo: ")))
  (setq stringa (cdr (assoc 1 (entget att))))
  (princ (strcat "\n" stringa))
)

 

Edited by BIGAL
Link to comment
Share on other sites

Hi Bigal, I tried the code in post n.2 but it gives me an error message

; errore: argomenti mancanti

 

For Steven P:

I have no problem transiting through text files etc., but after executing the lisp that I posted on Saturday 05/11/2024, I don't have the text available to be able to manipulate it, all I need is for it to be written on the command line instead of a messagebox

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