Jump to content

Extract XYZ values from multiple blocks


justindm

Recommended Posts

  • Replies 39
  • Created
  • Last Reply

Top Posters In This Topic

  • Tharwat

    12

  • alanjt

    6

  • Lee Mac

    5

  • symoin

    5

Top Posters In This Topic

Posted Images

Make sure the VLIDE isn't inserting tabs into your code:

 

Tools » Environment Options » Visual LISP Formatting Options » (uncheck) Insert Tabs

 

Thanks Lee .

 

That's right , it was checked. so I released it .

 

What is the problem that may cause for the others when they copy and paste codes in their Vlide editors ? Would codes get far from eachothers ?

 

I am still wonder why !

 

Thanks

Link to comment
Share on other sites

@Tharwat - yours works awesome! much simpler than the eattext (and much less filling :lol:)

 

Is there a way to specify the location of the output file? Or just to the same place as the dwg location?

Link to comment
Share on other sites

@Tharwat - yours works awesome! much simpler than the eattext (and much less filling :lol:)

 

Is there a way to specify the location of the output file? Or just to the same place as the dwg location?

 

You're welcome .

 

Here is one according to your request.

 

(defun c:THex (/ dir fNme ss)
 ; THARWAT 2010  
(if (and  (setq dir (getvar 'dwgprefix))
          (setq fNme (open (strcat dir "Block-coordinates.txt" ) "w"))
          (setq ss (ssget "_:L" '((0 . "INSERT"))))
        )
   (
    (lambda (i / ss1 e pt1 )
      (while
   (setq ss1
          (ssname ss (setq i (1+ i))))
     (setq e
        (entget ss1))
           (setq pt1
          (cdr (assoc 10 e)))
            
   (write-line
     (strcat  (rtos (car pt1) 2)
             "," (rtos (cadr pt1) 2)
                 ","  (rtos (caddr pt1) 2))
     fNme)
         )
      )
     -1
     )
  (princ)
  )
   (close fNme)
 (princ "\n Written by Tharwat")
 (princ)
 )

 

Enjoy. :)

Tharwat

Link to comment
Share on other sites

  • 6 years later...
You're welcome .

 

Here is one according to your request.

 

(defun c:THex (/ dir fNme ss)
 ; THARWAT 2010  
(if (and  (setq dir (getvar 'dwgprefix))
          (setq fNme (open (strcat dir "Block-coordinates.txt" ) "w"))
          (setq ss (ssget "_:L" '((0 . "INSERT"))))
        )
   (
    (lambda (i / ss1 e pt1 )
      (while
   (setq ss1
          (ssname ss (setq i (1+ i))))
     (setq e
        (entget ss1))
           (setq pt1
          (cdr (assoc 10 e)))
            
   (write-line
     (strcat  (rtos (car pt1) 2)
             "," (rtos (cadr pt1) 2)
                 ","  (rtos (caddr pt1) 2))
     fNme)
         )
      )
     -1
     )
  (princ)
  )
   (close fNme)
 (princ "\n Written by Tharwat")
 (princ)
 )

 

Enjoy. :)

Tharwat

 

Thanks for this beautiful code....

Could you please modify to include the layer of the block (layer on which it is inserted)

Link to comment
Share on other sites

Thanks for this beautiful code....

Thank you.

 

Could you please modify to include the layer of the block (layer on which it is inserted)

Can you show how it should look like in the txt file to allow me to modify the codes with one shot if possible?

Link to comment
Share on other sites

blk-details.jpg

 

Please find the attached it has Pointid or Sl. No, Easting, Northing, Elevation and Code.

Some can like this even without the Sl.No. will be great.

Thanks.

Link to comment
Share on other sites

(defun c:Test (/ sel dir fil int ent get pnt)
 ;; Tharwat - Date: 03.Aug.2017	;;
 (if (and (setq sel (ssget "_:L" '((0 . "INSERT"))))
          (setq int -1
                dir (getvar 'dwgprefix))
          (setq fil (open (strcat dir "Block-coordinates.txt") "w"))
          )
   (while (setq ent (ssname sel (setq int (1+ int))))
        (setq get (entget ent)
              pnt (cdr (assoc 10 get))
              )
     (write-line (strcat (rtos (car pnt) 2) "," (rtos (cadr pnt) 2) "," (rtos (caddr pnt) 2) "," (cdr (assoc 8 get))) fil)
     )
   )
 (if fil (close fil))
 (princ)
 )

Link to comment
Share on other sites

(defun c:Test (/ sel dir fil int ent get pnt)
 ;; Tharwat - Date: 03.Aug.2017	;;
 (if (and (setq sel (ssget "_:L" '((0 . "INSERT"))))
          (setq int -1
                dir (getvar 'dwgprefix))
          (setq fil (open (strcat dir "Block-coordinates.txt") "w"))
          )
   (while (setq ent (ssname sel (setq int (1+ int))))
        (setq get (entget ent)
              pnt (cdr (assoc 10 get))
              )
     (write-line (strcat (rtos (car pnt) 2) "," (rtos (cadr pnt) 2) "," (rtos (caddr pnt) 2) "," (cdr (assoc 8 get))) fil)
     )
   )
 (if fil (close fil))
 (princ)
 )

 

Firstly I apologize for the delay and Then thanks for this code.

This works exactly as required but only one issue is its creating the list in reverse order. (newer first and older last). Can it be reversed to older first and newest last.

 

Thanks

Link to comment
Share on other sites

Firstly I apologize for the delay and Then thanks for this code.

This works exactly as required but only one issue is its creating the list in reverse order. (newer first and older last). Can it be reversed to older first and newest last.

 

Thanks

 

Its okay - you're welcome anytime.

 

Are you after sorting the list as per the smallest X coordinates?

Link to comment
Share on other sites

not exactly,

now your code creates the list with the order of block created or inserted from newer to older into the drawing, required exactly the same with from older to newer..

 

Thanks

Link to comment
Share on other sites

not exactly,

now your code creates the list with the order of block created or inserted from newer to older into the drawing, required exactly the same with from older to newer..

 

Thanks

 

(defun c:Test (/ sel dir fil int ent get pnt)
 ;; Tharwat - Date: 03.Aug.2017	;;
 (if (and (setq sel (ssget "_:L" '((0 . "INSERT"))))
          (setq int (sslength sel)
                dir (getvar 'dwgprefix))
          (setq fil (open (strcat dir "Block-coordinates.txt") "w"))
          )
   (while (setq ent (ssname sel (setq int (1- int))))
        (setq get (entget ent)
              pnt (cdr (assoc 10 get))
              )
     (write-line (strcat (rtos (car pnt) 2) "," (rtos (cadr pnt) 2) "," (rtos (caddr pnt) 2) "," (cdr (assoc 8 get))) fil)
     )
   )
 (if fil (close fil))
 (princ)
 )

Link to comment
Share on other sites

  • 5 months later...

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