Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

AutoCAD to MS Access and Back

Status
Not open for further replies.

MrGriz

Civil/Environmental
Jun 11, 2003
6
Does anyone know of any good books on using VBA routines to take data from MS Access to control attributes and entities in AutoCAD? All the books I've seen have 10-15 pages on the subject but none go into depth on it.

Thanks for your help.
 
Replies continue below

Recommended for you

I only know how to do this 1 way so far. I can insert a block with defined attributes into an Autocad file and I can also pull out those defined attributes into access but I don't currently know how to change from access the attributes already in an autocad file. Would this information be of help?

tim
 
Sure it would be helpful. How did you learn to do that? It seems there is not a lot of documentation on hte interface between AutoCAD and MS Access.

Thanks.
 
I learned this mostly between this web site and the tek-tips site. (plus reading different help files once I heard of the commands)

(I am using Autocad lt 2000 and access 97)
(Do not use spaces or you may need to find other ways of doing this)

1st) how to make a "block" that includes useable text
under Draw/Block/Define attributes

Make Tag and prompt the same thing because its hard to find out what tag is later.
Specify piont, text height, etc
do this for as many tags as you intend to use (start with only 2 as you try to figure everything out)

2nd) Save the file (ex block.dwg) in an easy to reach location
(ex c:\Autocad\Blocks)

3rd) Close autocad and start Autocad again (just to have a clean slate

type -insert at the autocad prompt
It will ask you "Enter block name or [?]:" enter in your filename with path (c:\Autocad\Blocks\block.dwg)
now it will ask you about where to place it, what scale and angle
0,0,0 (location)
1 (x scale)
1 (y scale)
0 (angle)
then it gives you the prompt for your different text inputs
once your text inputs are in it will display everything on the screen.

4th) save the file under its new name

Now that the text is in there you can figure how to automate it by running a batch/script routine with the drawing

write a .scr file with the same text you just put in. (a .scr file is just a text file with the extension.scr)

-insert
c:\Autocad\Blocks\block.dwg
0,0,0
1
1
0
first_text_here
Second_text_here

you can run a script file from Autocad under tools/run script
you will also be able to do it by starting autocad with some extra text after it. (/b c:\autocad\blocks\script.scr)


now to extract(attribute extraction) the information you need to make a template file for Autocad. I'm running late so I'll explain this later. Let me know if you get through the first part .

Tim


 
The following is the format for at template file that you might just save as template.txt

First_tag_here c 040 000
Second_tag_here c 040 000


The trick about this is no extra spaces or [enters]

now the scrit file(access.scr) to extract the data is:

-attext
c
"c:\Autocad\Blocks\template.txt"
"c:\Autocad\Blocks\Access_Acad.txt"

you now have a file that contains all the tag information and you can import it into access

Let me know how it goes.

Tim
 
about the template file

First_tag_here c 040 000
Second_tag_here c 040 000

the c stands for text or string or someting like that
the 040 sets the limit of upto 40 characters and it can be changed. The 000 refers to decimal places when importing a number.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor