TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: V-Man on September 29, 2005, 03:32:44 PM

Title: Block Att Export?
Post by: V-Man on September 29, 2005, 03:32:44 PM
Is there anything out there that will export all of a particular blocks attributes into either Excel or Access?

I have numerous blocks with the same name and they are full of attrinutes with specific room information.

I am using Autcad 2002.
Title: Re: Block Att Export?
Post by: Bob Wahr on September 29, 2005, 04:01:53 PM
Do you have express tools loaded?  If so you can use ATTOUT which exports to a txt file that can then be opened in excel.
Title: Re: Block Att Export?
Post by: V-Man on September 29, 2005, 04:24:23 PM

Quote
Do you have express tools loaded?  If so you can use ATTOUT which exports to a txt file that can then be opened in excel.

Yes, I do have Express Tools but I need a routine to export all occurrences of a block's attributes to create 1 database. Wether that is Excel or Access
Title: Re: Block Att Export?
Post by: Bob Wahr on September 29, 2005, 04:26:30 PM
OK, and?
Title: Re: Block Att Export?
Post by: MP on September 29, 2005, 05:17:51 PM
<Friendlies on, but ...> I don't mean to be rude, but does anyone read the manuals or press F1 anymore? The native AutoCAD AttExt command will export attribute data (true, you have to configure it, but it's so easy I can do it) in comma, space or tab delimited formats, and Excel and Access both have the native ability to parse and import said data (as does any reasonably capable spreadsheet or database program written in the last ten years). True, there's a wealth of utilities out "there" that will hand hold you thru the attribute exporting process, but there's a lot of power in the native product, with or without additional programming that is overlooked and/or untapped.

:)
Title: Re: Block Att Export?
Post by: David Hall on September 29, 2005, 05:20:15 PM
I dont use F1 because my machine pauses for 30 seconds while it loads.  Cant have that....
Title: Re: Block Att Export?
Post by: Kerry on September 29, 2005, 06:00:56 PM
You guys are SO lucky that Tony T. doesn't post here when he visits.
Title: Re: Block Att Export?
Post by: V-Man on September 29, 2005, 06:27:03 PM

Quote
<Friendlies on, but ...> I don't mean to be rude, but does anyone read the manuals or press F1 anymore? The native AutoCAD AttExt command will export attribute data (true, you have to configure it, but it's so easy I can do it) in comma, space or tab delimited formats, and Excel and Access both have the native ability to parse and import said data (as does any reasonably capable spreadsheet or database program written in the last ten years). True, there's a wealth of utilities out "there" that will hand hold you thru the attribute exporting process, but there's a lot of power in the native product, with or without additional programming that is overlooked and/or untapped.

 :x :x :x :x
Title: Re: Block Att Export?
Post by: Kerry on September 29, 2005, 06:28:57 PM
Whoa !! nasty faces.
Title: Re: Block Att Export?
Post by: Jeff_M on September 29, 2005, 06:56:20 PM
And with EATTEXT you don't even need to select the blocks.....
Title: Re: Block Att Export?
Post by: MP on September 29, 2005, 07:01:21 PM
Yep, and if you pass the path to a valid delimited file to excel / access via a command line (startapp etc) it will automatically load or link to it (respectively).
Title: Re: Block Att Export?
Post by: MP on September 29, 2005, 07:13:01 PM

Quote
<Friendlies on, but ...> I don't mean to be rude, but does anyone read the manuals or press F1 anymore? The native AutoCAD AttExt command will export attribute data (true, you have to configure it, but it's so easy I can do it) in comma, space or tab delimited formats, and Excel and Access both have the native ability to parse and import said data (as does any reasonably capable spreadsheet or database program written in the last ten years). True, there's a wealth of utilities out "there" that will hand hold you thru the attribute exporting process, but there's a lot of power in the native product, with or without additional programming that is overlooked and/or untapped.

 :x :x :x :x

Sorry to hear you feel that way Don. How should I have worded it?
Title: Re: Block Att Export?
Post by: V-Man on September 30, 2005, 08:02:20 AM

