CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

复制方法 (ActiveX)

2023-1-4 11:18| 发布者: admin| 查看: 597| 评论: 0|来自: AutoCAD

摘要: 将给定对象复制到同一位置。

将给定对象复制到同一位置。

支持的平台:仅窗口

签名

工 务 局:

RetVal = object.Copy
对象

类型:所有图形对象属性引用尺寸

此方法适用的对象。

返回值(RetVal)

类型:所有图形对象属性引用尺寸

新创建的重复对象。

言论

属性引用:不应尝试对对象使用此方法。objects 继承此方法,因为它们是图形对象之一,但是,对属性参照执行此操作是不可行的。AttributeReferenceAttributeReference

注意:不能在循环访问集合的同时执行此方法。迭代将为只读操作打开工作空间,而此方法将尝试执行读写操作。在调用此方法之前完成任何迭代。

例子

工 务 局:

Sub Example_Copy()
    ' This example creates a circle and then copies
    ' that circle. The new circle is then moved.
    
    ' Create the circle
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 2#: center(1) = 2#: center(2) = 0#
    radius = 0.5
    Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)
    ZoomAll
    MsgBox "Copy the circle.", , "Copy Example"
    
    ' Copy the circle
    Dim copyCircleObj As AcadCircle
    Set copyCircleObj = circleObj.Copy()
    
    ' Define the points that make up the move vector
    Dim point1(0 To 2) As Double
    Dim point2(0 To 2) As Double
    point1(0) = 0: point1(1) = 0: point1(2) = 0
    point2(0) = 2: point2(1) = 0: point2(2) = 0
        
    MsgBox "Move the copied circle 2 units in the X direction.", , "Copy Example"
    
    ' Move the circle and color it
    copyCircleObj.Move point1, point2
    
    ZoomAll
    MsgBox "Move completed.", , "Copy Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Copy()
    ;; This example creates a circle and then copies
    ;; that circle. The new circle is then moved.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))    
    
    ;; Create the circle
    (setq center (vlax-3d-point 2 2 0)
          radius 0.5)
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq circleObj (vla-AddCircle modelSpace center radius))
    (vla-ZoomAll acadObj)
    (alert "Copy the circle.")
    
    ;; Copy the circle
    (setq copyCircleObj (vla-Copy circleObj))
    
    ;; Define the points that make up the move vector
    (setq point1 (vlax-3d-point 0 0 0)
          point2 (vlax-3d-point 2 0 0))
        
    (alert "Move the copied circle 2 units in the X direction.")
    
    ;; Move the circle and color it
    (vla-Move copyCircleObj point1 point2)
    
    (vla-ZoomAll acadObj)
    (alert "Move completed.")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-11 23:33

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部