Automatic data extraction

Automatic data extraction

Anonymous
Not applicable
4,011 Views
5 Replies
Message 1 of 6

Automatic data extraction

Anonymous
Not applicable

Hi!

 

I am trying to create a small VBA code (from excel) that allows me to do a new dataextraction everytime, and create an Excel file (not necessary to be linked with the drawing, i just want the file extracted). 

Lets picture the situation:

 

I have 100 drawings that contains the information more or less in the same shape. I want to run my code once for each drawing. 

I have found a solution to an extent:

Sub dataextraction()
AutoCAD.Application.ActiveDocument.SendCommand ("-dataextraction" & vbCr & "C:\Users\alvar\OneDrive\Documentos\pruebaDirectos1.dxe" & vbCr & vbCr)

End Sub

 

It works, but it creates an excel file with the data of the drawing which the .dxe file comes from.

What i really want is to do an extraction from scratch, but with an specific shape previously set.

Is it possible somehow? it would be very useful because i could skip the dataextraction wizard every time i do the extraction, since i have a great deal of documents.

 

Thank you very much

Regards

0 Likes
4,012 Views
5 Replies
Replies (5)
Message 2 of 6

cadffm
Consultant
Consultant

If you find a way to create/edit a dxe file well, sure (i dont know how, there are some chars they make it impossible for me).

Dirty workaround: If the only thing what you want to change in it is the filename (note: dxe setting only for one file).

Then you can create a dummy file like Z:/CAD-STUFF/Blocks/DXE-TEMPLATE.dwg with all your needed items for setting of Z:/CAD-STUFF/Blocks/DXE-TEMPLATE.dxe.

Now you can copy a file to Z:/CAD-STUFF/Blocks/DXE-TEMPLATE.dwg and the predefined dxe works well.

(or copy the file content to the existing DXE-TEMPLATE.dwg, that should be faster in some cases if you are using object dbx)

 

Via .Net Api the dataextract functionality is available, but for VBA and LISP i mean that isnt possible, except you find the way to create well working dxe files.

 

Edit: The best way is to write your own export program.

Sebastian

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi,

 

I dont have a high knowledge in how .NET works..I have readen several overviews about that topic..How long would it take me to learn how to costumize AutoCAD with this kind of tool from scratch (im not a proffesional developer, but i have programmed several times)? Would you recommend me any course, guide?

 

I think i will take in learning how to costumize AutoCAD in this way, since it looks that with VBA the task might be sort of dull.

 

Thank you very much,

Álvaro

0 Likes
Message 4 of 6

norman.yuan
Mentor
Mentor

I agree with @cadffm that the bets solution would be to develop your own data extracting/exporting tool. I would do it from AutoCAD side, not from Excel VBA side, because you need to process many drawings, automating AutoCAD from external app (Excel) would be very slow, and you limit the data only being exported into *.xls format.

 

It totally doable with either LISP, AutoCAD VBA, or AutoCAD .NET API. You should separate the exporting process into 2 functional part: extracting needed data from drawing and saving the data to external data store, be it Excel sheet, text file, XML file, or some sort of database. You can write different data saving code to save data without affect how data in searched/extracted from drawing file.

 

If you have already know enough on AutoCAD VBA, you can go ahead to do it, but be warned, if you use 64-bit AutoCAD (who does not these days?), there is very limited 64-bit COM components, especially UI components, support. Once your VBA program get more matured, you would find it is difficult to enhance it more with 64-VBA. 

 

Going with AutoCAD .NET API would be much better option. But the learning curve is quite steep if you have not done much .NET programming in general and AutoCAD programming in particular.

 

If you are willing to start to learn AutoCAD programming with this tool in mind, I'd suggest not waste time on VBA, go with Acad .NET API, unless you already know enough VBA and only want a quick, not so elegant solution.

 

Maybe, find someone who is qualified to do it for you would be easier option with cost (anywhere from a few hundreds or a few thousands $, depending on the details).

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 6

Anonymous
Not applicable

Hi!

 

I am searching for a while already to install this code to make an automatic data-extraction.
But I always have an error in the VBA.
I already called the local IT-service but they can't help me either.

 

They think it will be a mistake in the command as Excel doesn't recognize it.
But this would be strange as I copied it.

 

This is my code:  

Sub dataextraction()

AutoCAD.Application.ActiveDocument.SendCommand ("-dataextraction" & vbCr & "C:\temp\test\Dataextraction.dxe" & vbCr & vbCr)

End Sub

 

 

Could the problem be in the version of autocad en excell? (Mine are resp. 2019 & 2016).

I also opened the autocad file and made a dataextraction first, but it still doens't recognize the code.


@Anonymous wrote:

Hi!

 

I am trying to create a small VBA code (from excel) that allows me to do a new dataextraction everytime, and create an Excel file (not necessary to be linked with the drawing, i just want the file extracted). 

Lets picture the situation:

 

I have 100 drawings that contains the information more or less in the same shape. I want to run my code once for each drawing. 

I have found a solution to an extent:

Sub dataextraction()
AutoCAD.Application.ActiveDocument.SendCommand ("-dataextraction" & vbCr & "C:\Users\alvar\OneDrive\Documentos\pruebaDirectos1.dxe" & vbCr & vbCr)

End Sub

 

It works, but it creates an excel file with the data of the drawing which the .dxe file comes from.

What i really want is to do an extraction from scratch, but with an specific shape previously set.

Is it possible somehow? it would be very useful because i could skip the dataextraction wizard every time i do the extraction, since i have a great deal of documents.

 

Thank you very much

Regards


 

 

Thank you very much

Kind regards

Sofie

0 Likes
Message 6 of 6

Ed__Jobe
Mentor
Mentor

@Anonymous wrote:

They think it will be a mistake in the command as Excel doesn't recognize it.
But this would be strange as I copied it.

 

It's not an Excel command. Its meant to be run in AutoCAD's VBA environment.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature