Jump to content

extract dimesions from dwg to excel


shamsam1

Recommended Posts

i want to extract all dimesions values from dwg to excel.do help me with vb or vba .i have vb.6 code to extract block attributes.i want code to extrat only dimensions:shifty:

Link to comment
Share on other sites

  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • shamsam1

    11

  • fuccaro

    7

  • prabhathjp

    2

  • Cad64

    1

Why do you need that??

 

if you want do sum all the dimesions, i have a lisp for that.

tell me if you need that code.

 

 

 

i want to extract all dimesions values from dwg to excel.do help me with vb or vba .i have vb.6 code to extract block attributes.i want code to extrat only dimensions:shifty:
Link to comment
Share on other sites

i have around 3000 dwg drawing.so we want to extract all dimensin value in excel so thatwill be help ful for us to dispay drawing (dwg )accornding to dimensions.i dton want to extact blcok attributes.

 

wel my knowledge with lisp is nilll.do help me with vba code or vb .can lisp be converted to vb or vba .

Link to comment
Share on other sites

Would help a program to export the data in CSV format? It can be opened in Excel.

Try it:

;  Save the Dimension's values to a CSV file
;  [email="mfuccaro@hotmail.com"]mfuccaro@hotmail.com[/email]
;  2008 May
(defun dimexp( / s tx fn i d dl m file)
 (setq s (ssget "X" (list '(0 . "DIMENSION")))
tx nil
fn (strcat (getvar "dwgprefix")
    (substr (getvar "dwgname")
     1
     (- (strlen (getvar "dwgname")) 3)
     )
    "\CSV"))
 (repeat (setq i (sslength s))
   (setq d (ssname s (setq i (1- i)))
  dl (entget d)
  m (cdr (assoc 42 dl)))
   (if (not (member m tx)) (setq tx (cons m tx)))
   )
 (setq s nil)
 (if tx (progn
   (setq file (open fn "w"))
   (foreach x tx
     (princ x file)
     (princ "," file)
     )
   (close file)
   )
   )
 )

With small adjustments you can make the program to process at one go all the drawings contained in a directory.

Does it help?

Link to comment
Share on other sites

i get the following eroor

Unknown command "D:\DRAWINGS\SM\1-003666.ZIP". Press F1 for help.

; error: extra right paren on input

Link to comment
Share on other sites

ZIP?!:?

Ok, step by step:

-Select the code and press CTRL+C

-Open Notepad and press CTRL+V. The code should be there

-From Notepad: Save AS.. filename should be DIMEXP.LSP See the lsp extension!

-Open AutoCAD, open a drawing containing dimensions

-Drag the DIMEXP.LSP file in the drawing area. AutoCAD should report something like "dimexp loaded"

-Enter (dimexp) in the command line

-Minimize AutoCAD and go to the directory where the drawing is. You should see a file .CSV

-Open it in Excel

 

Extra right paren on input -probable you left out the end of the code when copied it. In the code window you must scroll down to see it all!

Link to comment
Share on other sites

fuccaro ur genious

thanks for the help.now i can run a lisp program:).i got my dimesions which i was looking for

Link to comment
Share on other sites

Do you wish to have all the data in the same file? It is even a litle bit simpler:

;  Save the Dimension's values to a CSV file
;  [email="mfuccaro@hotmail.com"]mfuccaro@hotmail.com[/email]
;  2008 May
;  Changed: all the dimensions are exported in the same file
(defun dimexp( / s tx fn i d dl m file)
 (setq s (ssget "X" (list '(0 . "DIMENSION")))
 tx nil
 fn "c:\\MyDims.csv")
 (repeat (setq i (sslength s))
   (setq d (ssname s (setq i (1- i)))
  dl (entget d)
  m (cdr (assoc 42 dl)))
   (if (not (member m tx)) (setq tx (cons m tx)))
   )
 (setq s nil)
 (if tx (progn
   (setq file (open fn "a"))
   (princ (strcat (getvar "dwgname") ",") file)
   (foreach x tx
     (princ x file)
     (princ "," file)
     )
   (if file (close file))
   )
   )
 )
(dimexp)

I am at home now and I can't test it, but it should work.

Now about processing more files at once: did you read the posts I pointed? Nevermind; here is the way again.

-In AutoCAD go to Tools>Load applications. In the opened window navigate to the folder where you saved the lisp. Drag the file DIMEXP.LSP in the startup folder. Click OK to close the window.

-Go to File>Open. You must see a window where you select the files to be opened by AutoCAD. Select all the files you wish to process. How? CTRL+A will select all of them, or CTRL and/or SHIFT +click them.

-Click the OPEN (or OK?) button.

-In Windows Explorer find the file C:\MyDims.csv and open it.

-If you run the lisp again, it will place the new results at the end of this file. So move or rename it if you wish the new dimensions in separate file

-IMPORTANT: remove the DIMEXP.LSP from the startup folder.

Link to comment
Share on other sites

hi

 

its working .but in excel all drawing details commming in 1 line.

in excel for new drawing it should take new line...

 

thanks for u help..u have solved my problem..

Link to comment
Share on other sites

;  Save the Dimension's values to a CSV file
;  mfuccaro@hotmail.com
;  2008 May
;  Changed: all the dimensions are exported in the same file
;  on a new line
(defun dimexp( / s tx fn i d dl m file)
 (setq s (ssget "X" (list '(0 . "DIMENSION")))
 tx nil
 fn "c:\\MyDims.csv")
 (repeat (setq i (sslength s))
   (setq d (ssname s (setq i (1- i)))
  dl (entget d)
  m (cdr (assoc 42 dl)))
   (if (not (member m tx)) (setq tx (cons m tx)))
   )
 (setq s nil)
 (if tx (progn
   (setq file (open fn "a"))
  (write-line "" file)
   (princ (strcat (getvar "dwgname") ",") file)
   (foreach x tx
     (princ x file)
     (princ "," file)
     )
   (if file (close file))
   )
   )
 )

Link to comment
Share on other sites

Keep it so, Shamsam1!

Together we make a great team! :)

 

Just a late question: Does your AutoCAD LT run the lisp I wrote for you? :twisted: :twisted: :twisted:

Ok, don't spend your time answering me; better use the time to update your profile. -just a sugestion...

Link to comment
Share on other sites

i am dotnet and vb programmmer...not a lisp programmer

for lisp rogram i am using autocad 2000.

 

regads

sam

Link to comment
Share on other sites

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