ObjectID Пример |
Sub Example_ObjectID() 'Этот пример создает несколько объектов в пространстве модели. 'Затем выполняет итерации через пространство модели и показывает 'ObjectID для каждого найденного объекта. 'Создайте объект Ray в пространстве модели 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) 'Создайте объект Polyline в пространстве модели 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 'Создайте объект Line в пространстве модели 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) 'Создайте объект Circle в пространстве модели 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) 'Создайте объект Ellipse в пространстве модели 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 ' Выполните итерации через коллекцию пространства модели и ' покажите ObjectID каждого найденного объекта. Dim entObjectID As Long Dim entry As AcadEntity For Each entry In ThisDrawing.ModelSpace entObjectID = entry.objectID entry.Highlight (True) MsgBox "ObjectID этого объекта " & entObjectID, vbInformation, "ObjectID Пример" entry.Highlight (False) Next End Sub