明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 6600|回复: 12

AutoCAD2006VBA程序参考

  [复制链接]
发表于 2007-12-6 20:05:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2007-12-7 12:05:45 编辑

要学好AutoCAD 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文件。

 http://www.ccebook.cn/books/16.html

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x

评分

参与人数 1威望 +1 明经币 +2 金钱 +20 贡献 +5 激情 +5 收起 理由
mccad + 1 + 2 + 20 + 5 + 5 【精华】表扬一下

查看全部评分

 楼主| 发表于 2007-12-6 21:18:00 | 显示全部楼层

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

 楼主| 发表于 2007-12-6 21:38:00 | 显示全部楼层

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

 楼主| 发表于 2007-12-6 21:47:00 | 显示全部楼层

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

发表于 2007-12-9 16:41:00 | 显示全部楼层
先下个看看,看标题应该是个不错的东东
发表于 2007-12-15 22:59:00 | 显示全部楼层

应该是好东西,不知是不是中文的

发表于 2007-12-23 22:33:00 | 显示全部楼层

书在那里?可不可以下载

发表于 2008-6-11 18:07:00 | 显示全部楼层
谢谢兰州的兄弟!!!
发表于 2008-6-11 18:07:00 | 显示全部楼层
谢谢兰州的兄弟!!!
发表于 2008-6-11 18:44:00 | 显示全部楼层
谢谢版主,下载保存,好东西,值得珍藏!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 08:22 , Processed in 0.186652 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表