Jump to content

Recommended Posts

Posted

Hi all,

I have a drawing with Attributes and Dimension. I want get value Attributes and Dimensions to Excel (2010) (view file Now.rar attachment).

Please, help me get value Attributes and Dimensions to Excel by autolisp.

Thank you very much!

File:

Now.zip

Posted

Before doing anything do a proper search here this has been solved many times. "EXCEl" & "Atrributes"

Posted
Before doing anything do a proper search here this has been solved many times. "EXCEl" & "Atrributes"

 

Dir, Bigal.

I tried searching, but things were not looking for something to help with specific cases like mine.

If possible, can you help me in this case?

Thank you.

Posted

Attributes to Excel. Use DATAEXTRACTION or use this....http://www.cadstudio.cz/excellink

 

Dimensions to Excel. Use this...http://forums.cadalyst.com/showthread.php?t=5965

Posted
Hi ,

 

Did not you solve your problem in this thread with the help of Marko ?

 

http://www.theswamp.org/index.php?topic=46057.msg511617#msg511617

 

Dir, Tharwat

Thank you quoted,

but in case of Ribarm help I have used Attribute Block + Dynamic Block (don't Aligned Dimensions).

case of Marko help I have used Circles and Text (two text) [don't Attribute Block] + Dimensions.

For now, In my drawing I only use the Attribute Block + Aligned Dimension (not Dynamic Dimension).

I hope you understand that.

Perhaps, you have not test on my data attached. It differs from in put in all of Marko, Ribarm.

We hope you consider specific on the data that I have attached.

Hope to receive help.

Thank you very much.

Posted
Attributes to Excel. Use DATAEXTRACTION or use this....http://www.cadstudio.cz/excellink

 

Dimensions to Excel. Use this...http://forums.cadalyst.com/showthread.php?t=5965

 

I want them combined into an AutoLISP file to solve my problem is not solved by two discrete issues.

Thank you.

Posted

I have wrote a program yesterday evening at home and I think it is a great tool since that you are allowed to select the dimensions with the Buble attributed block in one shut and you'd have the Excel file in the same location where the current drawing 's location is .

 

So you need to wait till evening till I get home to post the code for you to test :)

 

Good luck .

Posted
I want them combined into an AutoLISP file to solve my problem is not solved by two discrete issues.

Thank you.

 

Can we see what effort you have made toward solving the problem? Post your code.

Posted
I have wrote a program yesterday evening at home and I think it is a great tool since that you are allowed to select the dimensions with the Buble attributed block in one shut and you'd have the Excel file in the same location where the current drawing 's location is .

 

So you need to wait till evening till I get home to post the code for you to test :)

 

Good luck .

Thank Tharwat very much! I hope you help me!

I will waiting for your help!

Good luck for you.

Posted (edited)

Try it and let me know by selecting all dimensions and attributed blocks .

 

