Jump to content
Guiboard

Link Table to Attributes

Recommended Posts

Guiboard

Hi everyone,

 

I would like to read a table that would be linked with block attributes. Like a table (either AutoCAD or Excel) of fluids with pressure, temperature, flowrate... that I would link to attributes. I tried to insert a field in the attribute, but what I've found in fields are properties like Color/Layer/Column/Rows ... Anyone could help?

 

Guiboard

Share this post


Link to post
Share on other sites
ReMark

Isn't there a DATAEXTRACTION command in 2009? This command extracts data and sends it to a table or an external file such as an Excel spreadsheet.

Share this post


Link to post
Share on other sites
Guiboard

I know about Data extraction, which extracts block attributes into Excel/AutoCAD table. But is the opposite possible? Extracting data from a table into blocks via fields?

 

Edit: I found it by myself! It had to insert a field; Field category - Object // Field names: Formula. There are 4 buttons: Average/Sum/Count/Cell . Using cell I could pick an AutoCAD table cell.

 

But I still have 1 question,

Is there a way to link via an Excel table?

Edited by Guiboard

Share this post


Link to post
Share on other sites
divekark

hi there

 

i am also intrested in the same.

i have made a VBA code to import data from excel which can be extended for the required purpose

 

Sub markdupfromxl()
Dim xlApp As Object
Dim xlFileName As String
Dim getval(), getval1() As String
Dim obj, entRef As AcadBlockReference
Dim instPt() As Double
Dim a, b As Integer
xlFileName = "C:\Documents and Settings\divekark\Desktop\test duplicates.xls"
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
Set xlbook = xlApp.workbooks.Open(xlFileName)
Set xlSheet = xlbook.Sheets(1)
a = xlSheet.UsedRange.Rows.Count
ReDim getval(a), getval1(a)
For b = 0 To a - 2
Set myrng = xlSheet.Range("A1")
getval(b) = myrng.Offset(b + 1, 0).Value
getval1(b) = myrng.Offset(b + 1, 1).Value
Set obj = ThisDrawing.HandleToObject(getval(b))
instPt = obj.InsertionPoint
Set entRef = ThisDrawing.ModelSpace.InsertBlock(instPt, "flage2", 1#, 1#, 1#, 0)
   If entRef.HasAttributes Then
       Dim AttList As Variant
       ' Build a list of attributes for the current block.
       AttList = entRef.GetAttributes
       ' Cycle throught the list of attributes.
       For j = LBound(AttList) To UBound(AttList)
           If AttList(j).TagString = "FLAGTEST" Then
               AttList(j).TextString = getval1(b)
           End If
       Next
   End If
Next
xlbook.Close
xlApp.Quit
Set xlbook = Nothing
Set xlSheet = Nothing
ThisDrawing.Activate
End Sub

 

if you tell me some thing more may be i can help you.

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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