Jump to content

Excel to AutoCAD (Script vs VBA-DXF)


RFreund

Recommended Posts

I currently have a spreadsheet that performs certain calculations which return dimensions which I use to draw the objects in autocad. I would like to automate the processes by using either scripts or vba. I feel that if I could use several scripts but this would still require me to copy and paste the scripts and may become confusing depending on the size of the drawing and the number of scripts. I feel if I can learn to use VBA and create a Macro that I would have a more 'robust' program.

 

Can you suggest which you think is a more reasonable route to go?

Also I don't know much about how I would go about writing the dxf file. I mean I know that I would need to learn the syntax of it. Also I have came across a dxf library written in C++ http://www.qcad.org/dxflib/manual.pdf would this be of any help to me?

 

Thanks!

Link to comment
Share on other sites

Welcome to CADTutor!

 

Are you adept at developing for AutoCAD in any language in particular, or are you just starting out with code?

 

If familiar, consider using Visual LISP, or .NET for this task. Both can work with Excel, and have the advantage of speed over Scripts generally speaking. Additionally, both can be invoked from within AutoCAD allowing you to avoid the need for the DXFLib altogether. Not sure how in depth your Excel form is; perhaps a custom DCL form could replicate the need to even access Excel to begin with? If not certain a .NET Form, or Windows Presentation Foundation (WPF) User Control would do well - The latter requiring the availability of, and your being adept at .NET development (C#, VB.NET) with Visual Studio.

 

If unfamiliar with coding, you've certainly selected a monumental task for your pilot application!

 

Either way, I hope this helps (HTH)! :beer:

 

** Edit - I ignored mentioning VBA (until now) as VBA is considered dead or dying by much of the AutoCAD Development community. Microsoft has not supported it for years. You would do well to learn Visual LISP, and .NET instead.

Link to comment
Share on other sites

Thanks for the response and you are correct, I do predict this to be a monumental task if I accept it. I may use some scripts for now however I would like to explore the alternatives you suggested as I am currently learning php and I would like to learn other languages as well. Also a couple of my friends are familiar with VB and C+ (i think) and might be able to help some.

 

Maybe if I give you some more detail of what I'm trying to accomplish you can help push me in the right direction or let me know if it is doable.

 

Basically I have a bunch of data points (grade spot elevations which have a station and elevation) which are entered into the spreadsheet. Currently I have a script which will draw this polyline. I then place a grid of lines over these polylines (the top and bottom grade lines) to draw another set of poly lines (these are top and bottom of wall lines and the grid is how the wall steps up and down based on the top and bottom grade). I can write a routine in excel to draw these additional polylines lines and could use script for them. This process does not take long but there can be several walls and the process is repative so the time savings would add up if I could create a program where I only need to enter the data points and everything else is drawn (Top/bottom grade, top/bottom wall, grid is shown, stations, text labeling the lines, all in the correct layers, etc.). Now there is software out there that does this already but not exactly. Some do it only in excel with a graph others are there own programs which incoporate calcs. I'm not looking to develop a commercial program either but this could speed up our drafting process and make the boss happy. :)

 

Thanks again!!

Link to comment
Share on other sites

Thanks for the response and you are correct, I do predict this to be a monumental task if I accept it. I may use some scripts for now however I would like to explore the alternatives you suggested as I am currently learning php and I would like to learn other languages as well. Also a couple of my friends are familiar with VB and C+ (i think) and might be able to help some.

 

You're welcome. :)

 

With regard to developing for AutoCAD, .NET (C#, VB.NET), and ObjectARX (C++ for AutoCAD) are very different worlds. If you're not already adept at the former, then I would avoid the latter until you have more expertise (my $0.02).

 

To get started with AutoCAD .NET development, see this post for some useful links.

 

Maybe if I give you some more detail of what I'm trying to accomplish you can help push me in the right direction or let me know if it is doable.

 

Basically I have a bunch of data points (grade spot elevations which have a station and elevation) which are entered into the spreadsheet. Currently I have a script which will draw this polyline. I then place a grid of lines over these polylines (the top and bottom grade lines) to draw another set of poly lines (these are top and bottom of wall lines and the grid is how the wall steps up and down based on the top and bottom grade). I can write a routine in excel to draw these additional polylines lines and could use script for them. This process does not take long but there can be several walls and the process is repative so the time savings would add up if I could create a program where I only need to enter the data points and everything else is drawn (Top/bottom grade, top/bottom wall, grid is shown, stations, text labeling the lines, all in the correct layers, etc.). Now there is software out there that does this already but not exactly. Some do it only in excel with a graph others are there own programs which incoporate calcs. I'm not looking to develop a commercial program either but this could speed up our drafting process and make the boss happy. :)

 

Thanks again!!

 

I do not see anything in what you describe that would require .NET, depending on the source data file(s) that may be used to populate your Excel files. Meaning if you were to receive one file, then port the data into a form within 'your' Excel file, or not, etc.. If all you're doing is processing TOPO, Visual LISP will handle this with ease (once you learn to code some basics, and perhaps some more advanced methodologies). Again, the community here is great, and will typically help anyone who's put forth a solid effort first. :thumbsup:

 

HTH

Link to comment
Share on other sites

From your comments above it sounds like something that could be done easily in CIV3 you can think outside the square! The object does not have to be a road I worked on a billion dollar project and we did all sorts of weird shapes to create first a rolling wave surface 2kmx2km which then had roads, bridges, tunnels, water features buildings you name it we were up to surface number 30 as we kept adding stuff.

 

Think of each wall as a seperate road I think it could be done easy.

 

Post a dwg or picture.

Link to comment
Share on other sites

BigAl - I'm not sure I follow but that's prolly because I don't have any experience with CIV3. However I can post a picture to help clarify what I'm after....

I think I may have to wait until I'm a junior member? I don't have an option to upload.....errr wait try this: https://docs.google.com/open?id=0Bz-ld2aFpGVZMGIzNGZjY2QtNjY4Ni00NGEwLWI2MzQtMzllMGNiNDY1Mjhj

 

Basically these are not difficult to draw but I would like to see if I can automate the process. You can see the top and bottom grade are imput (Station, Elevation) then the top and bottom of wall are drawn based on the top and bottom grade.

 

Wait maybe I can attach. Sorry if this ends up really messy.

 

RW Example.pdf

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...