Jump to content

Recommended Posts

Posted

I have found lips routines that will list the blocks used in a drawing, show the number of blocks in a drawing, however, I need a lisp routine to list the xy coordinate of each block that has been inserted in a drawing and preferably write this both to an excel and text file.

Posted

Quickly written & wholly untested:

(defun c:blockinfo ( / e f i s )
   (if 
       (and
           (setq s (ssget "_X" '((0 . "INSERT") (410 . "Model"))))
           (setq f (getfiled "Create CSV File" "" "csv" 1))
           (setq f (open f "w"))
       )
       (progn
           (repeat (setq i (sslength s))
               (setq e (entget (ssname s (setq i (1- i)))))
               (write-line
                   (apply 'strcat
                       (cons (LM:name->effectivename (cdr (assoc 2 e)))
                           (mapcar '(lambda ( x ) (strcat "," (rtos x)))
                               (cdr (assoc 10 e))
                           )
                       )
                   )
                   f
               )
           )
           (close f)
       )
   )
   (princ)
)

;; Block Name -> Effective Block Name  -  Lee Mac
;; blk - [str] Block name

(defun LM:name->effectivename ( blk / rep )
   (if
       (and (wcmatch blk "`**")
           (setq rep
               (cdadr
                   (assoc -3
                       (entget
                           (cdr (assoc 330 (entget (tblobjname "block" blk))))
                          '("AcDbBlockRepBTag")
                       )
                   )
               )
           )
           (setq rep (handent (cdr (assoc 1005 rep))))
       )
       (cdr (assoc 2 (entget rep)))
       blk
   )
)

(princ)

Block Name to Effective Block Name function from here.

Posted

Thanks Lee, this work like a charm. :notworthy:

  • 3 months later...
Posted

I need a Lisp to export x,y coordinate of Block (or exref) to text (or csv)

x1 y1

x2 y2

 

Thank you so much

Posted

Hi Lee Mac

 

I need a lisp to export x,y coordinate of block (xref) to txt file

 

Help me please

Thank you in advance

Posted
I need a lisp to export x,y coordinate of block (xref) to txt file

 

Change 'csv' to 'txt' and the above code should perform as required.

Posted
Change 'csv' to 'txt' and the above code should perform as required.

 

Hi Lee Mac

i want to select block before export and i want to take out column A and D

Help me please

Posted (edited)
Threads merged.

 

bienda, please only post the same question once.

 

But my question was not answered ������

Edited by bienda
Posted
i want to select block before export and i want to take out column A and D

 

Remove "_X" to enable a user selection.

Posted

thank you Lee Mac but i want to remove column A and D? and i want to take meter for X, Y , what can i do?

Posted
(defun c:blockinfo ( / e f i s )
   (if (and (setq s (ssget '((0 . "INSERT") (410 . "Model"))))
            (setq f (getfiled "Create File" "" "txt" 1))
            (setq f (open f "w"))
       )
       (progn
           (repeat (setq i (sslength s))
               (princ
                   (apply 'strcat
                       (mapcar '(lambda ( a b ) (strcat (rtos a) b))
                           (cdr (assoc 10 (entget (ssname s (setq i (1- i))))))
                          '("," "\n")
                       )
                   )
                   f
               )
           )
           (close f)
       )
   )
   (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...