fixo Posted March 25, 2013 Share Posted March 25, 2013 Try this lisp to numbering holes, but as I see in your drawing the very top center hole on "Mounting holes" layer is a bit up to other circles in this row ;;---------------------------- code start -------------------------------;; ;; label holes (defun C:TCL (/ *error* cnt ent_list emake_txt pt_list ss txt_list) (vl-load-com) (defun *error* (msg) (if (vl-position msg '("console break" "Function cancelled" "quit / exit abort" ) ) (princ "Error!") (princ msg) ) (command "_undo" "_e") (princ) ) (defun emake_txt (pt txt hgt) ;; middle center ;; (entmake (list '(0 . "TEXT") '(100 . "AcDbEntity") '(67 . 0) '(8 . "0") '(100 . "AcDbText") (cons 10(list (- (car pt) (* hgt (strlen txt) 0.47))(- (cadr pt)(/ hgt 2.))(caddr pt))) (cons 40 hgt) (cons 1 txt) '(50 . 0) '(41 . 1) '(51 . 0) '(7 . "Standard") '(71 . 0) '(72 . 1) (cons 11 pt) '(100 . "AcDbText") '(73 . 2)))) (command "_undo" "_be") (setvar "cecolor" "5") (setq ss (ssget (list (cons 0 "CIRCLE")(cons 8 "HOLES,MOUNTING HOLES")))) (setq ent_list (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) (setq pt_list (mapcar (function (lambda (x) (cdr (assoc 10 (entget x))))) ent_list) ) ;; 1. Sort points by X+ then by Y- (setq pt_list (vl-sort pt_list '(lambda (a b) (< (cadr a) (cadr b))) ) ) (setq pt_list (vl-sort pt_list '(lambda (a b) (cond ((= (cadr a) (cadr b)) (< (car a) (car b))) (< (cadr a) (cadr b)))) ) ) ;;_____________________________________________________________;; ;; 2. Sort points by X+ then by Y+ ;;; (setq pt_list (vl-sort pt_list ;;; '(lambda (a b) ;;; (> (cadr a) (cadr b))) ;;; ) ;;; ) ;;; ;;; (setq pt_list (vl-sort pt_list ;;; '(lambda (a b) ;;; (cond ;;; ((= (cadr a) (cadr b)) ;;; (< (car a) (car b))) ;;; (< (cadr a) (cadr b)))) ;;; ) ;;; ) ;; 3. Sort points by X- then by Y+ ;;; (setq pt_list (vl-sort pt_list ;;; '(lambda (a b) ;;; (> (cadr a) (cadr b))) ;;; ) ;;; ) ;;; ;;; (setq pt_list (vl-sort pt_list ;;; '(lambda (a b) ;;; (cond ;;; ((= (cadr a) (cadr b)) ;;; (> (car a) (car b))) ;;; (< (cadr a) (cadr b)))) ;;; ) ;;; ) ;; 4. Sort points by X- then by Y- ;;; (setq pt_list (vl-sort pt_list ;;; '(lambda (a b) ;;; (< (cadr a) (cadr b))) ;;; ) ;;; ) ;;; ;;; (setq pt_list (vl-sort pt_list ;;; '(lambda (a b) ;;; (cond ;;; ((= (cadr a) (cadr b)) ;;; (> (car a) (car b))) ;;; (< (cadr a) (cadr b)))) ;;; ) ;;; ) ;;_____________________________________________________;; (setq cnt 0) (mapcar (function (lambda (x) (progn (setq cnt (1+ cnt)) (emake_txt x (itoa cnt) 0.375)) )) pt_list ) (princ) ) (prompt "\n\t\t---\tStart command with TCL\t---\n") (prin1) (or (vl-load-com) (princ)) ;;----------------------------code end-------------------------------;; Quote Link to comment Share on other sites More sharing options...
$anthony Posted May 24, 2013 Share Posted May 24, 2013 Your lisp routine works as advertised - but it only exports the dimension length. Is there any way to modify the code to export all of the dimension overrides? Quote Link to comment Share on other sites More sharing options...
fixo Posted May 24, 2013 Share Posted May 24, 2013 Hi, $antony, Welcome on board! Please, upload a drawing, and draw in there what you want to give as result, pehapsm the screenshot may helps for me too Quote Link to comment Share on other sites More sharing options...
$anthony Posted May 24, 2013 Share Posted May 24, 2013 DIMENSION EXAMPLE.dwg Hi Fixo - i was attempting to reply to a different thread of yours that had a LISP routine that extracted the length of dimensions to an excel file. i have a bunch of dimensions with text overrides that i'd like to extract to excel - not just the dimension length, but the overrides as well. i am attaching an example Quote Link to comment Share on other sites More sharing options...
fixo Posted May 24, 2013 Share Posted May 24, 2013 Well, this is much better , I will be back when I'll do it Cheers Quote Link to comment Share on other sites More sharing options...
fixo Posted May 24, 2013 Share Posted May 24, 2013 (edited) [ATTACH]42087[/ATTACH] Hi Fixo - i was attempting to reply to a different thread of yours that had a LISP routine that extracted the length of dimensions to an excel file. i have a bunch of dimensions with text overrides that i'd like to extract to excel - not just the dimension length, but the overrides as well. i am attaching an example Here is what I ended up with Tell me how it will works on your machine ;;---------------------------- code start -------------------------------;; ;; fixo () 2013 * all rights released (defun C:dovx (/ *error* abks aexc asht col column data dimz dim_data elist en i prec pt row ss tmp xbks xcel xlcolumns xshs) (vl-load-com) (defun *error* (msg) (if (vl-position msg '("console break" "Function cancelled" "quit / exit abort" ) ) (princ "Error!") (princ msg) ) (and dimz (setvar "dimzin" dimz)) ) (if (setq ss (ssget (list (cons 0 "dimension")))) (progn (setq dimz (getvar "dimzin")) (setq prec (getvar "dimdec")) (setvar "dimzin" 3) (setq i -1) (repeat (sslength ss) (setq en (ssname ss (setq i (1+ i))) elist (entget en) pt (cdr (assoc 11 elist)) tmp (list (car pt) (cadr pt)(caddr pt) (cdr (assoc 42 elist))(cdr (assoc 1 elist))) data (cons tmp data)) ) (setq dim_data (vl-sort data (function (lambda (e1 e2) (< (car e1) (car e2)))))) (alert "Click \"Close\" to Save Excel File Only") (setq aexc (vlax-get-or-create-object "Excel.Application") xbks (vlax-get-property aexc 'Workbooks) abks (vlax-invoke-method xbks 'Add) xshs (vlax-get-property abks 'Sheets) asht (vlax-get-property xshs 'Item 1) xcel (vlax-get-property asht 'Cells) ) (vla-put-visible aexc :vlax-true) (vla-put-name asht "DimOverrides") (vlax-put-property aexc 'UseSystemSeparators :vlax-false) (vlax-put-property aexc 'DecimalSeparator (vlax-make-variant "." ) (setq row 1 col 1) (vlax-put-property xcel 'NumberFormat (vlax-make-variant (rtos 0 2 prec) ) (setq xlcolumns (vlax-get-property asht 'columns)) (setq column (vlax-variant-value (vlax-get-property xlcolumns 'item 4)) ) (vlax-put-property column 'NumberFormat (vlax-make-variant "@" ) (foreach line dim_data (setq col 1) (foreach item line (vlax-put-property xcel "Item" row col (vl-princ-to-string (nth (1- col) line )) ) (setq col (1+ col))) (setq row (1+ row))) (vlax-invoke-method xlcolumns 'Autofit) (gc) (vlax-invoke-method abks 'SaveAs "C:\\Test\\ImportDims.xls" -4143 nil nil :vlax-false :vlax-false 1 2 ) (mapcar '(lambda(x) (progn (vl-catch-all-apply 'vlax-release-object (list x)) (setq x nil)) ) (list xcel asht xshs abks xbks aexc) ) (gc) ) ) (*error* nil) (princ) ) (prompt "\n\t\t---\tStart command with DOVX\t---\n") (prin1) (or (vl-load-com) (princ)) ;;----------------------------code end-------------------------------;; Edited June 25, 2013 by fixo spell check Quote Link to comment Share on other sites More sharing options...
sinnerboy Posted June 25, 2013 Share Posted June 25, 2013 If I may jump aboard to request a further modification -please. I would like to export dimension texts to an Excel sheet and then overwrite those texts and then import those overwrites. You see I want to use dimensions not as dimensions at all but as area describers across architectural elevations. SO for example if I have a dimension string that states 6500 / 11000 / 5000 I would like to handy way to change that to read Lobby / Reception/ Office etc Is this possible ? Quote Link to comment Share on other sites More sharing options...
fixo Posted June 25, 2013 Share Posted June 25, 2013 If I may jump aboard to request a further modification -please. I would like to export dimension texts to an Excel sheet and then overwrite those texts and then import those overwrites. You see I want to use dimensions not as dimensions at all but as area describers across architectural elevations. SO for example if I have a dimension string that states 6500 / 11000 / 5000 I would like to handy way to change that to read Lobby / Reception/ Office etc Is this possible ? I think yes, Upload the sample drawing in A2007 version with few rooms in there, and write explanation in the very first room, just to to make me more sence Quote Link to comment Share on other sites More sharing options...
bojanamit Posted October 26, 2013 Share Posted October 26, 2013 fixo, i need help with lisp U call dx (dimension value in excel)....it's work fine when dimension have no comma (example if is dimension 423 in excel I got 423, but if is dimension 423.15 then in my excel sheet i got 42315.00 )...i use this for making bill of quantity. So in one row I have dimension like in a cad, corect, and dimension #### incorect...I need help it's burning...ty...sorry for bad english and spelling! Quote Link to comment Share on other sites More sharing options...
fixo Posted October 26, 2013 Share Posted October 26, 2013 Welcome aboard, bojanamit! Please take a look at my response in posts #10 & #12 Quote Link to comment Share on other sites More sharing options...
bojanamit Posted October 26, 2013 Share Posted October 26, 2013 so it look like this...If aligned dimension is not decimal lisp work fine, but in thi s case i have this! Quote Link to comment Share on other sites More sharing options...
bojanamit Posted October 26, 2013 Share Posted October 26, 2013 i saw that so many times but nothing...now I check or unchek some tabs in excel options ( i don't know whic one )) ) and it work fine...TY fixo, U r GREAT! Quote Link to comment Share on other sites More sharing options...
fixo Posted October 26, 2013 Share Posted October 26, 2013 Glad, you solved it by yourself Cheers Quote Link to comment Share on other sites More sharing options...
bojanamit Posted October 26, 2013 Share Posted October 26, 2013 I have one more question. Last year i found Ur lisp named FA for length and area of polyline with leader...I use that with field command and its ok for litle objects...I manually changed in excel dimension. well my question is is there a lisp routine for selecting many polylines and get length/area of each in excel sheet! or maybe all polylines in one layer. TY Quote Link to comment Share on other sites More sharing options...
fixo Posted October 26, 2013 Share Posted October 26, 2013 Please, start a new thread with this question. There are much programmers smarter than me, probably somebody else will be helps Sorry, but I haven't have a time to do this work Quote Link to comment Share on other sites More sharing options...
bojanamit Posted October 26, 2013 Share Posted October 26, 2013 OK THANKS! oh no thank you very much...i'll try that with data extraction in AC 2014... Quote Link to comment Share on other sites More sharing options...
minhphuong_humg Posted November 28, 2013 Share Posted November 28, 2013 The same thing on Lisp (defun C:dx (/ *error* abks aexc asht col data dim_data elist en i row row_data ss tmp xbks xcel xshs) (vl-load-com) (defun *error* (msg) (if (vl-position msg '("console break" "Function cancelled" "quit / exit abort" ) ) (princ "Error!") (princ msg) ) ) (if (setq ss (ssget (list (cons 0 "dimension")))) (progn (setq i -1) (repeat (sslength ss) (setq en (ssname ss (setq i (1+ i))) elist (entget en) tmp (cons (cdr (assoc 11 elist)) (cdr (assoc 42 elist))) data (cons tmp data)) ) (setq dim_data (vl-sort data (function (lambda (e1 e2) (< (caar e1) (caar e2)))))) (alert "Close Excel File Only") (setq aexc (vlax-get-or-create-object "Excel.Application") xbks (vlax-get-property aexc "Workbooks") abks (vlax-invoke-method xbks "Add") xshs (vlax-get-property abks "Sheets") asht (vlax-get-property xshs "Item" 1) xcel (vlax-get-property asht "Cells") ) (vla-put-visible aexc :vlax-true) (setq row 0 col 1) (repeat (length dim_data) (setq row_data (car dim_data)) (setq row (1+ row)) (vlax-put-property xcel "Item" row col (vl-princ-to-string (cdr row_data)) ) (setq dim_data (cdr dim_data)) ) (vlax-invoke-method abks 'SaveAs "C:\\ImportDims.xls" -4143 nil nil :vlax-false :vlax-false 1 2 ) (vlax-release-object xcel) (vlax-release-object asht) (vlax-release-object xshs) (vlax-release-object abks) (vlax-release-object xbks) (vlax-release-object aexc) (setq aexc nil) (gc) (gc) ) (*error* nil) ) (princ) ) (prompt "\n\t\t>>>\tType DX to execute\t<<<\n") (princ) ~'J'~ This lisp greate, however value don't round. I want value round. Example: 40.1795 = 40; 42.5987 = 43..... Please help me. Thanks. Quote Link to comment Share on other sites More sharing options...
fixo Posted November 28, 2013 Share Posted November 28, 2013 Please take a look at function RTOS in the Help file To round numbers you have to write: (vl-princ-to-string(rtos (cdr row_data)) 2 0)) instead of: (vl-princ-to-string (cdr row_data)) Cheers Quote Link to comment Share on other sites More sharing options...
minhphuong_humg Posted November 28, 2013 Share Posted November 28, 2013 Please take a look at function RTOS in the Help fileTo round numbers you have to write: (vl-princ-to-string(rtos (cdr row_data)) 2 0)) instead of: (vl-princ-to-string (cdr row_data)) Cheers Thank you, however I edited (vl-princ-to-string(rtos (cdr row_data) 2 0)) because redundant ")" at ...data). Thank fixo very much. Quote Link to comment Share on other sites More sharing options...
minhphuong_humg Posted November 28, 2013 Share Posted November 28, 2013 Dir, fixo. Thank you for wrote this lisp. However, I used and this lisp worked don't exactly. Because, with drawing (link) I select dimention then text out but value don't excatly. Please help me. ImportDims.xls Hoi.dwg Quote Link to comment Share on other sites More sharing options...
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.