Baber62 Posted May 20, 2016 Posted May 20, 2016 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. Quote
Lee Mac Posted May 20, 2016 Posted May 20, 2016 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. Quote
bienda Posted September 7, 2016 Posted September 7, 2016 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 Quote
bienda Posted September 7, 2016 Posted September 7, 2016 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 Quote
Lee Mac Posted September 7, 2016 Posted September 7, 2016 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. Quote
Lee Mac Posted September 7, 2016 Posted September 7, 2016 [ @Mod: merge with duplicate post here: http://www.cadtutor.net/forum/showthread.php?96923-Listing-blocks-in-drawing&p=669066&viewfull=1#post669066 ] Quote
bienda Posted September 8, 2016 Posted September 8, 2016 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 Quote
SLW210 Posted September 8, 2016 Posted September 8, 2016 [ @Mod: merge with duplicate post here: http://www.cadtutor.net/forum/showthread.php?96923-Listing-blocks-in-drawing&p=669066&viewfull=1#post669066 ] Threads merged. bienda, please only post the same question once. Quote
bienda Posted September 8, 2016 Posted September 8, 2016 (edited) Threads merged. bienda, please only post the same question once. But my question was not answered ������ Edited September 9, 2016 by bienda Quote
Lee Mac Posted September 8, 2016 Posted September 8, 2016 i want to select block before export and i want to take out column A and D Remove "_X" to enable a user selection. Quote
bienda Posted September 9, 2016 Posted September 9, 2016 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? Quote
Lee Mac Posted September 9, 2016 Posted September 9, 2016 (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) ) 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.