明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1586|回复: 3

14.5 数据记录和AutoCAD实体的对应(VBA 二次开发教程)

[复制链接]
发表于 2006-7-10 10:47:00 | 显示全部楼层 |阅读模式

14.5.2 编程思路

1 ObjectID、Handle和对象本身

2 记录和实体对应的惟一性

我希望与各位VBA发烧友和班竹共同探讨以上两个问题。

a ObjectID、Handle相关语句的描述

b 记录和实体对应的惟一性的认识

c lsp语句的相关表述

 楼主| 发表于 2006-7-10 12:53:00 | 显示全部楼层

[glow=255,red,2]Handle

根据“开发者文档”的一个实例对Handle的理解[/glow]

Sub Example_Handle()

    ' This example creates several objects in model space.

    ' It then iterates through the objects in model space and displays the

    ' Handle for each object found.

   

    ' Create a Ray object in model space

    Dim rayObj As AcadRay

    Dim basePoint(0 To 2) As Double

    Dim SecondPoint(0 To 2) As Double

    basePoint(0) = 3#: basePoint(1) = 3#: basePoint(2) = 0#

    SecondPoint(0) = 1#: SecondPoint(1) = 3#: SecondPoint(2) = 0#

    Set rayObj = ThisDrawing.ModelSpace.AddRay(basePoint, SecondPoint)

   

    ' Create a polyline object in model space

    Dim plineObj As AcadLWPolyline

    Dim points(0 To 5) As Double

    points(0) = 3: points(1) = 7

    points(2) = 9: points(3) = 2

    points(4) = 3: points(5) = 5

    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)

    plineObj.Closed = True

 

    ' Create a line object in model space

    Dim lineObj As AcadLine

    Dim startPoint(0 To 2) As Double

    Dim endPoint(0 To 2) As Double

    startPoint(0) = 0: startPoint(1) = 0: startPoint(2) = 0

    endPoint(0) = 2: endPoint(1) = 2: endPoint(2) = 0

    Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)

   

    ' Create a circle object in model space

    Dim circObj As AcadCircle

    Dim centerPt(0 To 2) As Double

    Dim radius As Double

    centerPt(0) = 5: centerPt(1) = 3: centerPt(2) = 0

    radius = 3

    Set circObj = ThisDrawing.ModelSpace.AddCircle(centerPt, radius)

 

    ' Create an ellipse object in model space

    Dim ellObj As AcadEllipse

    Dim majAxis(0 To 2) As Double

    Dim center(0 To 2) As Double

    Dim radRatio As Double

    center(0) = 5#: center(1) = 5#: center(2) = 0#

    majAxis(0) = 10: majAxis(1) = 20#: majAxis(2) = 0#

    radRatio = 0.3

    Set ellObj = ThisDrawing.ModelSpace.AddEllipse(center, majAxis, radRatio)

 

 

    ZoomAll

   

    ' Iterate through the model space collection and display

    ' the handle of each object found.

   

    Dim entHandle As String

    Dim entry As AcadEntity

    For Each entry In ThisDrawing.ModelSpace

        entHandle = entry.Handle

        entry.Highlight (True)

        MsgBox "The handle of this object is " & entHandle, vbInformation, "Handle Example"

        entry.Highlight (False)

    Next

End Sub

 

 

 

问题1: Dim entry As AcadEntity 在开发者文档中没有查到AcadEntityAcadEntity什么意思?

问题2: entry.Highlight (True) 是否为 AutoCAD select命令,控制选择亮显功能

问题3: vbInformation在开发者文档中没查到,Debug.print64,从字面翻译为VB信息,是版号还是其它意思?

问题4: Each entry In ThisDrawing.ModelSpace的理解,在这个模型空间在循环找到每个实体?相比在lsp中完成这个功能要简单。

 

发表于 2006-7-10 16:54:00 | 显示全部楼层

1,AcadEntity即object

2,对,高亮显示

3,vbInformation在msgbox下可以察看许多这样的vb变量

4,对

发表于 2006-7-16 23:18:00 | 显示全部楼层

1、ObjectID是对象ID,在当前的整个AutoCAD应用程序内是唯一的。Handle是对象句柄,仅在一个文档内是唯一的。

2、AcadEntity是图元对象的基类,只限于有图形的对象使用。AcadObject是所有对象的基类,可以用于非图形对象,如层,文字样式等。

3、vbInformation是用于MsgBox中,代表弹出的是信息提示框,还可以是警告、疑问之类的。

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-27 00:43 , Processed in 0.161475 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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