Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
George Omura. Lisp programing tutorial for AutoCAD customization / [TUTORIAL] Autodesk - AutoCAD - VBA Integrating with Microsoft Excel.rtf
Скачиваний:
93
Добавлен:
02.05.2014
Размер:
630.89 Кб
Скачать

www.lanzarotecaliente.com (press control & click here)

Autodesk - AutoCAD - VBA: Integrating with Microsoft Excel - Part 1 http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=2671...

United States

Home | Products - Store - Support - Autodesk Subscription | About Autodesk - Contact Us | Search

Product Information

How to Buy

Autodesk Subscription

Consulting Training Custom Training

Authorized Training Centers

Courseware

How-to Articles

- Tutorials and How-to

- Expert Q&A

- Customization

- CAD Management

- Design Collaboration & Internet

- Hardware & Systems

- Industry Trends

- Routines, Tools & Add-ons

- Authors Tips Support

Data & Downloads

Vba: Integrating with Microsoft Excel - Part 1

By dave-espinosa aguilar

This article is the first in a series on integrating the programming

power of AutoCAD® VBA with the functionality found in other Windows applications—specifically, Microsoft Excel. Through Visual Basic programming within AutoCAD, you can launch Excel and bring the full power of a spreadsheet application into an AutoCAD drawing session. The information in this series will demonstrate how to generate, organize, query, and extract linework visibly or behind the scenes during an AutoCAD session without spending a dime on additional compilers or documentation. If you have AutoCAD and Microsoft Excel already loaded on your workstation, this technology is ready and waiting for you to take advantage of it.

To enter the world of Visual Basic programming and add Excel functionality to AutoCAD software, you have to be willing to spend the time it takes to master this object-oriented programming tool. Even if you've programmed in AutoLISP® before, Visual Basic is not as forgiving or as accommodating, and the rules that must be obeyed for everything to work right when you run your own VB applications are very strict. This isn't to say that an AutoLISP programmer can't conquer the world of Visual Basic; it just takes more dedication and effort.

So... as with any serious investment of your time, it pays to step back and examine what getting up to speed on Visual Basic (and the integration of AutoCAD VBA and Microsoft Excel) brings to your table in the first place. The more you learn about the software you already own, the more powerful it gets and the more impact it stands to have on your productivity. If the nature of your drawings and designs lends itself to spreadsheet functionality, then consider setting aside notions of cranking out code, and go Zen with me for a bit as we consider some potentially profound questions... beginning with "Why should any AutoCAD user care that integration of AutoCAD and Microsoft Excel is even possible?"

Reason #1: Automated Fully Customizable Part Counts

Have you ever counted entities in a drawing manually? By that I mean to ask have you ever (with your finger or pencil) tallied every parking lot space or every chair or every toilet in a bathroom or window on an exterior building wall or every HVAC fixture throughout a series of roof plans? Have you every counted sprinklers or landscaping features by plant type, bolts or screws for an assembly, or datapoints for a given site plan? Imagine pressing a menu button and being done with the process!

Reason #2: Queries

Maybe you use blocks with attributes. Have you ever wished you could count blocks (or maybe even select them) based on the values in

those attributes? Maybe you use Extended Entity Data, which attaches gobs of unique information to individual entities. Wouldn't it be slick if there were an easy way to take the sum or average of that information within seconds?

There are some ingenious tricks and techniques out there like using the old SSX.LSP routine, the internal FILTER command and various

1 of 4 16/10/2004 07:18 p.m.

Autodesk - AutoCAD - VBA: Integrating with Microsoft Excel - Part 1 http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=2671...

other filtering functions in AutoCAD, layer isolations, the ATTEXT Block Attribute extraction to CDF/SDF command, and even basic select-objects techniques to report entity counts in a drawing. But none of them come close to the reporting, querying, and attachment control that a linked spreadsheet application can offer.

Want to specify the name of a block with an attribute value that falls within a certain numeric range and have those entities meeting that criteria reported with full text formatting in a real spreadsheet template? You can with VBA. Imagine reporting attribute information or extended entity data from entities based on their location in the drawing or even based on the way in which they are being used or

were originally generated (for example, count all blocks named "x" that were inserted by CAD operator "y" during month "z" of last year). If you're a SQL guru, you could actually query blocks with attribute data using a SQL query statement—entirely through VBA.