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.
Solved! Go to Solution.
Solved by Alfred.NESWADBA. Go to Solution.
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?
- alfred -
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
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 -
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?
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 -
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 -
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 -
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 -
Can't find what you're looking for? Ask the community or share your knowledge.