PDA

View Full Version : Extracting Object Data into an Attributed Block



brennan.cunningham
2004-07-05, 09:44 PM
Hello Folks,
I was wondering how I can use VBA to extract object data information from an object and put that information into an attributed block. I think I have to go along the ODtable.getODRecords or ODFieldValue way but i'm not to sure how to go about it. If you could lead me in the right direction that would be wonderful.
Thank you

RobertB
2004-07-07, 07:46 PM
What version of AutoCAD are you using? If you have AutoCAD 2005, take a look at Fields.

mjfarrell
2004-07-07, 07:54 PM
If this user were to use fields then the question would
need to be how does he extract object data to fill in those fields?

Ed Jobe
2004-07-07, 08:05 PM
Only if he has 2005. I think Robert's just waiting for his response so that he doesn't provide an answer that's not needed.

richard.binning
2004-07-07, 08:35 PM
Hello Folks,
I was wondering how I can use VBA to extract object data information from an object and put that information into an attributed block. I think I have to go along the ODtable.getODRecords or ODFieldValue way but i'm not to sure how to go about it. If you could lead me in the right direction that would be wonderful.
Thank you
ODtable.getODRecords? Sounds suspiciously like the OpenDrawing libraries to me. Is that right?

mjfarrell
2004-07-07, 08:45 PM
The user is attempting to extract AutoDesk MAP
Object Data Records into block attributes.

brennan.cunningham
2004-07-07, 10:44 PM
Yes I am using Autocad Map 3D 2005. I was given this code as an example but it doesn't seem to work.

__________________________________________________________


Dim ODrcs As ODRecords
Dim returnObj As AcadObject
Dim i As Integer
Dim strMsg As String
Dim boolVal

Set amap = ThisDrawing.Application.GetInterfaceObject("AutoCADMap.Application")
Set ODrcs = amap.Projects.item(ThisDrawing).ODTables.item("MY_OD_TABLE_NAME").GetODRecords


'Prompt user to select an object
ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select an object"

boolVal = ODrcs.Init(returnObj, True, False)
strMsg = ODrcs.Record.tableName & vbNewLine
strMsg = strMsg & ODrcs.Record.objectID & vbNewLine

For i = 0 To ODrcs.Record.count - 1
strMsg = strMsg & ODrcs.Record.item(i).Value & vbNewLine
Next i

MsgBox strMsg
__________________________________________________________


I always get a run time error on this line:
Set amap = ThisDrawing.Application.GetInterfaceObject("AutoCADMap.Application")

any suggestions?

RobertB
2004-07-08, 12:31 AM
Do you have more than one version installed?

Does this make a difference?
Set amap = ThisDrawing.Application.GetInterfaceObject("AutoCADMap.Application.16.1")

Ed Jobe
2004-07-08, 02:47 PM
BTW, Brennan, It would have been helpful if you included this info with your first post. ;-)

brennan.cunningham
2004-07-08, 03:32 PM
Mr. Farrell helped me out - he suggested using an annotation template which extracted the object data information to a block. It was what I was looking for.

Thanks again Mr. Farrell

abare
2007-10-17, 07:58 AM
How do I compile?(stupid question)
How do I use?

Please help me.

Ed Jobe
2007-10-17, 05:29 PM
How do I compile?(stupid question)
Debug>Compile. However, vba does not compile to a separate file, just the dvb.


How do I use?
To use, the dvb has to be loaded. Search this forum for "vla-runmacro" or "vbarun" for tips on how to use.

abare
2007-10-19, 04:30 AM
I clicked the compile icon and the icon wasn't activated.

Could you let me know the next step?

Ed Jobe
2007-10-19, 02:21 PM
If it appears that nothing happened, the compile was successful. If there were errors in your code, the compiler would have stopped at the first error it found and highlighted it for you. Since the code is compiled to the dvb you are working on, you don't get any file dialogs.