CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

添加领导者方法 (ActiveX)

2023-1-4 12:57| 发布者: admin| 查看: 931| 评论: 0|来自: AutoCAD

摘要: 基于提供的坐标创建引出线,或向 MLeader 对象添加新的领导集群。

基于提供的坐标创建引出线,或向 MLeader 对象添加新的领导集群。

支持的平台:仅窗口

签名 - 块、模型空间、图纸空间

工 务 局:

RetVal = object.AddLeader(PointsArray, Annotation, Type)
对象

类型:模型空间,图纸空间

此方法适用的对象。

点数组

访问:仅输入

类型:变体(双打数组)

指定引线的 3D WCS 坐标数组。您必须至少提供两个点来定义领导者。第三点是可选的。

注解

访问:仅输入

类型:块引用MT扩展公差

应附加到引线的对象。该值也可以为 NULL 以不附加对象。

类型

访问:仅输入

类型:枚举AcLeaderType

  • acLineNoArrow
  • acLineWithArrow
  • acSplineNoArrow
  • acSplineWithArrow

签名 - MLeader

工 务 局:

RetVal = object.AddLeader
对象

类型:MLeader

此方法适用的对象。

返回值 (RetVal) - 块、模型空间、图纸空间

类型:领导者

新创建的对象。Leader

返回值 (RetVal) - MLeader

类型:

添加的领导集群的索引

言论

块、模型空间、图纸空间:引线是将某些注释连接到图形中特征的线。引线及其注释是关联的,这意味着如果您修改引线,引线也会相应地更新。注释可以是 a、、、 或对象。ToleranceMTextBlockReference

您还可以创建不与特定对象关联的引线。为此,只需输入一个对象作为注释。NULL

例子

工 务 局:

Sub Example_AddLeader()
    ' This example creates a leader in model space.
    ' The leader is not attached to any annotation object
    ' in this example.
   
    Dim leaderObj As AcadLeader
    Dim points(0 To 8) As Double
    Dim leaderType As Integer
    Dim annotationObject As AcadObject
    
    points(0) = 0: points(1) = 0: points(2) = 0
    points(3) = 4: points(4) = 4: points(5) = 0
    points(6) = 4: points(7) = 5: points(8) = 0
    leaderType = acLineWithArrow
    Set annotationObject = Nothing
        
    ' Create the leader object in model space
    Set leaderObj = ThisDrawing.ModelSpace.AddLeader(points, annotationObject, leaderType)
    ZoomAll
    
End Sub

Sub Example_MLeaderLine()
    Dim oML As AcadMLeader
    Dim points(0 To 5) As Double
    points(0) = 1: points(1) = 1: points(2) = 0
    points(3) = 4: points(4) = 4: points(5) = 0
    Dim i As Long
    Set oML = ThisDrawing.ModelSpace.AddMLeader(points, i)

    Dim r As Long
    r = oML.AddLeader()

    points(4) = 10
    Call oML.AddLeaderLine(r, points)

    MsgBox "LeaderCount = " & oML.LeaderCount
    ZoomExtents
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AddLeader()
    ;; This example creates a leader in model space.
    ;; The leader is not attached to any annotation object
    ;; in this example.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    (setq modelSpace (vla-get-ModelSpace doc))
  
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 8)))
    (vlax-safearray-fill points '(0 0 0
                                  4 4 0
                                  4 5 0
                                 )
    )
    (setq leaderType acLineWithArrow)
  
    ;; Create a temporary annotaion object
    (setq point (vlax-3d-point 4 5 0))
    (setq annotationObject (vla-AddMText modelSpace point 1 ""))  

    ;; Create the leader object in model space
    (setq leaderObj (vla-AddLeader modelSpace points annotationObject leaderType))

    ;; Remove the temporary annotaion object and adjust the last coordinate of the leader
    (vla-Erase annotationObject)
    (vla-put-Coordinate leaderObj 2 (vlax-3D-point 4 5 0))
    (vla-ZoomAll acadObj)
)

(defun c:Example_MLeaderLine()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 5)))
    (vlax-safearray-fill points '(1 1 0
                                  4 4 0
                                 )
    )  
    (setq i 0)

    (setq modelSpace (vla-get-ModelSpace doc))
    (setq oML (vla-AddMLeader modelSpace points i))

    (setq r (vla-AddLeader oML))

    (vlax-safearray-put-element points 4 10)
    (vla-AddLeaderLine oML r points)

    (alert (strcat "LeaderCount = " (itoa (vla-get-LeaderCount oML))))
    (vla-ZoomExtents acadObj)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-11 14:51

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部