Jump to content

Are there a way copy and paste via clipboard by lisp?


hosyn

Recommended Posts

Posted

it's possible ctrl-x and ctrl-y embed in lisp routine and how?:?

Posted
(Defun c:Democopy (/ string 2ClipB)
 (vl-load-com)
 (if (setq string (ssget "_:S" '((0 . "TEXT"))))
   (progn
     (vlax-invoke
(vlax-get
  (vlax-get (setq 2ClipB (vlax-create-object "htmlfile"))
	    'ParentWindow
  )
  'ClipBoardData
)
'SetData
"Text"
(cdr (assoc 1 (entget (ssname string 0))))
     )
     (vlax-release-object 2ClipB)
   )
 )
)


(Defun c:Demopaste (/ string 2ClipB txtstring)
 (vl-load-com)
 (if (setq string (ssget "_:S" '((0 . "TEXT"))))
   (progn
     (setq
txtstring (vlax-invoke
	    (vlax-get
	      (vlax-get
		(setq 2ClipB (vlax-create-object "htmlfile"))
		'ParentWindow
	      )
	      'ClipBoardData
	    )
	    'GetData
	    "Text"
	  )
     )
     (vla-put-textstring
(vlax-ename->vla-object (ssname string 0))
txtstring
     )
     (vlax-release-object 2ClipB)
   )
 )
)

Posted

pBe

It sounds your routine specially for text ,are there for any entity??:unsure:

Posted
It sounds your routine specially for text ,are there for any entity??:unsure:

 

Try the CUTCLIP / PASTECLIP commands.

Posted

Thanxxxx Mr LEE MAC:)

I try

(command "copyclip" )

And i don't know what's difference between (command "copyclip" ) and (command "_copyclip" ) and (command ".copyclip" ) and (command "._copyclip" ) ???

and which one is better and why??

Posted
pBe

It sounds your routine specially for text ,are there for any entity??:unsure:

 

Oops my bad.

  • 6 months later...
Posted

Thank you pBe : but how to select mutable text rather than one entity selection??

Thank you

Posted
Thank you pBe : but how to select mutable text rather than one entity selection??

Thank you

 

Are you wanting to concatenate multiple string values into one? what are you planning to do with the results? paste into a text file? or for a text/mtext entity string value?

Posted

Hi

i want to select all text and copy their values to clipboard and paste to excel

thank you very much

Posted
Hi

i want to select all text and copy their values to clipboard and paste to excel

thank you very much

 

ALL text? in what format? one word or phrase per cell? this is very intriguing, post a cad file and a Excel file which shows the result you want

  • 8 years later...
Posted

image.png.2c0d3d1eb58eabf5903b846594c37fef.png

text cad file 

I want to select all text and copy their values to clipboard and paste to excel

image.png.7192eeaa14eeba466027431435ca674a.png

 

Posted (edited)

Did you google ? Uses sort on Y so knows the order for excel, I think the example code solution was for multi line text and mtext. May have been Forums/Autodesk.

Edited by BIGAL
  • Like 1
  • 1 year later...
Posted
On 7/22/2014 at 5:40 AM, pBe said:
(Defun c:Democopy (/ string 2ClipB)
 (vl-load-com)
 (if (setq string (ssget "_:S" '((0 . "TEXT"))))
   (progn
     (vlax-invoke
(vlax-get
  (vlax-get (setq 2ClipB (vlax-create-object "htmlfile"))
	    'ParentWindow
  )
  'ClipBoardData
)
'SetData
"Text"
(cdr (assoc 1 (entget (ssname string 0))))
     )
     (vlax-release-object 2ClipB)
   )
 )
)


(Defun c:Demopaste (/ string 2ClipB txtstring)
 (vl-load-com)
 (if (setq string (ssget "_:S" '((0 . "TEXT"))))
   (progn
     (setq
txtstring (vlax-invoke
	    (vlax-get
	      (vlax-get
		(setq 2ClipB (vlax-create-object "htmlfile"))
		'ParentWindow
	      )
	      'ClipBoardData
	    )
	    'GetData
	    "Text"
	  )
     )
     (vla-put-textstring
(vlax-ename->vla-object (ssname string 0))
txtstring
     )
     (vlax-release-object 2ClipB)
   )
 )
)
 

 

(Defun c:AClip (/ 2ClipB enam elst objid ss ent1 fldexp1 fldexp2 pt)
 (vl-load-com)
   	(while (null (setq enam (car (nentsel "\nSelect LWPOLYLINE or HATCH: "))))
		(princ "Nothing Selected")
	);while
	
	(setq elst (entget enam))
	
	(if (or 
		(= (cdr (assoc 0 elst)) "LWPOLYLINE") (= (cdr (assoc 0 elst)) "HATCH") (= (cdr (assoc 0 elst)) "AECC_TIN_SURFACE"))
		(progn
			(setq objid (vla-get-ObjectId (vlax-ename->vla-object enam)))
			(setq ent1 "%lu2%pr0%ps[, sf]%th44")
			(setq fldexp1 (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa objid) ">%).Area " (chr 92)"f " (chr 34) ent1 (chr 34) ">%"))
			(setq ent1 "%lu2%pr3%ps[, ac]%ct8[2.295684113865930E-005]%th44")
			(setq fldexp2 (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa objid) ">%).Area " (chr 92)"f " (chr 34) ent1 (chr 34) ">%"))
			(setq fldexp1 (strcat fldexp1 " " (chr 40) fldexp2 (chr 41)))
			(setvar "cmdecho" 0)
			(vlax-invoke
				(vlax-get
					(vlax-get (setq 2ClipB (vlax-create-object "htmlfile"))
					'ParentWindow
					)
					'ClipBoardData
				)
				'SetData
				"Text"
				(strcat fldexp1)
			)
			(vlax-release-object 2ClipB)
			(setvar "cmdecho" 1)			
		)
		(princ "\nSelected Entity is Not a LWPOLYLINE or HATCH.")
	);If

	(setq 	
		2ClipB nil
		enam nil
		elst nil
		ent1 nil
		objid nil
		ss nil
		fldexp1 nil
		fldexp2 nil
		pt nil)
	(gc)
	(princ)
);AClip

 

Just giving back. 

I altered pBe's lisp to build INSERT FIELDs for either selected LWPOLYLINE or HATCH object and add those to the clipboard.  A paste action will make an MTEXT object with area formatted as both acres and sq. ft.

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