Hi all, now my work needs to get the value of multi dimensions in attached drawing and input in Excel file. I need your help to export them as the below information:
1. The value of dim is mm but the value after export is meter.
2. The exporting value must have 03 numbers after decimal point (e.g: If value of dim = 1,0514 mm => exporting value will be 1.051).
3. Please refer the attached lisp named "D2E" (export drawing text to Excel that hosneyalaa made for me - https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6591997).
4. Please refer the attached lisps that extracts dim value to field in drawing with mm and meter units that named "mmD2F" and "mD2F".
Thank you soo much and best regards.
Solved! Go to Solution.
Solved by hosneyalaa. Go to Solution.
Solved by hosneyalaa. Go to Solution.
This is reference to extract dim to field with unit is meter.
Best regards.
learn yourself how to do that.
This is a snippet from your code:
(vla-put-textString obj (if (= 1 (length Ids)) (strcat "%<\\AcObjProp Object(%<\\_ObjId " (car Ids) ">%).Measurement \\f \"%lu6\%ct8[0.001]\">%") (strcat "%<\\AcExpr" (lst->str Ids " %<\\AcObjProp Object(%<\\_ObjId " ">%).Measurement >% +") ">%).Measurement >% \\f \"%lu6\%ct8[0.001]\">%" ) ) )
See, there is some FIELD formatting in your code.
So, run the FIELD command, specify the desired formatting, and change the code accordingly. The following screenshot is just for illustration:
hi @minh.dxuan
test this
;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-value-of-text-to-excel-sometimes-error/td-p/9764877
(defun C:testD2E(/ FN FW I J LST L_TXT SLST STR)
;;--------------=={ SelectionSet -> Entities }==--------------;;
;; ;;
;; Converts a SelectionSet to a list of Entities ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; ss - Valid SelectionSet (Pickset) ;;
;;------------------------------------------------------------;;
;; Returns: List of Entity names, else nil ;;
;;------------------------------------------------------------;;
(defun LM:ss->ent ( ss / i l )
(if ss
(repeat (setq i (sslength ss))
(setq l (cons (ssname ss (setq i (1- i))) l))
)
)
)
(princ "\nChoose Dimension can xuat ra file...")
(IF (AND
(setq lst (mapcar 'entget (LM:ss->ent (ssget '((0 . "DIMENSION"))))))
(setq fn (getfiled "Chon file de save" "" "text" 1))
(setq fw (open fn "w") i 0 j 0)
)
(PROGN
(foreach n lst
;;; (setq n (nth 4 lst))
(princ
(cond
((wcmatch (cdadr n) "*TEXT")(strcat (setq str (vlax-get (vlax-ename->vla-object (CDR(ASSOC -1 N))) 'Textstring)) ";Text" (itoa (setq i (1+ i))) "\n"))
((= (cdadr n) "DIMENSION")
(setq l_txt (strcat (rtos (/ (vlax-get (vlax-ename->vla-object (CDR(ASSOC -1 N))) 'measurement) 1000) (getvar 'lunits) 3)));_end_setq
(setq slst (vl-string->list l_txt));_end_setq
(cond ( (not (vl-position 46 slst)) (setq l_txt (strcat l_txt ".000")))
( (= (vl-position 46 slst) (1- (strlen l_txt))) (setq l_txt (strcat l_txt "000")))
( (= (vl-position 46 slst) (- (strlen l_txt) 2)) (setq l_txt (strcat l_txt "00")))
( (= (vl-position 46 slst) (- (strlen l_txt) 3)) (setq l_txt (strcat l_txt "0")))
);end_cond
(strcat l_txt ";Dim" (itoa (setq j (1+ j))) "\n")
)
)
fw
)
)
(close fw)
;;;(startapp "explorer" fn)
(startapp "notepad" fn)
))
)
Hi @hosneyalaa , thank you so much for your help. Could you please revise your lisp to extract to Excel file and the exporting file is automatically opened like the attached file named "D2E" - Drawing to Excel (this file before you make for me to export text from AutoCAD to Excel). This one is more convenient to copy the data after exporting.
Thanks and best regards.
Hi @ВeekeeCZ .
Thank you for your help. I think it's very good to enlarge the acknowledge with your code. But I am very sad that I am as white paper with lisp code and at the moment I can not program the lisp by myself. I hope I will be able soon.
Many thanks and have a nice day.
;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-value-of-text-to-excel-sometimes-error/td-p/9764877
(defun C:testD2E(/ FN FW I J LST L_TXT SLST STR)
;;--------------=={ SelectionSet -> Entities }==--------------;;
;; ;;
;; Converts a SelectionSet to a list of Entities ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; ss - Valid SelectionSet (Pickset) ;;
;;------------------------------------------------------------;;
;; Returns: List of Entity names, else nil ;;
;;------------------------------------------------------------;;
(defun LM:ss->ent ( ss / i l )
(if ss
(repeat (setq i (sslength ss))
(setq l (cons (ssname ss (setq i (1- i))) l))
)
)
)
(princ "\nChoose Dimension can xuat ra file...")
(IF (AND
(setq lst (mapcar 'entget (LM:ss->ent (ssget '((0 . "DIMENSION"))))))
(setq fn (getfiled "Chon file de save" "" "csv" 1))
(setq fw (open fn "w") i 0 j 0)
)
(PROGN
(foreach n lst
;;; (setq n (nth 4 lst))
(princ
(cond
((wcmatch (cdadr n) "*TEXT")(strcat (setq str (vlax-get (vlax-ename->vla-object (CDR(ASSOC -1 N))) 'Textstring)) ";Text" (itoa (setq i (1+ i))) "\n"))
((= (cdadr n) "DIMENSION")
(setq l_txt (strcat (rtos (/ (vlax-get (vlax-ename->vla-object (CDR(ASSOC -1 N))) 'measurement) 1000) (getvar 'lunits) 3)));_end_setq
(setq slst (vl-string->list l_txt));_end_setq
(cond ( (not (vl-position 46 slst)) (setq l_txt (strcat l_txt ".000")))
( (= (vl-position 46 slst) (1- (strlen l_txt))) (setq l_txt (strcat l_txt "000")))
( (= (vl-position 46 slst) (- (strlen l_txt) 2)) (setq l_txt (strcat l_txt "00")))
( (= (vl-position 46 slst) (- (strlen l_txt) 3)) (setq l_txt (strcat l_txt "0")))
);end_cond
(strcat l_txt ";Dim" (itoa (setq j (1+ j))) "\n")
)
)
fw
)
)
(close fw)
(startapp "explorer" fn)
;;;(startapp "notepad" fn)
))
)
Hi @hosneyalaa , your lisp runs extremely well and I would like to thank you for your many helps.
Best regards and best wishes to you.
Can't find what you're looking for? Ask the community or share your knowledge.