ktbjx Posted August 8, 2016 Posted August 8, 2016 is it possible to get the Start X Y Z and End X Y Z of a line to clipboard?? i needed to manually copy the coordinates and say paste it to text file?.. you know? CTRL+V it so somewhere else? because i have this Macro code and i dont know much about lisp on how am i gonna get the XYZ coordinates into clipboard. so that i can use the macro to search the coordinared on extracted excel files can someone help me make a lisp routine to only clipboard the x y z coordinates of a LINE? so i can literally CTRL+V it to anywhere, weather its on excel cells, text, word, anywhere i can use CTRL+V shortcut key.. Quote
BIGAL Posted August 9, 2016 Posted August 9, 2016 1 Try DATAEXTRACTION should do what you want. 2 List select line copy info, but you will get extra info. 3 use a lisp http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/pasteclip-and-copyclip-commands/td-p/3790508 Quote
Lee Mac Posted August 9, 2016 Posted August 9, 2016 Try the following: (defun c:l2c ( / ent ) (if (setq ent (LM:selectifobject "\nSelect line: " "LINE")) (if (LM:copytoclipboard (LM:lst->str (mapcar 'rtos (append (cdr (assoc 10 (entget ent))) (cdr (assoc 11 (entget ent))) ) ) "\t" ) ) (princ "\nLine endpoints copied to clipboard.") ) ) (princ) ) ;; Same method as MP demonstrates here: http://bit.ly/170kacW (defun LM:copytoclipboard ( str / clp htm par rtn ) (if (setq htm (vlax-create-object "htmlfile")) (progn (setq rtn (vl-catch-all-apply '(lambda ( ) (setq par (vlax-get htm 'parentwindow) clp (vlax-get par 'clipboarddata) ) (vlax-invoke clp 'setdata "Text" str) ) ) ) (foreach obj (list clp par htm) (if (= 'vla-object (type obj)) (vlax-release-object obj) ) ) (if (not (vl-catch-all-error-p rtn)) str) ) ) ) ;; Select if Object - Lee Mac ;; Continuously prompts the user for a selection of a specific object type (defun LM:selectifobject ( msg typ / ent ) (while (progn (setvar 'errno 0) (setq ent (car (entsel msg))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil) ( (not (wcmatch (cdr (assoc 0 (entget ent))) typ)) (princ "\nInvalid object selected.") ) ) ) ) ent ) ;; List to String - Lee Mac ;; Concatenates each string in a supplied list, separated by a given delimiter ;; lst - [lst] List of strings to concatenate ;; del - [str] Delimiter string to separate each item (defun LM:lst->str ( lst del ) (if (cdr lst) (strcat (car lst) del (LM:lst->str (cdr lst) del)) (car lst) ) ) (vl-load-com) (princ) Quote
ktbjx Posted August 9, 2016 Author Posted August 9, 2016 Try the following:(defun c:l2c ( / ent ) (if (setq ent (LM:selectifobject "\nSelect line: " "LINE")) (if (LM:copytoclipboard (LM:lst->str (mapcar 'rtos (append (cdr (assoc 10 (entget ent))) (cdr (assoc 11 (entget ent))) ) ) "\t" ) ) (princ "\nLine endpoints copied to clipboard.") ) ) (princ) ) ;; Same method as MP demonstrates here: http://bit.ly/170kacW (defun LM:copytoclipboard ( str / clp htm par rtn ) (if (setq htm (vlax-create-object "htmlfile")) (progn (setq rtn (vl-catch-all-apply '(lambda ( ) (setq par (vlax-get htm 'parentwindow) clp (vlax-get par 'clipboarddata) ) (vlax-invoke clp 'setdata "Text" str) ) ) ) (foreach obj (list clp par htm) (if (= 'vla-object (type obj)) (vlax-release-object obj) ) ) (if (not (vl-catch-all-error-p rtn)) str) ) ) ) ;; Select if Object - Lee Mac ;; Continuously prompts the user for a selection of a specific object type (defun LM:selectifobject ( msg typ / ent ) (while (progn (setvar 'errno 0) (setq ent (car (entsel msg))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil) ( (not (wcmatch (cdr (assoc 0 (entget ent))) typ)) (princ "\nInvalid object selected.") ) ) ) ) ent ) ;; List to String - Lee Mac ;; Concatenates each string in a supplied list, separated by a given delimiter ;; lst - [lst] List of strings to concatenate ;; del - [str] Delimiter string to separate each item (defun LM:lst->str ( lst del ) (if (cdr lst) (strcat (car lst) del (LM:lst->str (cdr lst) del)) (car lst) ) ) (vl-load-com) (princ) EXACTLY WHAT i needed!!!! thank you so much! i can now use this! OMG your genius! Quote
ktbjx Posted August 9, 2016 Author Posted August 9, 2016 You're welcome! sir one question... i cant use the command: "Select P" anymore after selecting the line, how na i change the way i select the line? Quote
Lee Mac Posted August 9, 2016 Posted August 9, 2016 sir one question...i cant use the command: "Select P" anymore after selecting the line, how na i change the way i select the line? Please try the following modified code: (defun c:l2c ( / ent ) (if (or (and (setq ent (ssget "_I" '((0 . "LINE")))) (setq ent (ssname ent 0)) ) (setq ent (LM:selectifobject "\nSelect line: " "LINE")) ) (if (LM:copytoclipboard (LM:lst->str (mapcar 'rtos (append (cdr (assoc 10 (entget ent))) (cdr (assoc 11 (entget ent))) ) ) "\t" ) ) (princ "\nLine endpoints copied to clipboard.") ) ) (princ) ) ;; Same method as MP demonstrates here: http://bit.ly/170kacW (defun LM:copytoclipboard ( str / clp htm par rtn ) (if (setq htm (vlax-create-object "htmlfile")) (progn (setq rtn (vl-catch-all-apply '(lambda ( ) (setq par (vlax-get htm 'parentwindow) clp (vlax-get par 'clipboarddata) ) (vlax-invoke clp 'setdata "Text" str) ) ) ) (foreach obj (list clp par htm) (if (= 'vla-object (type obj)) (vlax-release-object obj) ) ) (if (not (vl-catch-all-error-p rtn)) str) ) ) ) ;; Select if Object - Lee Mac ;; Continuously prompts the user for a selection of a specific object type (defun LM:selectifobject ( msg typ / ent ) (while (progn (setvar 'errno 0) (setq ent (car (entsel msg))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil) ( (not (wcmatch (cdr (assoc 0 (entget ent))) typ)) (princ "\nInvalid object selected.") ) ) ) ) ent ) ;; List to String - Lee Mac ;; Concatenates each string in a supplied list, separated by a given delimiter ;; lst - [lst] List of strings to concatenate ;; del - [str] Delimiter string to separate each item (defun LM:lst->str ( lst del ) (if (cdr lst) (strcat (car lst) del (LM:lst->str (cdr lst) del)) (car lst) ) ) (vl-load-com) (princ) Quote
Recommended Posts
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.