明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1322|回复: 2

[求助]使用CopyObjects不能复制尺寸标注

[复制链接]
发表于 2009-3-10 15:08:00 | 显示全部楼层 |阅读模式

用下面的代码把当前图纸中所有的图形复制到一张新建dwg中,其他图形都是好的,就是标注没有复制过去

Sub main()
    Dim doc1 As AcadDocument, doc2 As Object
    Dim ssetObj As AcadSelectionSet
    Dim objCollection() As Object
    Set doc1 = Application.ActiveDocument
   
    Set ssetObj = doc1.ActiveSelectionSet
    ssetObj.Select acSelectionSetAll

    If ssetObj.Count > 0 Then
         ReDim objCollection(ssetObj.Count - 1) As Object
         For k = 0 To ssetObj.Count - 1
             Set objCollection(k) = ssetObj(k)
         Next k
        
         Set doc2 = Documents.Add
         doc1.CopyObjects objCollection, doc2.ModelSpace
     End If


End Sub

发表于 2009-3-10 16:11:00 | 显示全部楼层

标注也复制过去了,只不过没显示出来

    Dim doc1 As AcadDocument, doc2 As AcadDocument
    Dim ssetObj As AcadSelectionSet
    Dim objCollection() As Object
    Dim k As Integer
    Set doc1 = Application.ActiveDocument
   
    Set ssetObj = doc1.ActiveSelectionSet
    ssetObj.Select acSelectionSetAll

    If ssetObj.Count > 0 Then
         ReDim objCollection(ssetObj.Count - 1) As Object
         For k = 0 To ssetObj.Count - 1
             Set objCollection(k) = ssetObj.Item(k)
            
         Next k
        
         Set doc2 = Documents.Add
         doc1.CopyObjects objCollection, doc2.ModelSpace
     End If
    For k = 0 To ssetObj.Count - 1
        doc2.ModelSpace.Item(k).Visible = True
    Next k

发表于 2024-12-16 15:24:39 | 显示全部楼层
都是好人啊。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-12-27 10:48 , Processed in 0.146918 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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