CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2020 开发者帮助

Highlight 方法 (ActiveX)

2024-5-18 18:20| 发布者: admin| 查看: 81| 评论: 0|原作者: admin|来自: AutoCAD

Highlight 方法 (ActiveX)

设置给定对象或给定选择集中所有对象的高亮显示状态。

支持的平台:仅限 Windows

签名

VBA:

object.Highlight HighlightFlag
对象

类型:所有绘图对象AttributeReferenceDimensionGroupSelectionSet

此方法应用到的对象。

突出显示标志

访问:仅输入

类型:布尔

  • True:对象将加亮显示。
  • False:从对象中移除现有高亮显示。

返回值 (RetVal)

无返回值。

言论

设置对象的突出显示标志后,需要调用 or 方法才能查看更改。UpdateRegen

注意:此函数不返回对象的当前突出显示状态。

例子

VBA:

Sub Example_Highlight()
    ' This example creates several objects in model space.
    ' It then iterates through model space, highlights each
    ' object, and displays its Entity Name.
    
    ' 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) = 20: centerPt(1) = 30: 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
    ' highlight each object.
    
    Dim entName As String
    Dim entry As AcadEntity
    For Each entry In ThisDrawing.ModelSpace
        entName = entry.ObjectName
        entry.Highlight (True)
        MsgBox "The name of this object is " & entName, vbInformation, "Highlight Example"
        entry.Highlight (False)
    Next
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_Highlight()
    ;; 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.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    (setq modelSpace (vla-get-ModelSpace doc))

    ;; Create a Ray object in model space
    (setq basePoint (vlax-3d-point 3 3 0)
          secondPoint (vlax-3d-point 1 3 0))
    (setq rayObj (vla-AddRay modelSpace basePoint SecondPoint))
    
    ;; Create a polyline object in model space
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 5)))
    (vlax-safearray-fill points '(3 7
                                  9 2
				                              3 5
				                             )
    )
    (setq plineObj (vla-AddLightWeightPolyline modelSpace points))
    (vla-put-Closed plineObj :vlax-true)

    ;; Create a line object in model space
    (setq startPoint (vlax-3d-point 0 0 0)
          endPoint (vlax-3d-point 2 2 0))
    (setq lineObj (vla-AddLine modelSpace startPoint endPoint))
    
    ;; Create a circle object in model space
    (setq centerPt (vlax-3d-point 20 30 0)
          radius 3)
    (setq circObj (vla-AddCircle modelSpace centerPt radius))

    ;; Create an ellipse object in model space
    (setq center (vlax-3d-point 5 5 0)
          majAxis (vlax-3d-point 10 20 0)
          radRatio 0.3)
    (setq ellObj (vla-AddEllipse modelSpace center majAxis radRatio))

    (vla-ZoomAll acadObj)
    
    ;; Iterate through the model space collection and display
    ;; the object name of each object found.
    (vlax-for entry (vla-get-ModelSpace doc)
        (setq entName (vla-get-ObjectName entry))
        (vla-Highlight entry :vlax-true)
        (alert (strcat "The name of this object is " entName))
        (vla-Highlight entry :vlax-false)
    )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1   苏公网安备32011402011833)

GMT+8, 2024-12-15 12:54

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部