Copy field to clipboard

Copy field to clipboard

msarqui
Collaborator Collaborator
1,404 Views
5 Replies
Message 1 of 6

Copy field to clipboard

msarqui
Collaborator
Collaborator

Hi guys,

I am trying to adapt  gpcattaneo code but I am having no lucky.

I am trying to copy the field within a Text to the clipboard, to paste it latter in another text without losing the data.

 

(defun c:CopyFieldToClipboard ()
(vlax-invoke
(vlax-get (vlax-get (vlax-create-object "htmlfile") 'ParentWindow) 'ClipBoardData)
'setData
"TEXT"
;(getvar 'dwgname);this was the original code
(entsel "\nSelect Text with Field: ");this is what I tried
)
);defun

 ; error: unsupported argument type: <Entity name: 7f69d7bf720>

 

Thanks for any help!

0 Likes
Accepted solutions (2)
1,405 Views
5 Replies
Replies (5)
Message 2 of 6

gpcattaneo
Advocate
Advocate
Accepted solution

Try this:

(cdr (assoc 1 (entget (car (entsel "\nSelect Text with Field:")))))

0 Likes
Message 3 of 6

msarqui
Collaborator
Collaborator

Hi gpcattaneo 

 

Thanks for the answer!

It works but this made me reconsider... could be a way to keep the field (not just its value) when I paste it in the second text?

Like if I use DDEDIT to open the text editor, Ctrl+c to copy the field and then paste it. Like that, the link will be still there.

 

0 Likes
Message 4 of 6

msarqui
Collaborator
Collaborator

Nevermind... I  found a way.

Thanks!

0 Likes
Message 5 of 6

gpcattaneo
Advocate
Advocate
Accepted solution

@msarqui wrote:

...I  found a way.


This?

(vla-fieldcode (vlax-ename->vla-object (car (entsel))))

 Smiley Wink 

0 Likes
Message 6 of 6

msarqui
Collaborator
Collaborator

Exactly! Thanks for your help. 🙂

0 Likes