CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

GetSubEntity32 方法 (ActiveX)

2023-1-2 23:10| 发布者: admin| 查看: 131| 评论: 0|来自: AutoCAD

摘要: 对于 64 位系统,以交互方式获取对象或子实体。(已过时)

对于 64 位系统,以交互方式获取对象或子实体。(已过时)

支持的平台:仅窗口

签名

工 务 局:

object.GetSubEntity32 Object, PickedPoint, TransMatrix, ContextData [, Prompt]
对象

类型:实用工具

此方法适用的对象。

对象

访问:仅输出

类型:对象

选取的对象或子实体。可以是任何图形对象之一。

拾取点

访问:仅输出

类型:变体(双精度的三元素数组)

指定所选点的三维 WCS 坐标。

跨矩阵

访问:仅输出

类型:变体(4x4 双精度数组)

应用于此实体的转换矩阵。

上下文数据

访问:仅输出

类型:变体(多头数组)

选定对象中任何嵌套对象的对象 ID 数组。

提示

访问:仅输入;自选

类型:变体(字符串)

要显示以提示用户输入的文本。

返回值(RetVal)

无返回值。

言论

此方法要求 AutoCAD 用户通过在图形屏幕上选取一个点来选择对象。如果选取对象或子实体,则会在第一个参数中返回该对象或子实体,第二个参数将包含在 WCS 坐标中选取的点。如果拾取点不在对象上,则该方法将失败。

此方法可以检索对象,即使对象在屏幕上不可见或位于冻结层上也是如此。

例子

工 务 局:

Sub Example_GetSubEntity()
    ' This example prompts the user to select on object on the screen with a mouse click,
    ' and returns some information about the selected object.
    
    AppActivate ThisDrawing.Application.Caption
    
    Dim Object As Object
    Dim PickedPoint As Variant, TransMatrix As Variant, ContextData As Variant
    Dim HasContextData As String
    
    On Error GoTo NOT_ENTITY
        
TRYAGAIN:
        
    MsgBox "Use the mouse to click on an object in the current drawing after dismissing this dialog box."
        
    ' Get information about selected object
    ThisDrawing.Utility.GetSubEntity Object, PickedPoint, TransMatrix, ContextData
    
    ' Process and display selected object properties
    HasContextData = IIf(VarType(ContextData) = vbEmpty, " does not ", " does ")
    
    MsgBox "The object you chose was an: " & TypeName(Object) & vbCrLf & _
            "Your point of selection was: " & PickedPoint(0) & ", " & _
                                              PickedPoint(1) & ", " & _
                                              PickedPoint(2) & vbCrLf & _
            "This object" & HasContextData & "have nested objects."
    
    Exit Sub
    
NOT_ENTITY:
    ' If you click on empty space or do not select an entity,
    ' this error will be generated
    If MsgBox("You have not selected an object.  Click OK to try again.", _
               vbOKCancel & vbInformation) = vbOK Then
        Resume TRYAGAIN
    End If
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_GetSubEntity()
    ;; This example prompts the user to select on object on the screen with a mouse click,
    ;; and returns some information about the selected object.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Get information about selected object
    (vla-GetSubEntity (vla-get-Utility doc) 'Object 'PickedPoint 'TransMatrix 'ContextData "Select a subentity: ")
    
    ;; Process and display selected object properties
    (if (/= ContextData nil)
        (setq HasContextData " does ")
        (setq HasContextData " does not ")
    )
    
    (alert (strcat "The object you chose was an: " (vla-get-ObjectName Object)
                   "\nYour point of selection was: " (rtos (vlax-safearray-get-element PickedPoint 0) 2) ", "
		                                                   (rtos (vlax-safearray-get-element PickedPoint 1) 2) ", "
		                                                   (rtos (vlax-safearray-get-element PickedPoint 2) 2)
                   "\nThis object" HasContextData "have nested objects."))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 07:26

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部