Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programming Help, anyone?

Status
Not open for further replies.

AlexDring

Mechanical
Dec 31, 2002
117
I have some ideas for some utilities that would help me out greatly in AutoCad. I see these small programs that run inside of AutoCad with buttons and everything. What route should I take to create something of that caliber? Example is MechQ, how or what platform would I use to create my own program? Visual Lisp, Arx? What are the benefits of these and other platforms that AutoCad supports?

I have been using this program for many years and dont want to pay for other programs for some things that might be nice and not using anything else. So I want to create my own, anyone have any thoughts?
 
Replies continue below

Recommended for you

Hi AlexDring,

I have received some training in Autolisp programming and have written many different types of routines to help in Autocad. I would say that Autolisp may be a good starting point (depending on the type of programs that you want to write). I have written programs to make mundane drafting chores easier as well as programs to actually perform design calculations to speed the design process at the same time as drafting. For example, I wrote a small Autolisp program to calculate a uniformly loaded simple beam. It will write the calculations into a text file for record, then draw and label the beam within Autocad. When this program is finished, I can print the text file to give to the engineer AND have my drawing more complete to meet the current deadline.

Another great choice would be Visual Basic as many different applications run on this system. For example, you could access information from an Excel spreadsheet to use in your Autocad drawing. I have not become familiar with VBA, but I plan to in the future.

As far as buttons go, Autocad will allow you to create your own buttons to run whichever macros you desire. The sky's the limit.

Hope this helps,
Paul
 
Paul-

I see that you are a structual man, the things I actually am writing for is steel detailing. I wanted to make some programs to quickly draw structures such as columns and beams and connections. If I could figure out a way to draw the columns quickly and simple connections, it would speed my job up and provide a cheaper service to my customers. I then would get a clean and simple subroutine for picking the solid and having my program spit the geometry out on a sheet I designate. But I want to for right now continue to detail the peices. I dont want to pay the thousands of dollars for the dedicated steel detailing programs using only a few of the feautures. Can those get expensive, dang, some reaching 22k........
 
AlexDring -

You can save yourself some time by creating a block library which contains standard pieces (i.e. beam sections, angle elevations with bolt patterns, etc.) and simply insert the pieces that you need to quickly assemble details. Another idea that I have used is to draw a generic "standard" detail that does not label a specific size of beam or column and simply refer to each piece as "W BEAM" or "TS COL.". That way, you can use the same detail over and over without a large amount of changes. Standard details sheets can then be "pre-made". I have used this theory quite a bit. Any of the particular joints or situations can and are refered to in the specifications.

Hope this helps,
Paul
 
VBA is a very good programing environment for AutoCAD if u have basic knowledge in VB6.0.

I have used it to develop programs for pipeline routing and some designs where an equation is to be used in creating curves and I use the equations within the program to generate and plot the curves straight out instead of generating the points and then plotting with AutoCAD.

However I believe Paul has a point with creating blocks and generic plots which u can adopt for most designs.

greg.
 
I have written a fair amount of AutoLISP (a long time ago, admittedly) and VBA. My first choice would be VBA.
[ul][li]VBA skills are transferrable to a lot of other apps, but AutoLISP is only useful in AutoCAD.[/li][li] The IDE's for Visual Basic are very similar from MS Excel to MS Access to MS-whatever, and provide really decent support (autocomplete and context-sensitive help and debugging tools.)[/li][li]It is possible (not necessary, but possible) to write fairly good Object Oriented code, which makes reuse, debugging, and maintenance simpler. [/li][li]It is easier to port your VBA app to VisualBasic per se, which can compile your code into an exe file, with the advantages inherent in compiled code.[/li][/ul]

Perhaps if someone knows the AutoLISP IDE, they could provide a comparison between the AutoLISP editor and the VBA Editor?
 
I had thought about VBA, but wondered how VBA actaully gets the information to AutoCAD. I probally can find out with some more research, but I wondered how exactly a seperate program transfer information to AutoCADs input.