Let's see. For starters I have numerous drawings to extract the attribute information from and I do not want to extract everything using EATTEXT. As I stated previously....

Quote
Is there anything out there that will export all of a particular blocks attributes into either Excel or Access?

Not every attributed block in the drawing. Also, since I do have numerous drawings to do this on I want it to create 1 database file (Excel or Access) Append if you will, so that I do not have to do extra combining of all of the txt files that get produced using ATTOUT and EATTEXT.

Does this clear things up?
Title: Re: Block Att Export?
Post by: MP on September 30, 2005, 09:47:38 AM
Quote
Is there anything out there that will export all of a particular blocks attributes into either Excel or Access?

The attext command will let you select blocks interactively or by using "_previous" to retrieve a selection set made previously via the "select" command or (ssget) etc.

If I recall you lisp, so a very simple snip to illuminate --

Code: [Select]
(if     
    (setq ss
        (ssget "x"
           '(   
                (0 . "insert")
                (2 . "MyBlockSpec")
                (66 . 1)
            )
        )
    )
    (command
        ".attext"
        "_objects"
        ss
        ""
        "_cdf"
        "path/myTemplate.txt"
        "path/myData.csv"
    )
)

Appending umpteen csv files can be as easy as (dos command line) --

Code: [Select]
for %i in (*.csv) do type %i >> MyNewFile.csv
Or batch file --

Code: [Select]
for %%i in (*.csv) do type %%i >> MyNewFile.csv
As noted previously, Excel / Access have native ability to process delimited files.

Of course, all of this can be scripted, automated, programmed to varying degrees, using native commands as noted or doing a full scale assualt using the development language of your choice, extracting exactly what you want and the using ADO to create and then populate a database. It's not hard, I've done it, but it's more information than I care to type today so you will have to do some research of your own (http://groups.google.ca/groups?hl=en&q=extract+attributes+database&qt_s=Search).

But this --

Quote
Is there anything out there that will export all of a particular blocks attributes into either Excel or Access?

I have numerous blocks with the same name and they are full of attrinutes with specific room information.

I am using Autcad 2002.

Didn't suggest to me anything was needed beyond vanilla AutoCAD.
Title: Re: Block Att Export?
Post by: V-Man on October 06, 2005, 09:01:32 AM

When using the

Code: [Select]
(if     
    (setq ss
        (ssget "x"
           '(   
                (0 . "insert")
                (2 . "MyBlockSpec")
                (66 . 1)
            )
        )
    )
    (command
        ".attext"
        "_objects"
        ss
        ""
        "_cdf"
        "path/myTemplate.txt"
        "path/myData.csv"
    )
)

It wants a template. I looked in the HELP and I cannot find what is the template suppose to look like. I tried to leave this part blank and do not specify a template but it will not work unless I specify a template. Can anyone shed some light on what should the contents of the template should look like?

Thanks
Title: Re: Block Att Export?
Post by: Bob Wahr on October 06, 2005, 11:32:41 AM
I'm going to remention my first suggestion.  It sounds to me like attext has more functionality, not to mention options, than you need.  Just use the express tools ATTOUT.
Title: Re: Block Att Export?
Post by: Mark on October 06, 2005, 02:52:43 PM
This explains how to make a template file.
Title: Re: Block Att Export?
Post by: Sdoman on October 06, 2005, 03:14:27 PM
BTW,

AutoCAD 2006 comes with a new wiz bang "native" command that makes extracting attribute information to a CSV file a cake walk.  I know that the OP is using AutoCAD 2002 so this info doesn't help him/her.  But this new feature is a killer command and might be worth the upgrade price if you need this tool.  Otherwise, I agree that the Express tool command is a good choice.  It also has the capability to read in attribute data from an external file.

-Steve
Title: Re: Block Att Export?
Post by: Andrea on October 10, 2005, 11:04:07 PM
Is there anything out there that will export all of a particular blocks attributes into either Excel or Access?

I have numerous blocks with the same name and they are full of attrinutes with specific room information.

I am using Autcad 2002.

Yes, with AutoCAD 2006