Jump to content

Recommended Posts

Posted

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

Posted

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)

Posted
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!

Posted
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?

Posted
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)

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