Handle property example


Sub Handle_Example()
' This example creates some entities.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 Pt1(0 To 2) As Double
    Dim Pt2(0 To 2) As Double
    Pt1(0) = 3: Pt1(1) = 3: Pt1(2) = 0
    Pt2(0) = 1: Pt2(1) = 3: Pt2(2) = 0
    Dim rayObj As AcadRay
    Set rayObj = ThisDrawing.ModelSpace.AddRay(Pt1, Pt2)
    'Create a polyline object in model space
    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
    Dim plineObj As AcadLWPolyline
    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    plineObj.Closed = True
    'Create a line object in model space
    Pt1(0) = 0: Pt1(1) = 0: Pt1(2) = 0
    Pt2(0) = 2: Pt2(1) = 2: Pt2(2) = 0
    Dim lineObj As AcadLine
    Set lineObj = ThisDrawing.ModelSpace.AddLine(Pt1, Pt2)
    'Create a circle object in model space
    Pt1(0) = 20: Pt1(1) = 30: Pt1(2) = 0
    Dim radius As Double: radius = 3
    Dim circObj As AcadCircle
    Set circObj = ThisDrawing.ModelSpace.AddCircle(Pt1, radius)
    'Create an ellipse object in model space
    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
    Dim ellObj As AcadEllipse
    Set ellObj = ThisDrawing.ModelSpace.AddEllipse(center, majAxis, radRatio)
    ThisDrawing.Application.ZoomExtents
    Dim entHandle As String
    Dim ent As AcadEntity
    For Each ent In ThisDrawing.ModelSpace
        entHandle = ent.Handle
        ent.Highlight (True)
        MsgBox "The handle of this " & ent.ObjectName & " object is " & entHandle
        ent.Highlight (False)
    Next
End Sub

© Bricsys NV. All rights reserved.