mssoysal Posted March 25, 2022 Posted March 25, 2022 Hi Everyone, I want to make this with lisp in Autocad... I want to export totale line lenght to excel table.. but i want to see lenght of lines with their box name with lenght.. Pls see example in attachment, Can you help me pls this issue Quote
devitg Posted March 26, 2022 Posted March 26, 2022 @mssoysal For better understanding, and maybe get further help, please upload such sample.dwg As far as I know, ACAD only can edit DWG. Or send it to devitg@gmail.com Quote
mssoysal Posted March 26, 2022 Author Posted March 26, 2022 6 hours ago, devitg said: @mssoysal For better understanding, and maybe get further help, please upload such sample.dwg As far as I know, ACAD only can edit DWG. Or send it to devitg@gmail.com Hi Devitg; Pls find sample document with attachment... Thank you so much Autocad Lisp.rar Quote
marko_ribar Posted March 26, 2022 Posted March 26, 2022 (edited) ;;; Source : https://www.cadtutor.net/forum/topic/74677-lisp-for-total-line-length-for-lines-which-in-every-separately-box/?do=findComment&comment=591483 ;;; REMOVE DUPLICATES - NON RECURSIVE NON COMMAND FUNCTION ;;; (setq lst '("box1" "box1" "box1" "box2" "box2" "box3" "box3")) (defun mr_RemoveDupl (InList fuzz / x r ) (while (setq x (car InList)) (setq InList (vl-remove-if (function (lambda ( y ) (equal x y fuzz) ) ) InList ) ) (setq r (append r (list x))) ) ) (mr_RemoveDupl lst 0) => ("box1" "box2" "box3") (setq lst '("box1" "box1" "box1" "box2" "box2" "box3" "box3")) (defun mr_RemoveDupl (InList fuzz) (vl-remove-if-not (function (lambda ( x ) (if (vl-some (function (lambda ( y ) (equal x y fuzz) ) ) InList ) (progn (setq InList (vl-remove-if (function (lambda ( y ) (equal x y fuzz) ) ) InList ) ) x ) ) ) ) InList ) ) (mr_RemoveDupl lst 0) => ("box1" "box2" "box3") (setq lst '("box1" "box1" "box1" "box2" "box2" "box3" "box3")) (setq rtn (vl-sort (setq lst (vl-remove nil (mapcar (function (lambda ( x / r ) (if (vl-some (function (lambda ( y ) (equal x y) ) ) lst ) (progn (setq lst (vl-remove-if (function (lambda ( z ) (equal x z) ) ) lst ) ) x ) ) ) ) lst ) ) ) (function (lambda ( a b ) (< (atoi a) (atoi b)) ) ) ) ) rtn => ("box1" "box2" "box3") Create pseudo code : 1. Select all rectangles... 2. Iterate through selection set... 3. Foreach rectangle : * 1. Select all entities inside - [ curve entities / have lenghts : (vlax-curve-getdistatparam curve (vlax-curve-getendparam curve)) ] * 2. Foreach curve : * create/append association list (rectangle-description / curve-length ^^^ look above ^^^) 4. Look into this topic to learn how to quickly create TABLE enitity from data stored in LIST (association list - previously built) https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/table-editing/m-p/9335975 5. Insert 2 tables - like you wanted... For first one : for ex. : (setq assoclst '(("box1" 15) ("box1" 20) ("box1" 50) ("box2" 30) ("box2" 20) ("box3" 25) ("box3" 12))) (setq rtn (vl-sort assoclst (function (lambda ( a b ) (< (atoi (car a)) (atoi (car b))) ) ) ) ) rtn => (("box1" 15) ("box1" 20) ("box1" 50) ("box2" 30) ("box2" 20) ("box3" 25) ("box3" 12)) For second one - you'll have to summarize lengths foreach parent rectangle : for ex. : (setq assoclst '(("box1" 15) ("box1" 20) ("box1" 50) ("box2" 30) ("box2" 20) ("box3" 25) ("box3" 12))) (setq rtn (vl-sort (vl-remove nil (mapcar (function (lambda ( x / r ) (if (and (setq r (apply (function +) (mapcar (function cadr) (vl-remove-if-not (function (lambda ( y ) (equal (car x) (car y)) ) ) (progn (or lst (setq lst assoclst) ) lst ) ) ) ) ) (assoc (car x) lst) (setq lst (vl-remove-if (function (lambda ( z ) (equal (car x) (car z)) ) ) lst ) ) ) (list (car x) r) ) ) ) assoclst ) ) (function (lambda ( a b ) (< (atoi (car a)) (atoi (car b))) ) ) ) ) rtn => (("box1" 85) ("box2" 50) ("box3" 37)) Edited March 27, 2022 by marko_ribar Quote
mssoysal Posted March 29, 2022 Author Posted March 29, 2022 On 3/26/2022 at 11:25 PM, marko_ribar said: ;;; Source : https://www.cadtutor.net/forum/topic/74677-lisp-for-total-line-length-for-lines-which-in-every-separately-box/?do=findComment&comment=591483 ;;; REMOVE DUPLICATES - NON RECURSIVE NON COMMAND FUNCTION ;;; (setq lst '("box1" "box1" "box1" "box2" "box2" "box3" "box3")) (defun mr_RemoveDupl (InList fuzz / x r ) (while (setq x (car InList)) (setq InList (vl-remove-if (function (lambda ( y ) (equal x y fuzz) ) ) InList ) ) (setq r (append r (list x))) ) ) (mr_RemoveDupl lst 0) => ("box1" "box2" "box3") (setq lst '("box1" "box1" "box1" "box2" "box2" "box3" "box3")) (defun mr_RemoveDupl (InList fuzz) (vl-remove-if-not (function (lambda ( x ) (if (vl-some (function (lambda ( y ) (equal x y fuzz) ) ) InList ) (progn (setq InList (vl-remove-if (function (lambda ( y ) (equal x y fuzz) ) ) InList ) ) x ) ) ) ) InList ) ) (mr_RemoveDupl lst 0) => ("box1" "box2" "box3") (setq lst '("box1" "box1" "box1" "box2" "box2" "box3" "box3")) (setq rtn (vl-sort (setq lst (vl-remove nil (mapcar (function (lambda ( x / r ) (if (vl-some (function (lambda ( y ) (equal x y) ) ) lst ) (progn (setq lst (vl-remove-if (function (lambda ( z ) (equal x z) ) ) lst ) ) x ) ) ) ) lst ) ) ) (function (lambda ( a b ) (< (atoi a) (atoi b)) ) ) ) ) rtn => ("box1" "box2" "box3") Create pseudo code : 1. Select all rectangles... 2. Iterate through selection set... 3. Foreach rectangle : * 1. Select all entities inside - [ curve entities / have lenghts : (vlax-curve-getdistatparam curve (vlax-curve-getendparam curve)) ] * 2. Foreach curve : * create/append association list (rectangle-description / curve-length ^^^ look above ^^^) 4. Look into this topic to learn how to quickly create TABLE enitity from data stored in LIST (association list - previously built) https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/table-editing/m-p/9335975 5. Insert 2 tables - like you wanted... For first one : for ex. : (setq assoclst '(("box1" 15) ("box1" 20) ("box1" 50) ("box2" 30) ("box2" 20) ("box3" 25) ("box3" 12))) (setq rtn (vl-sort assoclst (function (lambda ( a b ) (< (atoi (car a)) (atoi (car b))) ) ) ) ) rtn => (("box1" 15) ("box1" 20) ("box1" 50) ("box2" 30) ("box2" 20) ("box3" 25) ("box3" 12)) For second one - you'll have to summarize lengths foreach parent rectangle : for ex. : (setq assoclst '(("box1" 15) ("box1" 20) ("box1" 50) ("box2" 30) ("box2" 20) ("box3" 25) ("box3" 12))) (setq rtn (vl-sort (vl-remove nil (mapcar (function (lambda ( x / r ) (if (and (setq r (apply (function +) (mapcar (function cadr) (vl-remove-if-not (function (lambda ( y ) (equal (car x) (car y)) ) ) (progn (or lst (setq lst assoclst) ) lst ) ) ) ) ) (assoc (car x) lst) (setq lst (vl-remove-if (function (lambda ( z ) (equal (car x) (car z)) ) ) lst ) ) ) (list (car x) r) ) ) ) assoclst ) ) (function (lambda ( a b ) (< (atoi (car a)) (atoi (car b))) ) ) ) ) rtn => (("box1" 85) ("box2" 50) ("box3" 37)) Thanks Marko_ribar.. But I didnt open lisp.. It error Bad function Type - "box1".. But I want to draw table in excel.. not in the cad? Your code draw table in cad i think? 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.