Friday, December 11, 2009

VBA for CAD Customization


VBA for CAD Customization
Visual Basic for Applications (VBA) is AutoCAD, SolidWorks, ZWCAD, MicroStation inbuilt programming language. Today we will consider AutoCAD Customization environment. Visual Basic for Applications comes from a long line of BASIC language development environments and latest VB6. VBA first appeared in Microsoft Excel and Microsoft Project. It was introduced to AutoCAD in Release 14.0 as a “preview edition.” In Release 14.01, VBA became a permanent addition to the core AutoCAD application.
CAD programmers than any other language for automation mostly use VBA. It gives AutoCAD/SolidWorks well-developed and robust interface for customization and automation. Visual Basic for Applications utilizes the same Visual Basic language syntax, VB. Support complete integration into AutoCAD; VBA is both complete and powerful. Internal to AutoCAD, it acts as an in-process controller, providing outstanding performance. Before VBA was, introduce LISP use to rule programmers working for automation.
Going For VBA
Users can create useful applications by learning just a few of the keywords, and powerful features of language allow professionals achieve higher design automation that is done using any of the high-level programming languages. VBA is easy to use and simple language, lot of help is provided by parent companies with supportive forums.
Like,
When working on few projects on AutoCAD customization, I got lot of help from above Autodesk forum.
Because VBA’s powerful visual interface takes care of most of the background programming tasks, creating highly functional and useful programs is virtually nothing more than dragging pre-built objects into place on screen and tying them together with a logic. In addition, being an AutoCAD user means that you already have most of the skills necessary to create an effective user interface. The benefits of VBA include the following.
· Run-time Speed – Faster than AutoLISP applications
· Ease of Use – Built-in and easy to use
· Debugging – Finding and correcting errors has never been easier
· Easy to build form, many routines can be reused
· Built into Windows, VBA allows communication and control of other applications
When writing Visual Basic for Applications (VBA) routines, is easy task, as language uses everyday common language (as most engineers are know C or VB), pre-built visual objects, and have fully developed programming environment.
AutoCAD's VBAIDE
The VBAIDE (Integrated Development Environment) is made up of different windows, grouped according to their purpose or use. The "Design Group" includes the Code, the UserForm, and the Properties windows. The "Debugging Group" includes the Immediate, Locals, and Watch windows. Other windows include the toolbox, object browser, and project explorer. The parts and pieces that make up this IDE include the following windows grouped according to their usage


· Code Window – This is where we will put the logic and decision-making program of our projects
· Object Box – Located on the left side; displays the main divisions of your code. These divisions change based on what this code refers to such as: UserForms, Modules, or ThisDrawing
· Procedures Box – Located on the right side; displays the individual functions, procedures, or pre-defined methods available to the object displayed in the Object Box
· UserForm Window – This is our "Visual" layout of your project, where we arrange the buttons, boxes, text, etc. that are displayed when we run our programs.
· Toolbox – Can take various parameter required
· Properties Window – Like the properties window inside of AutoCAD, when we select something like a button or form we can adjust all the properties of our selection such as color and font
· Debugging window - This is where we can test and explore commands and "code" or logic, user can debug your code in real time
· Project Explorer Window – This window allows users to manage, add, and delete all the parts and pieces of the project created
VBAIDE, provided "free" inside of AutoCAD, is a feature rich, easy-to-learn development environment that can help you debug your code in real time. So start with AutoCAD Customization, be experts…

By,
Sachin Nalawade
Editor-dailycadcam.com

2 comments:

Unknown said...

Please not that Autodesk is phasing out VBA. http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=12729484&linkID=9240618
How long will VBA continue to be supported in AutoCAD?
Autodesk is evaluating how long VBA will be supported in Autodesk products in the future. Though supported in the AutoCAD 2010-based products, it may or may not be supported in future releases. Autodesk recommends VB developers develop all new code with VB .NET.

Unknown said...

Yeh.. You are right. But still LISP is used so why not VBA?

.net is must for future work, and I too will be covering few topics on .net customization soon.