Jump to content

Dimension values to Excel


Butch

Recommended Posts

  • Replies 127
  • Created
  • Last Reply

Top Posters In This Topic

  • fixo

    59

  • Butch

    13

  • flyingjunkie

    11

  • Fordy

    9

Top Posters In This Topic

Posted Images

Or do you want to do it with Lisp?

 

PS This will not work in 2010 version

 

~'J'~

 

I'm using Autocad 2014 and MS Office 2010. I used VB in autocad appear error. Please, help me.

Capture.PNG

Thank you very much.

Link to comment
Share on other sites

  • 3 weeks later...

Thanks fixo! The lisp code works fine! You are such a great helper!

 

here is complete code

(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)
   (vlax-put-property aexc "UseSystemSeparators" :vlax-false) 
   (vlax-put-property aexc "DecimalSeparator" (vlax-make-variant "." )
   (setq row 0
     col 1)
   ;;added:
   [color=red](vlax-put-property xcel  "NumberFormat"[/color]
[color=red]     (vlax-make-variant "0.00" [/color]
[color=red]     )[/color]

   (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)

 

about measuring of closed polyline areas this will not work

there is need to write another routine

Not clearly enough for me what do mean

Start a new thread please and attach the sample drawing

for testing

 

~'J'~

Link to comment
Share on other sites

I'm using Autocad 2014 and MS Office 2010. I used VB in autocad appear error. Please, help me.

 

Thank you very much.

 

Hey, plz use the lisp code. I tried both. The VBA code gave the same error as yours, but the lisp code works fine!

Link to comment
Share on other sites

Thanks fixo! The lisp code works fine! You are such a great helper!
Thanks fixo! The lisp code works fine! You are such a great helper!

 

Thanks Fixo! Thanks ytong! Thank you all for your interest!

The lisp code your works fine with dimension is straigh. But, I tried lisp's ytong ( ;;added:

(vlax-put-property xcel "NumberFormat"

(vlax-make-variant "0.00" 8)

)

don't ouput result). File attached.

However, your lisp only selection dimension but don't selected text or mtext. I have a drawing with groups (each group is 1 dimension, 2 text). I hope your lisp selected each object order select dimension, select text 1 on (numerator)

, select text 2 bottom (denominator).....until end.

Then, ouput to excel (2010) include 3 columns with order: Text 1, Dimension, Text 2 (ex: 31 54 H7.5).

Although, your lisp work fine with dimension (straigh) don't branch. I select order each dimension but don't output result.

Ah, Output result don't sort order select when result of your lisp order reserver. Select end ouput (in excel) before.

Thanks all.

Please, please help me.

File attach:

http://www.mediafire.com/download/masapimvvhfh9lv/File.dwg

My final final (reference):

http://www.mediafire.com/download/xxod08ltmzlocrm/LNam.dwg

http://www.mediafire.com/view/6zp9ov84rf9o5ma/LNam.xls

Link to comment
Share on other sites

  • 5 years later...
  • 2 years later...

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