GetSubEntity 方法 (ActiveX)
以交互方式获取对象或子实体。 支持的平台:仅限 Windows 签名VBA: object.GetSubEntity Object, PickedPoint, TransMatrix, ContextData [, Prompt] 返回值 (RetVal)无返回值。 言论此方法要求 AutoCAD 用户通过在图形屏幕上选取一个点来选择对象。如果选取了对象或子实体,则在第一个参数中返回该对象或子实体,第二个参数将包含 WCS 坐标中选取的点。如果拾取点不在对象上,则该方法将失败。 此方法可以检索对象,即使该对象在屏幕上不可见或位于冻结图层上。 例子VBA: 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 可视化 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.")) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 22:25
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.