AutoCAD Map 3D Developer
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Re: Does it have Object Data? vb.net
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I am reading a CAD drawing, creating a MDB file and writing out the data.
However, I will comment out the call to the other routines to simplify it.
The section call is TextExtractOBJData and I am passing a selection set.
the dwg file Text.dwg is in the Vb.net project folder.
thanks for looking into this. Any suggestions or recommendations are welcomed.
Re: Does it have Object Data? vb.net
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
I did what I could do, but some objects are unclear to me, e.g. the object "tables" you reference but never declared or assigned anything to it. That's your job.
Therefor (and for the reason I currently have 64bit running) I could not start anything as you have some ADOX-/MDB-access.
A tip for the future: use "strict on" in your project settings. It's a little bit more code to write as then late-binding is disabled by default and you have to use some TryCast or CType coding, but the code will run more stable as you see type-mismatches while code-writing and not as exceptions at customer-place. ![]()
Good luck, - alfred -
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Re: Does it have Object Data? vb.net
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
What you see is simply a cut and paste of the sample from the Autodesk site.
So I too do not know what the object "Table" refers too.
basically at this point all I want is a routine that I can pass an object and it returns it's object data.
thanks for helping
Re: Does it have Object Data? vb.net
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
EUREKA, I filnally got it !!!!
I did some more digging in the documentation and pulled all the pieces together.
just in case some other poor sap like me needs to extract object data.
Here is the code.
References are AcDbMgd, AcMgd, managedMapApi
Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.Gis.Map.ObjectData
Imports Autodesk.Gis.Map
Private Sub TestExtractOBJData(ByRef acSSet As SelectionSet)
Dim doc As Document = Application.DocumentManager.MdiActiveDocument()
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim mapApp As MapApplication
mapApp = HostMapApplicationServices.Application
Dim activeProject As Autodesk.Gis.Map.Project.ProjectModel = mapapp.ActiveProject
Dim tableList As Autodesk.Gis.Map.ObjectData.Tables = activeProject.ODTables
'get specific table = "MyTable"
Dim table As ObjectData.Table = tableList("MyTable")
'Dim acEditor As Editor = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.MdiActiveDocument.Editor
'start a transaction
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManag er = db.TransactionManager
Dim myT As Transaction = tm.StartTransaction()
Using myT
Try
'loop through object in the selection set
For Each sobj As SelectedObject In acSSet
Dim ent As Entity = myT.GetObject(sobj.ObjectId, OpenMode.ForRead)
If TypeOf ent Is DBText Then
Dim tt As DBText = DirectCast(ent, DBText)
Dim fieldDefs As ObjectData.FieldDefinitions = table.FieldDefinitions
Dim recs As ObjectData.Records
recs = table.GetObjectTableRecords(0, sobj.ObjectId, Constants.OpenMode.OpenForRead, True)
'check if there are records for the selected table
If (recs.Count() > 0) Then
For Each rec As ObjectData.Record In recs
'get object data for each record in table
For i As Integer = 0 To rec.Count() - 1
Dim val As Autodesk.Gis.Map.Utilities.MapValue
val = rec(i)
Dim fieldDef As ObjectData.FieldDefinition
fieldDef = fieldDefs(i)
ed.WriteMessage(vbNewLine + fieldDef.Name + ": ")
Select Case val.Type
Case Constants.DataType.Character
ed.WriteMessage(val.StrValue)
Case Constants.DataType.Integer
ed.WriteMessage(val.Int32Value.ToString)
Case Constants.DataType.Point
ed.WriteMessage("point")
Case Constants.DataType.Real
ed.WriteMessage(val.DoubleValue.ToString)
Case Else
ed.WriteMessage("undefined")
End Select
Next
Next
End If
recs.Dispose()
End If
Next
myT.Commit()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage(vbLf & "{0}" & vbLf & "{1}", ex.Message, ex.StackTrace)
End Try
End Using
End SubBig thanks to alfred for spending time and patients with me
cheers
Re: Does it have Object Data? vb.net
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
>> I did some more digging in the documentation and pulled all the pieces together.
That's how development works ![]()
Great you could solve it and that you published it here for others (not all do that)!
- alfred -
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Re: Does it have Object Data? vb.net
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
OK great. Now that it finds the Object Data I want to highlight the drawing objects (perhaps by changing the object's color) that have an empty field for their Object Data record (i.e. the data was not entered and the field value and is now blank or empty).
Once those objects are identified on the drawing (perhaps by turning their color to RED) , the Object Data for these drawing objects can then be altered to contain a non-blank entry.



