Jump to content

Link Table to Attributes


Guiboard

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 5 months later...

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.

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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