AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AutoCAD Map 3D Extract ODrecords

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
chase.hochstrasser
1240 Views, 12 Replies

AutoCAD Map 3D Extract ODrecords

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.

12 REPLIES 12
Message 2 of 13

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 13

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

 

Message 4 of 13

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 13

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?

Message 6 of 13

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 7 of 13

i need to know the what each drawing contains to list which drawing connects to what data.
Message 8 of 13

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 9 of 13

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

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 11 of 13

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.
Message 12 of 13

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 13 of 13

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost