Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Link between AutoCad and Access 2

Status
Not open for further replies.

HanKleppe

Programmer
Mar 17, 2005
50
NL
Hi,

I'm a newbie on this forum.

The case:

In our company we use AutoCad2004 and Access97. I want to set up a link between this two.

We have over 3000 drawings (in *.DWG format). The drawer makes some blocks below the drawing with some variable information.

Bitmapafbeelding.JPG


Now I wanna link this information with Access. I've tried it with DBManager but there not a lot information about this. The form must be something like this:

naamloos.JPG


Who can help me in the next steps?

Many thanks in forward!
 
Hi Todd,

I use the filename in my database for the tagstring "Locatie bestand" like this: C:\Documents and Settings\terrier.TERRIERCLAMPS\Bureaublad\Testcase Access Autocad\850000.dwg

maybe is here the fault?? I have nog attribute tag in my drawing what's name is "Locatie bestand" It's the filename...

Han
 
Yep, that's the problem, change this portion of the code:

Code:
  For intAttribCnt = LBound(varAttribs) To UBound(varAttribs)
    If UCase(varAttribs(intAttribCnt).TagString) = "Locatie bestand" Then
      ' Now search for the existence of this record in the database
      ' and if there's a match, ask the user how to handle it.
      '
      strSearch = varAttribs(intAttribCnt).TextString
      Exit For
    End If
  Next intAttribCnt

To:

Code:
strSearch = ThisDrawing.Path & "\" & ThisDrawing.Name

And below this section of code:
Code:
  ' Walk the array, comparing tag strings to field names,
  ' and populating or updating accordingly.
  '
  For intAttribCnt = LBound(varAttribs) To UBound(varAttribs)
    For Each fldAttribs In rstAttribs.Fields
      ' Does the tag string value match the field name?
      '
      If UCase(fldAttribs.Name) = UCase(varAttribs(intAttribCnt).TagString) Then
        ' Must have the right tag string mapped to the correct field name,
        ' update the field.
        '
        fldAttribs.Value = varAttribs(intAttribCnt).TextString
        Exit For
      End If
    Next fldAttribs
  Next intAttribCnt

Add this:

Code:
rstAttribs.Fields("file name").Value = strSearch

Todd
 
Hi Todd,

I'm home now, it's tommorow Good Friday (free translation :eek:)) So I can check your code next week. Are you working within this sector? You know a lot about this! (I hope you will be the best helper member of the week, i push all the stars :))

Good weekend!!!

gr,

han
 
Hi Han,

Yes I do work in this sector, I do a lot of AutoCAD customization and thanks for the stars!

Have a great weekend!

Todd
 
hi Todd,

I'm back in bussiness :) You have a good weekend?

I apply the changes but there's an error. Is there a possibility i can send the documents to you?

Greetz,

Han
 
Hi Han,

My weekend was great, just too short. Yes you can send me the documents, send them to edgi3ATjunoDOTcom.

Todd
 
Hi Han,

You had two problems with your routine which were minor:

This line of code:
Code:
rstAttribs.Fields("file name").Value = strSearch

Should have read:
Code:
rstAttribs.Fields("Locatie bestand").Value = strSearch

The other problem you will have is dealing with blank fields. In your database table "toddiscool", you have your text fields; OMS, MAT, OPP, HARD, GET, EEN, SCH, and FOR, all set to NOT accept zero length strings. You'll need to either change this in Access to allow the field to accept zero length strings, or you'll need to modify your code to trap on this condition.

HTH
Todd
 
Hi Han,

Hit the submit button too fast...

Your code could be modified to this to trap on zero length strings:

Code:
fldAttribs.Value = IIf(Len(varAttribs(intAttribCnt).TextString) = 0, "N/A", varAttribs(intAttribCnt).TextString)

HTH
Todd
 
Hi Todd,

I changed the code like this way:
Code:
        'fldAttribs.Value = varAttribs(intAttribCnt).TextString
        fldAttribs.Value = IIf(Len(varAttribs(intAttribCnt).TextString) = 0, "N/A", varAttribs(intAttribCnt).TextString)

The program connect to the database, ask if i want to overwrite an ask it another time. After that i get an error like: (code 3265) Can't find the item in the collection with the wanted number or text.

Gr,

Han
 
Hi Han,

Did you make the change below:

This line of code:

Code:
rstAttribs.Fields("file name").Value = strSearch
Should have read:

Code:
rstAttribs.Fields("Locatie bestand").Value = strSearch

I got the same error, and it was the lines above.

HTH
Todd
 
Hi Todd,

Sorry for my time offline. I'm working in this company as a stagaire (i don't know the English word for it, it means that i'm a student, so i'm 3 days in school and 2 days in a company)
Back to business, it works very great!! Many thanks!
Can I with the same program import the items?

Greets!

Han
 
Hi Han,

Glad to hear it's working for you...

By import the items I'm guessing you mean enter or edit the data in Access and then run the routine and have it update the title block in AutoCAD? If that's the case, you can, however not with code as supplied, you'd need to modify it to edit the attributes instead of just reading them.

HTH
Todd
 
Hi Todd,

I post yesterday a reply but I think something is wrong (maybe you cannot post more than ... threads?)

By import I mean the same procedure as export but the other way. In access I modify my table (in a form) hit a populate button and the program runs en copy the values of the table in the Titleblock.

Is that possible with the same program of with copy the program to another project en modify it?

Thanks in forward!
Han
 
Hi Han,

Give me just a little bit and I'll show how that's done...

Todd
 
Hi Todd,

I want it with the same examples which I send to you. (I can send them another time). So no tablenames, titleblocks etc are changed all is the same.

Have a nice workingday (it's morning by you?)

Han
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top