(defun c:Test (/ ss i sn vl p lst bks s d at l a f o)
 ;;    Author : Tharwat Al Shoufi    ;;
 ;;    Date :    08. Feb. 2014        ;;
 (princ
   "\n Select Dimensions with Attributed Block < Buble > "
 )
 (if (setq ss (ssget '((-4 . "<OR")
                       (0 . "DIMENSION")
                       (-4 . "<AND")
                       (0 . "INSERT")
                       (2 . "Buble")
                       (-4 . "AND>")
                       (-4 . "OR>")
                      )
              )
     )
   (repeat (setq i (sslength ss))
     (setq sn (ssname ss (setq i (1- i)))
           vl (vlax-ename->vla-object sn)
     )
     (if (eq (cdr (assoc 0 (entget sn))) "DIMENSION")
       (progn
         (if (/= (vla-get-Arrowhead1Block vl)
                 "None"
             )
           (setq p (cdr (assoc 13 (entget sn))))
           (setq p (cdr (assoc 14 (entget sn))))
         )
         (setq
           lst
            (cons (list p
                        (rtos (cdr (assoc 42 (entget sn))) 2 0)
                  )
                  lst
            )
         )
       )
       (setq bks (cons (list (cdr (assoc 10 (entget sn))) vl) bks))
     )
   )
 )

 (foreach x lst
   (if (and (car x) (car bks))
     (progn
       (setq d  (distance (car x) (caar bks))
             at (cadr (car bks))
       )
       (foreach e bks
         (if (< (setq a (distance (car x) (car e))) d)
           (setq d  a
                 at (cadr e)
           )
         )
       )
     )
   )
   (if bks
     (setq l
            (cons
              (append
                (mapcar '(lambda (u)
                           (list (vla-get-tagstring u) (vla-get-textstring u))
                         )
                        (vlax-invoke at 'getattributes)
                )
                (list
                  (cadr x)
                )
              )
              l
            )
     )
   )
   (setq lst (cdr lst))
 )
 (if l
   (progn
     (setq l (vl-sort l
                      '(lambda (j k)
                         (< (atof (cadr (car j)))
                            (atof (cadr (car k)))
                         )
                       )
             )
     )
     (if (and (setq f
                     (strcat
                       (getvar 'DWGPREFIX)
                       (vl-filename-base (getvar 'DWGNAME))
                       ".csv"
                     )
              )
              (setq o (open f "w"))
         )
       (progn
         (setq s
                (cond ((vl-registry-read
                         "HKEY_CURRENT_USER\\Control Panel\\International"
                         "sList"
                       )
                      )
                      (",")
                )
         )
         (write-line
           (strcat "NUMBER"        s       "DIMENSION"     s
                   "HEIGHT"        s       "H1"    s       "H2"
                   s       "H4"    s       "3F"
                  )
           o
         )
         (foreach u l
           (write-line
             (strcat
               (nth 1 (nth 0 u))
               s
               (nth 6 u)
               s
               (nth 1 (nth 1 u))
               s
               (nth 1 (nth 2 u))
               s
               (nth 1 (nth 3 u))
               s
               (nth 1 (nth 4 u))
               s
               (nth 1 (nth 5 u))
             )
             o
           )
         )
         (close o)
         (princ (strcat "\n File path : < " f " > "))
       )
       (alert "Unable to open or create CSV file for writing !!")
     )
   )
 )
 (princ)
)
(vl-load-com)

Edited by Tharwat
Posted
Try it and let me know by selecting all dimensions and attributed blocks .

 

(defun c:Test (/ ss i sn vl p lst bks d at l a f o)
 ;;    Author : Tharwat Al Shoufi    ;;
 ;;    Date :    08. Feb. 2014        ;;
 (princ
   "\n Select Dimensions with Attributed Block < Buble > "
 )
 (if (setq ss (ssget '((-4 . "<OR")
                       (0 . "DIMENSION")
                       (-4 . "<AND")
                       (0 . "INSERT")
                       (2 . "Buble")
                       (-4 . "AND>")
                       (-4 . "OR>")
                      )
              )
     )
   (repeat (setq i (sslength ss))
     (setq sn (ssname ss (setq i (1- i)))
           vl (vlax-ename->vla-object sn)
     )
     (if (eq (cdr (assoc 0 (entget sn))) "DIMENSION")
       (progn
         (if (/= (vla-get-Arrowhead1Block vl)
                 "None"
             )
           (setq p (cdr (assoc 13 (entget sn))))
           (setq p (cdr (assoc 14 (entget sn))))
         )
         (setq
           lst
            (cons (list p
                        (rtos (cdr (assoc 42 (entget sn))) 2 0)
                  )
                  lst
            )
         )
       )
       (setq bks (cons (list (cdr (assoc 10 (entget sn))) vl) bks))
     )
   )
 )

 (foreach x lst
   (if (and (car x) (car bks))
     (progn
       (setq d  (distance (car x) (caar bks))
             at (cadr (car bks))
       )
       (foreach e bks
         (if (< (setq a (distance (car x) (car e))) d)
           (setq d  a
                 at (cadr e)
           )
         )
       )
     )
   )
   (if bks
     (setq l
            (cons
              (append
                (mapcar '(lambda (u)
                           (list (vla-get-tagstring u) (vla-get-textstring u))
                         )
                        (vlax-invoke at 'getattributes)
                )
                (list
                  (cadr x)
                )
              )
              l
            )
     )
   )
   (setq lst (cdr lst))
 )
 (if l
   (progn
     (setq l (vl-sort l
                      '(lambda (j k)
                         (< (atof (cadr (car j)))
                            (atof (cadr (car k)))
                         )
                       )
             )
     )
     (if (and (setq f
                     (strcat
                       (getvar 'DWGPREFIX)
                       (vl-filename-base (getvar 'DWGNAME))
                       ".csv"
                     )
              )
              (setq o (open f "w"))
         )
       (progn
         (write-line "NUMBER;DIMENSION;HEIGHT;H1;H2;H4;3F" o)
         (foreach u l
           (write-line
             (strcat
               (nth 1 (nth 0 u)) ";" (nth 6 u) ";" (nth 1 (nth 1 u)) ";"
               (nth 1 (nth 2 u)) ";" (nth 1 (nth 3 u)) ";"
               (nth 1 (nth 4 u)) ";" (nth 1 (nth 5 u))
             )
             o
           )
         )
         (close o)
         (princ (strcat "\n File path : < " f " > "))
       )
       (alert "Unable to open or create CSV file for writing !!")
     )
   )
 )
 (princ)
)
(vl-load-com)

 

Thank Tharwat very much.

I have a few opinion

-File out put (*.csv) still group into a column without split other column (B, C, D....).

-In column (D (H1)| E (H2)| F (H4)| G (3F)) value in the column is number (1, 2, 3.....) don't (H1, H2, H3, 3F...). The value of the column is taken get in front of number of H1, H2, H4, 3F (ex: H1 = 1H1--->get value 1; 2H1--->get value 2; H4=1H4--->get value 1; 3-3F-->get value 3; 3F--->get value 1;.....)

Please, Tharwat help me edit your lisp.

Thank you very much.

Posted

Although that the first code worked in my system but try the modified codes above and let me know .

 

CODES UPDATED ABOVE

Posted
Although that the first code worked in my system but try the modified codes above and let me know .

 

CODES UPDATED ABOVE

 

Thank Tharwat very much.

I have a few opinion:

1-File output result splitted to other column. However, value in column Ạ is missing number 0 if value is 2.10 =2.1, 16.10-->16.1, 125.10--->125.1. Summary is missing number 0 after the comma.

2-In column (D (H1)| E (H2)| F (H4)| G (3F)) value in the column is number (1, 2, 3.....) don't get value (H1, H2, H3, 3F...). The value of the column is taken get in front of number of H1, H2, H4, 3F (ex: H1 = 1H1--->get value 1; 2H1--->get value 2; H4= get value 1; 3-3F-->get value 3; 3F--->get value 1;.....)

P/S:

Case 2 (ex: cell A1 (in Excel) = H1) the same function: if(A1="H1",1,left(A1,1) in Excel. I don't know how AutoLISP performances.

Please, Tharwat help me!

Thank Tharwat very much.

Posted

Everything goes very well here , you may need to try it on another machine or we may wait for any of the users here to try it and let us know .

Posted

Hope someone would try the code and let us know the outcome of the excel file (if values in ONE or SEPARATE columns ) . :)

Posted
Everything goes very well here , you may need to try it on another machine or we may wait for any of the users here to try it and let us know .

Dir, Tharwat.

I think Tharwat don't understand my opinion .

Please, view picture to difference 2 result.

 

I hope.jpg

 

Please, help me. Thank Tharwat very much.

Posted

I think Tharwat don't understand my opinion .

 

I will consider this phrase as the English language is not your native one , so I would ignore it .

 

Back to theme ,

 

Select the whole column A by pressing on the first cell in Excel then right click -> general -> number then increase the decimal numbers as much as you want .

Posted
I will consider this phrase as the English language is not your native one , so I would ignore it .

 

Back to theme ,

 

Select the whole column A by pressing on the first cell in Excel then right click -> general -> number then increase the decimal numbers as much as you want .

 

Yes, :). I'm Vietnamese. I understan the language is hurdle of us. :)

Please, help me Case 2 is get value in column H1, H2, H4, 3-3F. Thank you very much!

So You please view image.

Thank you very much.

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...