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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract autocad attributes to access

Status
Not open for further replies.

kdoran

Technical User
Mar 23, 2003
88
US
Anyone have any luck extracting autocad attributes into access 2000?

Thanks,

Kelly

 
We extract data to a comma delimited format and then import
it into Access. It's quite simple. Directly
connecting AutoCAD to Access is a little more complicated.
What is your question?
 
mhaff,

What I would like to do is take the the title block and a few other blocks (not sure on the terms) or attributes and import them into an access database which could be through excel or a text file or other. I would like to be able to do more than one at a time. Any ideas

Thanks,

Kelly
 
Kelly,

Here is a sample of what I use to import all text from autocad to access directly. You can change the paameters to look for attribute block with specific titles. I call this function thru a loop to import over 1000 drawings.



Function Transfer_ACText_To_Access(sDwg As String, sLoc As String, Min As Integer, Max As Integer)
Dim value As Object
Dim rst As New Recordset
'Dim insertionPoint(0 To 2) As Variable
Dim currInsertionPoint As Variant
rst.Open "tblData", CurrentProject.Connection, adOpenStatic, adLockOptimistic
Set AC = Nothing
On Error Resume Next
Set AC = GetObject(, "AutoCAD.Application")
If Err <> 0 Then
Set AC = CreateObject(&quot;AutoCAD.Application&quot;)
MsgBox &quot;You have to open a dwg. file in AutoCad &quot; & _
&quot;first and let the commandline stay empty&quot;
Exit Function
End If

AC.Visible = False
Set doc = AC.ActiveDocument
Set mspace = doc.ModelSpace
For Each value In mspace
With value
If StrComp(.EntityName, &quot;AcDbMText&quot;, 1) = 0 Or StrComp(.EntityName, &quot;AcDbText&quot;, 1) = 0 Then
'Selection.TypeText Text:=.TextString This is for word
'Selection.TypeParagraph
If Len(.TextString) >= Min And Len(.TextString) <= Max Then
currInsertionPoint = .insertionPoint
rst.AddNew
rst.Fields(&quot;Data&quot;) = .TextString
rst.Fields(&quot;Layer&quot;) = .Layer
rst.Fields(&quot;Color&quot;) = .Color

rst.Update
rst.MoveNext
End If
End If
End With
Next value
rst.Close
value = Nothing
Set AC = Nothing
'MsgBox &quot;Finished&quot;
End Function



Praxden
 
Praxden,

I am pretty new at vba code and I am not sure which part of the code to change to look at the attribute block titles.

thanks,

Kelly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top