AutoCAD2006VBA程序参考
要学好 VBA程序,AutoCAD 2006 VBA A Programmer’s Reference是一本相当好的参考书。可惜这本书是英文,为了让大家能更好的学好这本书,本人抛砖引玉,摘要部分学习心得与网友共享。This book provides a concise guide to the kind of customization programmers can achieve with AutoCAD 2006. It demonstrates how to use AutoCAD through short code examples written in Visual Basic for Applications (VBA). It also includes a complete quick reference that lists all the events, methods, and properties available with AutoCAD. Finally, it describes all the constants and system variables.
本书通过提供简明扼要AutoCAD程序,采用短程序教学法介绍VBA编程。而且用表的形式,快速介绍所有的事件、方法和有用的AutoCAD特性。
What Is This Book About? 有关这本这本书
By interfacing with AutoCAD, you can exploit all of AutoCAD’s functionality that would have taken you a long time to write yourself. This book will first help you learn how to use this functionality.
如何用AutoCAD接口技术开发AutoCAD功能。
TABLE OF CONTENT:目录
Chapter 01 - The VBA Integrated Development Environment (VBAIDE)----VBA整合开发环境
Chapter 02 - Introduction to Visual Basic Programming----介绍VBA
Chapter 03 - Application Elements ----- 应用原理
Chapter 04 - AutoCAD Events----AutoCAD事件
Chapter 05 - User Preferences----用户参数
Chapter 06 - Controlling Layers and Linetypes----图层和线的控制
Chapter 07 - User Interaction and the Utility Object
Chapter 08 - Drawing Objects
Chapter 09 - Creating 3-D Objects
Chapter 10 - Editing Objects
Chapter 11 - Dimensions and Annotations
Chapter 12 - Selection Sets and Groups
Chapter 13 - Blocks,Attributes,and External References
Chapter 14 - Views and Viewports
Chapter 15 - Layout and Plot Configurations
Chapter 16 - Controlling Menus and Toolbars
Chapter 17 - Drawing Security
Chapter 18 - Using the Windows API
Chapter 19 - Connecting to External Applications
Chapter 20 - Creating Tables
Chapter 21 - The SummaryInfo Object
Chapter 22 - An Illustrative VBA Application
Appendix A - AutoCAD Object Summary
Appendix B - AutoCAD Constants Reference
Appendix C - System Variables
附本书的PDF文件。
**** Hidden Message ***** P68页要点
以下程序为声明类模块示例。
Option Explicit
Public objApp As New clsApplicationEvents
Public Sub InitializeEvents()
Set objApp.objApp = ThisDrawing.Application
End Sub
As soon as the InitializeEvents subroutine is called, in this case by running the
App_StartMacro macro shown next, the application-level events are enabled.
运行初始子程序,
Public Sub App_StartMacro()
InitializeEvents
End Sub
P89
Checking for Existing Layers检查已经存的图层。
Public Sub CheckForLayerByIteration()
Dim objLayer As AcadLayer
Dim strLayerName As String
strLayername = InputBox("Enter a Layer name to search for: ")
If "" = strLayername Then Exit Sub ' exit if no name entered
For Each objLayer In ThisDrawing.Layers ' iterate layers
If 0 = StrComp(objLayer.name, strLayername, vbTextCompare) Then
MsgBox "Layer '" & strLayername & "' exists"
Exit Sub ' exit after finding layer
End If
Next objLayer
MsgBox "Layer '" & strLayername & "' does not exist"
End Sub
P93页
The ActiveLayer property is a member of the Document object. To make a specific layer
active, assign the Layer object to the ActiveLayer.
激活图层示例
Public Sub ChangeEntityLayer()
On Error Resume Next ' handle exceptions inline
Dim objEntity As AcadEntity
Dim varPick As Variant
Dim strLayerName As String
Dim objLayer As AcadLayer
ThisDrawing.Utility.GetEntity objEntity, varPick, "Select an entity"
If objEntity Is Nothing Then
MsgBox "No entity was selected"
Exit Sub ' exit if no entity picked
End If
strLayerName = InputBox("Enter a new Layer name: ")
If "" = strLayerName Then Exit Sub ' exit if no name entered
Set objLayer = ThisDrawing.Layers(strLayerName)
If objLayer Is Nothing Then
MsgBox "Layer was not recognized"
Exit Sub ' exit if layer not found
End If
objEntity.Layer = strLayerName ' else change entity layer
End Sub
先下个看看,看标题应该是个不错的东东 应该是好东西,不知是不是中文的
书在那里?可不可以下载
谢谢兰州的兄弟!!! 谢谢兰州的兄弟!!! 谢谢版主,下载保存,好东西,值得珍藏!
页:
[1]