Jump to content

Recommended Posts

Posted

oh, test.txt

 

you will have to turn it back to a .xls file, it wouldn't let me upload it.

 

Thanks for your help. :D

Posted
oh, [ATTACH]19300[/ATTACH]

 

you will have to turn it back to a .xls file, it wouldn't let me upload it.

 

Thanks for your help. :D

 

First of all change all cells data format on "Text"

because I can't convert Excel time and scale (i.e 1:96) to string

Secondly you could run this program just in the current

drawing

And also if you want to process the whole folder in

this case you need to recreate Excel file using this way:

say, all drawing names need to be stored in the column "A"

starting from the cell "A2" (write the full path only or

write the folder path in cell "A1" and short drawing names below

then I could be easily combine it to full path)

all the tags you need to write in the first row starting

from the cell "B1"

all attribute values will follows after drawing name cell

starting from the cell "B2" in the same row as drawing name

 

; Tested on A2005/2008; MS Office 2003/2007
(defun C:AXE (/ atts blkref data exd i itm ss)
;; local defun:

;; read Excel data
(defun EXD ( / ExcelApp ExcData FilePath Sht ShtNum UsdRange Wbk)
 (setq ExcData nil);debug only
 (vl-load-com)
   (setq FilePath (getfiled "Select Excel file to read attribute values:"
  (getvar "dwgprefix")
  "xls"
  16
      )
 )
 (setq ShtNum 1); Spreadsheet number, change to suit 
 (setq ExcelApp (vlax-get-or-create-object "Excel.Application"))
 (vla-put-visible ExcelApp :vlax-true)
 (setq Wbk (vl-catch-all-apply 'vla-open
      (list (vlax-get-property ExcelApp "WorkBooks") FilePath)))
  (setq Sht (vl-catch-all-apply 'vlax-get-property
         (list (vlax-get-property Wbk "Sheets")
        "Item" ShtNum)))
     (vlax-invoke-method Sht "Activate")
 (setq Sht (vlax-get-property ExcelApp "ActiveSheet"))
(setq UsdRange (vlax-get-property Sht "Range"
      "A3:H4"));<-- select two rows with tags and values
 (vlax-for Row (vlax-get-property UsdRange 'Rows)
 (setq ExcData (cons  (car (vlax-safearray->list
      (vlax-variant-value
   (vlax-get-property Row 'Value2)))) ExcData)))
(setq ExcData (reverse (mapcar (function (lambda (x)
 (mapcar 'vlax-variant-value x)))
       ExcData)
        )
     )

     (vl-catch-all-apply
'vlax-invoke-method
(list Wbk "Close")
     )
(vl-catch-all-apply
  'vlax-invoke-method
  (list ExcelApp "Quit")
)
 (mapcar
   (function (lambda (x)
 (if (not (vlax-object-released-p x))

   (vlax-release-object x)
 )
      )
   )
   (list UsdRange Sht Wbk ExcelApp)
 )
 (setq UsdRange nil
Sht nil
Wbk nil
ExcelApp nil
 )
 (gc)
 (gc)
 ; to ignore empty cells :
 (vl-remove-if (function(lambda(x)(member nil x)))
 ExcData
 )
)

;======================main part=======================;
(if (not (tblsearch "block" "TITLE"));<-- change title block name here
 (progn
   (alert "Block \"TITLE\" does not exist\nChange on appropriate name");<-- change title block name here
   (exit)(princ)
   )
 )
(if (and
 (setq data (exd))
 ;; groupping pairs :
 (setq data (mapcar 'cons (car data)(cadr data)))

 (setq ss (ssget "_X" (list (cons 0 "INSERT")(cons 2 "TITLE")(cons 66 1)))));<-- change title block name here
 (progn
   (setq i -1)
   (repeat (sslength ss)
   (setq blkref (vlax-ename->vla-object (ssname ss (setq i (1+ i)))))
   (setq atts (vlax-invoke blkref "GetAttributes"))
   (foreach at atts
     (if (setq itm (assoc (vla-get-tagstring at) data))
 (progn
 (vla-put-textstring at (cdr itm))
 (vla-update at)))
     )
   (vla-update blkref)
   )
   )
 (alert "Something wrong")
 )
(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acallviewports)  
(princ)
 )
(prompt "\t\t***\t\nType AXE to change attributes\t***")
(prin1)

 

~'J'~

  • 5 weeks later...
Posted

Hey Lee,

I am using AutoCAD 2010 but I need to save all my drawings back to 2007 for my clients. Everytime I run this program it saves all the drawings in the 2010 format. What can I do to have it save to 2007 format? I have set my Options>File Save>Save as: to AutoCAD 2007/LT2007 Drawing (*.dwg), but this did not fix the issue.

 

If it requires the program to be rewritten then don't bother because I do still have a copy of AutoCAD 2009 I can use.

 

Thanks Lee.

Posted

Hi,

 

There is only one line to change :)

 

Change this line (line 2340):

 

(vla-saveas oDoc dwg))

To

 

(vla-saveas oDoc dwg [b][color=Blue]ac2007_dwg[/color][/b]))

Or any of these:

 

[color=Blue][b]acR14_dwg[/b][/color]           AutoCAD R14 DWG (*.dwg)
[b][color=Blue]ac2000_dwg[/color][/b]          AutoCAD 2000 DWG (*.dwg)
[b][color=Blue]ac2000_dxf[/color][/b]          AutoCAD 2000 DXF (*.dxf)
[b][color=Blue]ac2000_Template[/color][/b]     AutoCAD 2000 Drawing Template File (*.dwt)
[b][color=Blue]ac2004_dwg[/color][/b]          AutoCAD 2004 DWG (*.dwg)
[color=Blue][b]ac2004_dxf[/b][/color]          AutoCAD 2004 DXF (*.dxf)
[color=Blue][b]ac2004_Template[/b][/color]     AutoCAD 2004 Drawing Template File (*.dwt)
[b][color=Blue]ac2007_dwg [/color][/b]         AutoCAD 2007 DWG (*.dwg)
[b][color=Blue]ac2007_dxf[/color][/b]          AutoCAD 2007 DXF (*.dxf)
[color=Blue][b]ac2007_Template[/b][/color]     AutoCAD 2007 Drawing Template File (*.dwt)
[color=Blue][b]acNative[/b][/color]            A synonym for the latest drawing release.

Posted

Awesome... Thanks Lee... This program is working great for me.

Posted
Awesome... Thanks Lee... This program is working great for me.

 

Excellent - good to hear :)

 

A few questions if I may:

 

Do you mostly use the Editor or Extractor?

 

Do you have any trouble with the attribute alignment if using the Editor?

 

Is the dialog layout intuitive to use?

 

Thanks,

 

Lee

Posted
Excellent - good to hear :)

 

A few questions if I may:

 

Do you mostly use the Editor or Extractor?

 

Do you have any trouble with the attribute alignment if using the Editor?

 

Is the dialog layout intuitive to use?

 

Thanks,

 

Lee

 

 

I only use the editor.

 

I have not noticed any attribute alignment errors yet but I will keep an eye on it.

 

I like the dialog layout, very easy to use.

 

I have not been using this for too long, but I will report back any errors or glitches I come across.

Posted
Hi,

 

There is only one line to change :)

 

Change this line (line 2340):

 

(vla-saveas oDoc dwg))

To

 

(vla-saveas oDoc dwg [b][color=Blue]ac2007_dwg[/color][/b]))

Or any of these:

 

[color=Blue][b]acR14_dwg[/b][/color]           AutoCAD R14 DWG (*.dwg)
[b][color=Blue]ac2000_dwg[/color][/b]          AutoCAD 2000 DWG (*.dwg)
[b][color=Blue]ac2000_dxf[/color][/b]          AutoCAD 2000 DXF (*.dxf)
[b][color=Blue]ac2000_Template[/color][/b]     AutoCAD 2000 Drawing Template File (*.dwt)
[b][color=Blue]ac2004_dwg[/color][/b]          AutoCAD 2004 DWG (*.dwg)
[color=Blue][b]ac2004_dxf[/b][/color]          AutoCAD 2004 DXF (*.dxf)
[color=Blue][b]ac2004_Template[/b][/color]     AutoCAD 2004 Drawing Template File (*.dwt)
[b][color=Blue]ac2007_dwg [/color][/b]         AutoCAD 2007 DWG (*.dwg)
[b][color=Blue]ac2007_dxf[/color][/b]          AutoCAD 2007 DXF (*.dxf)
[color=Blue][b]ac2007_Template[/b][/color]     AutoCAD 2007 Drawing Template File (*.dwt)
[color=Blue][b]acNative[/b][/color]            A synonym for the latest drawing release.

 

 

I made this change and now I am getting this error:

 

 

Command: _appload MacAtt V2.8.lsp successfully loaded.

 

 

Command:

¤º°`°º¤ø,¸¸, MacAtt.lsp ~ Copyright © by Lee McDonnell ,¸¸,ø¤º°`°º¤

~¤~ Extractor: "MacAttExt" -==- Editor: "MacAttEdit" ~¤~

Command:

Command: MACATTEDIT

; error: Exception occurred: 0xC0000005 (Access Violation)

; warning: unwind skipped on unknown exception

Posted

I get the same - I hadn't tested my suggestion :(

 

I'm not sure on this one :(

Posted
I get the same - I hadn't tested my suggestion :(

 

I'm not sure on this one :(

 

 

I will keep trying stuff... I am in no rush for this fix... It is only for convenience because this program works great already.

Posted
I will keep trying stuff... I am in no rush for this fix... It is only for convenience because this program works great already.

 

It could be that you can only save to the native dwg format when using ObjectDBX - there is still a few things I haven't tried with it.

Posted
This program will allow the user to extract all attributes from multiple blocks in multiple drawings, and will write all data to an Excel spreadsheet.

 

The user is prompted to create a list of block names from which attributes will be extracted.

 

The user is then prompted to select a directory of drawing files to process, and also provided with the option to process sub-directories of the selected directory.

 

Results will then be written to an Excel Spreadsheet, to be saved as the user wishes.

 

Among many other uses, this program may be used to create a Drawing List, by inputting the name of the titleblock, and the attributes that you want to extract from it, and setting the mode to 'Drawing List Mode' (within the 'Options' Dialog), so that the data is grouped in one list.

(See the Header for more info).

 

Your feedback, comments and suggestions are welcome :)

 

Lee

 

Preview:

 

Attribute Extractor:

 

MacAtt%20V2.6.png

 

'Choose Tags' Dialog:

 

MacAttTagOrder.png

 

Options Dialog:

 

OptionsV2-8.png

 

 

Attribute Editor:

 

Prev.png

 

Function Syntax: MacAttEdit / MacAttExt / MacAtt

 

 

;;;¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,;;;
;;;ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,¤º°`°º¤;;;
;;                                                                               ;;
;;                                                                               ;;
;;              --=={  Global Attribute Editor & Extractor  }==--                ;;
;;                                                                               ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;                                                                               ;;
;;  AUTHOR:                                                                      ;;
;;                                                                               ;;
;;  Copyright © Lee McDonnell, June 2009. All Rights Reserved.                   ;;
;;                                                                               ;;
;;      { Contact: Lee Mac @ TheSwamp.org, CADTutor.net }                        ;;
;;                                                                               ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;                                                                               ;;
;;  VERSION:                                                                     ;;
;;                                                                               ;;
;;  ø 1.0  ~¤~       11th June 2009   ~¤~ º First Release                        ;;
;;...............................................................................;;
;;  ø 1.1  ~¤~       12th June 2009   ~¤~ º Added Suggestions                    ;;
;;                                        º General Bug Fixes.                   ;;
;;...............................................................................;;
;;  ø 1.2  ~¤~   24th November 2009   ~¤~ º Code updated.                        ;;
;;...............................................................................;;
;;  ø 1.3  ~¤~   17th January  2010   ~¤~ º Updated to include ability to        ;;
;;                                          process SubDirectories.              ;;
;;...............................................................................;;
;;  ø 1.4  ~¤~   18th January  2010   ~¤~ º Updated Excel format to group        ;;
;;                                          attribute tags.                      ;;
;;...............................................................................;;
;;  ø 1.5  ~¤~   20th January  2010   ~¤~ º Added Dialog Interface.              ;;
;;...............................................................................;;
;;  ø 1.6  ~¤~   21st January  2010   ~¤~ º Updated code to account for open     ;;
;;                                          drawings within folder.              ;;
;;...............................................................................;;
;;  ø 1.7  ~¤~   24th January  2010   ~¤~ º Added ability to select Tags to      ;;
;;                                          extract.                             ;;
;;                                        º Modified code to correct order of    ;;
;;                                          extracted attributes.                ;;
;;...............................................................................;;
;;  ø 1.8  ~¤~   29th January  2010   ~¤~ º Updated code for ObjectDBX Document  ;;
;;                                          object aquirement.                   ;;
;;...............................................................................;;
;;  ø 1.9  ~¤~   2nd February  2010   ~¤~ º Added option to process current      ;;
;;                                          drawing only.                        ;;
;;                                        º Updated code to process dynamic      ;;
;;                                          blocks.                              ;;
;;                                        º Added Progress Bar.                  ;;
;;...............................................................................;;
;;  ø 2.0  ~¤~   5th February  2010   ~¤~ º Added config file to save dialog     ;;
;;                                          setup.                               ;;
;;...............................................................................;;
;;  ø 2.1  ~¤~   8th February  2010   ~¤~ º Added Global Attribute Editor.       ;;
;;...............................................................................;;
;;  ø 2.2  ~¤~   8th February  2010   ~¤~ º Added compatibility for older        ;;
;;                                          versions.                            ;;
;;...............................................................................;;
;;  ø 2.3  ~¤~  11th February  2010   ~¤~ º Updated code for Get_Unique function ;;
;;                                          with a 40% speed increase.           ;;
;;                                        º In Extractor: Block Tags will be     ;;
;;                                          displayed when blocks are selected   ;;
;;                                          from drawing.                        ;;
;;                                        º In Editor: Tags and Current Values   ;;
;;                                          will be added to list when block is  ;;
;;                                          selected.                            ;;
;;                                        º In Extractor: Block name can be      ;;
;;                                          changed when double-clicking on      ;;
;;                                          entry.                               ;;
;;...............................................................................;;
;;  ø 2.4  ~¤~  14th February  2010   ~¤~ º Updated program selection prompt.    ;;
;;...............................................................................;;
;;  ø 2.5  ~¤~     11th March  2010   ~¤~ º Added option to allow user to choose ;;
;;                                          whether to write drawing filenames.  ;;
;;                                          [ideal for creating a DWG List].     ;;
;;...............................................................................;;
;;  ø 2.6  ~¤~     17th March  2010   ~¤~ º Replaced toggle V2.5 addition with   ;;
;;                                          Options dialog to choose Excel       ;;
;;                                          format.                              ;;
;;                                        º Sorted data by Block Name in all     ;;
;;                                          modes when writing to Excel.         ;;
;;...............................................................................;;
;;  ø 2.7  ~¤~     22nd March  2010   ~¤~ º Added code to allow user to control  ;;
;;                                          the order in which attributes are    ;;
;;                                          written to Excel.                    ;;
;;...............................................................................;;
;;  ø 2.8  ~¤~      6th April  2010   ~¤~ º Added ability to extract Block       ;;
;;                                          Coordinates.                         ;;
;;...............................................................................;;
;;                                                                               ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;                                                                               ;;
;;;¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,;;;
;;;ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,¤º°`°º¤;;;

 

--=={ Code Updated to Version 2.8 }==--

 

Thank you,

I tried to run the lsp and it's running with autocad but nothing results in excel ?! could you help me ?

Posted

What version of Excel are you using? Do you get an error?

Posted
What version of Excel are you using? Do you get an error?

 

EXCEL 2010, message > , could you explain me the difference between your lsp and the standard extract attributes of Autocad ?

 

In the second the result it's a txt file delimited that you can manage by excel too.

 

I use autocad for electrical dwg and I would like to extract data from blocks, for managing the materials purchasing order

 

Thank you

Posted

One of the advantages of my program over Data Extraction is that it can process multiple drawings at the same time.

 

I have never tested it with Excel 2010 (that only just been released hasn't it?).

 

Seeing that it shows 0 Drawings processed, were there actually drawings in the directory you pointed it to?

Posted
One of the advantages of my program over Data Extraction is that it can process multiple drawings at the same time.

 

I have never tested it with Excel 2010 (that only just been released hasn't it?).

 

Seeing that it shows 0 Drawings processed, were there actually drawings in the directory you pointed it to?

 

Yes it's new release from MS, no the drawing it's in another directory different from that I wold like to have the data.

Thank you

Posted

The data will be written to an open Excel sheet - the program will process all drawings in a selected directory/subdirectories. This should be explained in the first post and the program header.

Posted
The data will be written to an open Excel sheet - the program will process all drawings in a selected directory/subdirectories. This should be explained in the first post and the program header.

 

Thank you, now seems to work fine.

Nay I suggest you to order also the data ? eg greater to lower ? or the opposite ?, I know to do this with excel could be more easy but it's only a suggestion.

 

I'm working with one block only in different layers.

 

Thank You again

Posted

You can order the data - the blocks are written alphabetically, and the tag order can also be changed.

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