明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1113|回复: 0

CopyObjects 函数在C++中如何用???

[复制链接]
发表于 2007-3-20 18:21:00 | 显示全部楼层 |阅读模式

各位CAD开发大哥好!

小弟对CAD二次开发AutoMation非常感兴趣!

一直不明白CopyObjects函数 在C++中参数含义,恳请指教,不胜感激!!!

以下是AutoCAD联机帮助:

Duplicates multiple objects (deep cloning).

MSITStore:C:\Program%20Files\AutoCAD%202004\help\ACADAUTO.CHM::/copyobjects_see_also.htm">See Also | MSITStore:C:\Program%20Files\AutoCAD%202004\help\ACADAUTO.CHM::/ex_copyobjects.htm">Example

Signature

RetVal = object.CopyObjects(Objects[, Owner][, IDPairs])

Object

MSITStore:C:\Program%20Files\AutoCAD%202004\help\ACADAUTO.CHM::/idh_database_object.htm">Database, MSITStore:C:\Program%20Files\AutoCAD%202004\help\ACADAUTO.CHM::/idh_document_object.htm">Document
The object or objects this method applies to.

Objects

Variant (array of objects); input-only
The array of primary objects to be copied. All the objects must have the same owner, and the owner must belong to the database or document that is calling this method.

Owner

Variant (a single object); input-only; optional
The new owner for the copied objects. If no owner is specified, the objects will be created with the same owner as the objects in the Objects array.

IDPairs

Variant (array of IDPair objects); input-output; optional
Information on what happened during the copy and translation process.
Input: an empty variant.
Output: an array of IDPair objects.

RetVal

Variant (array of objects)
An array of newly created duplicate objects. Only primary objects are returned in this array. For more information on what occured during the CopyObjects operation, or a list of objects owned by primary objects that were also copied, consult the IDPairs array.

Remarks

To copy objects to another open drawing, set the Owner parameter to the other drawing's model space.

During the CopyObjects operation, objects that are owned or referenced by the primary objects in the Objects parameter will also be copied.

NOTE You cannot execute this method while simultaneously iterating through a collection. An iteration will open the work space for a read-only operation, while this method attempts to perform a read-write operation. Complete any iteration before you call this method.

例子如下:

Sub Example_CopyObjects()
    ' This example creates a Circle object and uses the CopyObjects
    ' method to make a copy of the new Circle.

    Dim DOC1 As AcadDocument
    Dim circleObj1 As AcadCircle, circleObj2 As AcadCircle
    Dim circleObj1Copy As AcadCircle, circleObj2Copy As AcadCircle
    Dim centerPoint(0 To 2) As Double
    Dim radius1 As Double, radius2 As Double
    Dim radius1Copy As Double, radius2Copy As Double
    Dim objCollection(0 To 1) As Object
    Dim retObjects As Variant
    
    ' Define the Circle object
    centerPoint(0) = 0: centerPoint(1) = 0: centerPoint(2) = 0
    radius1 = 5#: radius2 = 7#
    radius1Copy = 1#: radius2Copy = 2#
    
    ' Create a new drawing
    Set DOC1 = Documents.Add
    
    ' Add two circles to the drawing
    Set circleObj1 = DOC1.ModelSpace.AddCircle(centerPoint, radius1)
    Set circleObj2 = DOC1.ModelSpace.AddCircle(centerPoint, radius2)
    ThisDrawing.Application.ZoomAll
    
    ' Copy objects
    '
    ' First put the objects to be copied into a form compatible with CopyObjects
    Set objCollection(0) = circleObj1
    Set objCollection(1) = circleObj2
    
    ' Copy object and get back a collection of the new objects (copies)
    retObjects = DOC1.CopyObjects(objCollection)
    
    ' Get newly created object and apply new properties to the copies
    Set circleObj1Copy = retObjects(0)
    Set circleObj2Copy = retObjects(1)
    
    circleObj1Copy.radius = radius1Copy
    circleObj2Copy.radius = radius2Copy
        
    ThisDrawing.Application.ZoomAll
    
    MsgBox "Circles copied."
End Sub

一直不明白CopyObjects函数 在C++中参数含义,恳请指教,不胜感激!!!

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-2-22 05:43 , Processed in 0.155625 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表