EG say you wanted to draw a plate with some holes, in which might be standard for a specific industry. So in this serperate program, you get a screen and you put in the size, hole locations, and size or what have you, hit a create button and it draws the object asking for an insert place. How would that seperate program get those values into AutoCAD? If I understood that theroy then I can visualize the limits I would have and structure my program to those limits. Any input is appreciated, its been a few years since I took Visual, back in version 3.0, I took C++ classes during my ME pursuit, but I think that is not applicable here. Thanks.
 
In using VBA you would have to create a user form (window for input) This would allow you to make it look like what ever you want (this is the easier part of VBA programming). Anything you can do with a mouse and a keyboard in AutoCAD, you can make a program in VBA to do it. You can get the VBA program to prompt the user for input as it goes.

Hope this helps.

 
Hi...

I think than is better mix Visual LISP with Visual Basic. Making DLL file.

AutoLISP(Visual LISP) and Visual Basic are different. But VBA is more limited than VB, his different is great.

Everything depends on the application than you want make.

However, ARX is more powerful to programming in AutoCAD via C++, but it is very complicated.

If you are learning programming I recommend to you first learn AutoLISP or Visual LISP, next Visual Basic or VBA, and finally C++ and ARX.
 
SpeedCad & Thalon

I agree C++ is much more challenging, I took both C++ and Visual classes during my engineering schooling. I read up a little on it last night and most of the information I am finding is suggesting I use VBA or VB. The main differnce according to my source of info is that VBA will not proceed with an open dialog box as to VB can let the user do something else without that irratating box flashing on normal programs if you click somewhere out side of the dialog box. What is your take on the differnces between the two?
 
Not sure what you mean.
I think in both VB and VBA any mew windows that pop up in the program you have to deal with first before you can continue on with the program.

Might help narrow down the best language to use if we knew more about the exact application.

 
Hi AlexDring...

The difference between VB and VBA are several:

It's not VB - don't confuse VBA with VB; the two languages are different. VB is a superset of VBA with important distinctions. Features such as control arrays simply aren't available in VBA. The set of common controls (e.g. buttons) are limited in VBA. The biggest pitfall of VBA: no resizable forms. This basic feature of VB is vitally important to UI design, and is conspicuously absent from VBA.

Revision cycles - AutoCAD 2000i upgraded embedded VBA to version 6.2. Great: it's up-to-date with its VB siblings - for now. When Microsoft releases Visual Basic 7 sometime next year, you won't be able to take advantage of new language features in AutoCAD. And AutoCAD, as with Microsoft Office products, usually embeds a version of VBA that's several steps behind standalone Visual Basic.

Distribution - AutoCAD VBA Projects (.dvb files) are somewhat more difficult to distribute and load than Visual LISP files (.lsp or .vlx). As well, you'll typically need to write lisp stub functions to if you intend to invoke your VBA functions from a menu or command line.

Limited Use - Code and forms that you write in AutoCAD VBA aren't easily portable to standalone Visual Basic. Granted, you can use VBA's Import and Export functions to move source code modules between VBA and VB, but oftentimes code still needs to be rewritten, especially coming from AutoCAD.

Personally I program in Visual Basic 6.0 since VBA is more limited...
 
Thalon-

This is what I know as far as what I have read so far as the differences between VBA and VB. VBA can be devolped and ran inside Autocad using ARX (if I remember correctly). The benifit of that is that using VBA like that it uses the resources Autocad has dedicated. According to my resources VBA running like that inside Autocad is very robust and very effiecent. Using VB like we all know would be a stand alone program not needing Autocad to fire off, thus taking its own resources and maybe slowing Autocad down if the resources (RAM, Video etc)werent that great to begin with.
 
SpeedCad-

I think I agree with your thought pattern. Since I may want my program to pop using other design programs with reference information I am leaning towards the VB. I have experience in VB but that was back in dinasour ages of version three. I got a new copy of six, but needless to say it is a lot different.

Since we are on the subject, I printed off a sample of a book that seems to be by autodesk and is all about using VB and VBA for customizing Autocad. I didnt write the book name down, and that was about a year ago. Do you know of a book of such. I printed off the sample of chapter one, and it appears to be all about Autocad and VB. I dont want to by another VB, I have several. I was looking for a book purely on VB and Autocad like the sample chapter I printed. Know of any?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor