AutoCAD Map 3D Extract ODrecords

AutoCAD Map 3D Extract ODrecords

Anonymous
Not applicable
2,822 Views
12 Replies
Message 1 of 13

AutoCAD Map 3D Extract ODrecords

Anonymous
Not applicable

I have been looking for help in extracting ObjectData Records from Drawings. I have about 8,000 drawings to extract one piece of data from each. My problem is how to do this fast and without any errors. I have been able run vb.net code like this

 

Dim newDoc As Document = Application.DocumentManager.Open(drawingFile, True, "")

 

to open the drawing and then

 

newDoc.CloseAndDiscard()

 

to close the drawing after I get the ODRecords. If I do it this way, it will take a couple of days until it will complete with an error. Do you know anyway to reduce the time and to resolve the error?

 

note: i will post the error after once i run into it again.

0 Likes
Accepted solutions (1)
2,823 Views
12 Replies
Replies (12)
Message 2 of 13

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

where do you want to extract the odrecords to? Might it be enough to connect to your drawings using command _ADEDRAWINGS and then run _ADEQUERY with the option report to create an ascii file from the odrecords?

 

2013-12-19 07-51-30.png

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 13

Anonymous
Not applicable

I like your Idea and i will try this out. my issue now is how to do this in vb.net?

 

I have some code but i'm stuck now on how to finish it correctly.

                    '' Attach drawing
                    Dim proj As ProjectModel = HostMapApplicationServices.Application.ActiveProject
                    Dim dwgSet As DrawingSet = proj.DrawingSet
                    Try
                        dwgSet.AttachDrawing(drawingFile)
                    Catch ex As MapException
                        acDocEd.WriteMessage(ex.Message & " error code: " & ex.ErrorCode)
                    End Try

                    '' Clear the existing Query
                    Dim qryModel As QueryModel = proj.CreateQuery()
                    qryModel.Clear()

                    Dim qryBranch As New QueryBranch(Constants.JoinOperator.OperatorAnd)

                    '' Property Condition
                    Dim propertyCondition As PropertyCondition = New PropertyCondition
                    propertyCondition.JoinOperator = Constants.JoinOperator.OperatorAnd
                    propertyCondition.PropertyType = Constants.PropertyType.Layer
                    propertyCondition.ConditionOperator = Constants.ConditionOperator.ConditionEqual
                    propertyCondition.Value = "CP*"
                    qryBranch.AppendOperand(propertyCondition)
                    qryModel.Define(qryBranch)
                    qryModel.Mode = Constants.QueryType.QueryReport
                    qryModel.Run()

                    '' Detach drawing
                    Try
                        While dwgSet.DirectDrawingsCount > 0
                            dwgSet.DetachDrawing(0)
                        End While
                    Catch ex As MapException
                        acDocEd.WriteMessage(ex.Message & " error code: " & ex.ErrorCode)
                    End Try

 

0 Likes
Message 4 of 13

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

do you need that once for your 8000 drawings or will that be a daily process?

If you do that once I would create a stored query manually. Then connect to XXX drawings (number depends on size of those drawings) with your dotNET code and run the stored query. I would not try to get access to the odrecords object by object because that would need more time then the stored query (feeling, not measured).

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 13

Anonymous
Not applicable

I need to loop through each drawing and pull out the one ODRecord that i need out of the drawing then store it in the txt file. so, i will be attaching 8000 drawings, query the 8000 drawings individually, and detaching 8000 drawings. one by one.

i'm not sure about this method but it still seems like it should work.

 

Also, i should mention that my code is not correct becasue it does not save to a text file can i get some help with this?

0 Likes
Message 6 of 13

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

why not attaching 500 drawings, run the export and detach them and attach the next 500, ...

And to be save I would built in an options that let's AutoCAD Map3D restart if it crashed during the process (as I guess 8000 drawings will not be accessed without issues, but would be happy to hear it does not end in an exception 😉 ).

 

What reasons do you have to run in file-by-file and not a package of drawings in one step?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 7 of 13

Anonymous
Not applicable
i need to know the what each drawing contains to list which drawing connects to what data.
0 Likes
Message 8 of 13

Alfred.NESWADBA
Consultant
Consultant
Accepted solution

Hi,

 

>> i need to know the what each drawing contains to list which drawing connects to what data.

Look to my previous screenshot, the field .DWGNAME (3rd column to output) is the one that exports the drawing name in the exported line, so you know for each record in the ascii-file the source drawing where the data is coming from.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 9 of 13

Anonymous
Not applicable
I get it thank you so much, now i need to learn how to do that in VB.NET. thank you again.
0 Likes
Message 10 of 13

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

 

>> now i need to learn how to do that in VB.NET.

if you download the ObjectARX kit for Map3D from >>>there<<< there are query-samples included (Map Samples\DotNet\QueryViewVB).

I don't know at the moment if there is a sample for querying into a report, but hopefully it helps.

 

HTH, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 11 of 13

Anonymous
Not applicable
Hello Alfred.NESWADBA, Do you know how to "NOT" in vb.net, send to a text file only non duplicates. for example i'm getting 83 items that are exactly the same for one drawing. All i need is one of them.
0 Likes
Message 12 of 13

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

with the ADEQUERY-technology afaik there is no way to do that.

I would import then the ascii-file into a database (or datatable in memory) as you can use then a SQL statement with DISTINCT.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 13 of 13

Anonymous
Not applicable
dang i thought it would be less code and nice to just get out a filter. thanks so much for helping me.
0 Likes