Copy distance values to past into excel

Copy distance values to past into excel

justinariem
Explorer Explorer
1,100 Views
7 Replies
Message 1 of 8

Copy distance values to past into excel

justinariem
Explorer
Explorer

How do I automatically copy the value when I use the command distance in autocad into Windows clipboard to paste into excel? 

0 Likes
Accepted solutions (1)
1,101 Views
7 Replies
Replies (7)
Message 2 of 8

pbejse
Mentor
Mentor

@justinariem wrote:

How do I automatically copy the value when I use the command distance in autocad into Windows clipboard to paste into excel? 


With the use of command Reactors

 

(if (not *DistToClip*)
    (setq *DistToClip*
	 (vlr-command-reactor
	   "To ClipBoard"
	   '((:vlr-commandEnded . callback:commandendedCancelled)
	     (:vlr-commandCancelled . callback:commandendedCancelled)
	    )
	 )
     )
)
(defun callback:commandendedCancelled (Rea Cmd /)
	(if (= (Car Cmd) "MEASUREGEOM")
		(progn
			(vlax-invoke
			  (vlax-get
			    (vlax-get (setq 2ClipB (vlax-create-object "htmlfile"))
				      'ParentWindow
			    ) 'ClipBoardData )  'SetData "Text" (rtos (getvar "distance") 2 )
			)
			(vlax-release-object 2ClipB)
			)
	  	)
  )

 

HTH

 

0 Likes
Message 3 of 8

justinariem
Explorer
Explorer

Hi, thanks for the response. I'm a beginner when it comes to these codes. How do I use this? I tried pasting it on the command line then typing Reactors.  nothing happened. Thanks

0 Likes
Message 4 of 8

andkal
Collaborator
Collaborator
Accepted solution

Here is a plugin for autocad for this (MSI installation file)

https://apps.autodesk.com/ACD/pl/Detail/Index?id=5859464488561915200&appLang=en&os=Win32_64

 

and here newer version (plain FAS faile):
http://autolisps.blogspot.com/p/sumarea-sumlen-toclipboard_2.html


• www.autolisps.blogspot.com - Productivity plugins for Autocad and Autocad MEP
• Autodesk AppStore
0 Likes
Message 5 of 8

pbejse
Mentor
Mentor

Load the attached file or inlcude it on your startapp suite | acaddoc.lsp or whatever you have setup for autoloading

 

HTH

 

0 Likes
Message 6 of 8

justinariem
Explorer
Explorer

I tried loading it but the values does not copy to the windows clipboard to paste into excel

0 Likes
Message 7 of 8

pbejse
Mentor
Mentor

@justinariem wrote:

I tried loading it but the values does not copy to the windows clipboard to paste into excel


All you need to do is load the file.

 

You wanted a command that will work whenever you use the Autocad "Distance" command. and thats what you get. 

Unless you wanted it to call an entirely differrent command then you should have stated that from your first post.

 

Anyway, no point in explaining to you how it works then 

😊

 

BTW: I'm attaching the corrected lisp here

 

 

0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor

A simplified example version pick two points. Credit to Pbe though.

 

 

(defun c:test ( / dist)
(setq dist (distance (getpoint "\nPick p1")(getpoint "\nPick p2")))
(vlax-invoke
	(vlax-get
		(vlax-get (setq 2ClipB (vlax-create-object "htmlfile"))
			'ParentWindow
		) 'ClipBoardData )  'SetData "Text" (rtos dist 2 2)
	)
)

 

0 Likes