明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2014|回复: 1

[已解决]如何给两个同名的块重命名?

[复制链接]
发表于 2010-8-5 11:44:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2010-8-5 13:02:26 编辑

我将一个块复制黏贴成另外一个块后,如何在VBA里给两个块重命名啊? 以下代码执行后,两个块还是变成一样的名字

 

  Dim sset As AcadSelectionSet
    Set sset = ThisDrawing.SelectionSets.Add("Selection")
    ' Define the filter list, only Circle objects
    ' will be selectable
    Dim FilterType(0) As Integer
    Dim FilterData(0) As Variant
    FilterType(0) = 0
    FilterData(0) = "Block"
 
    ' Prompt the user to select objects
    ' and add them to the selection set
    sset.Select acSelectionSetAll, FilterType, FilterData
 
    MsgBox "Number of objects selected: " & sset.Count

    For Count = 0 To sset.Count - 1
        Set BlockObj = ThisDrawing.Blocks(sset.Item(Count).EffectiveName) '感觉是这里有问题,但是不知道怎么分别查找这两个同名块
        BlockObj.name = sset.Item(Count).ObjectID

    Next Count 
    sset.Delete

 楼主| 发表于 2010-8-5 13:04:00 | 显示全部楼层

参考代码 http://bbs.mjtd.com/forum.php?mod=viewthread&tid=79706

    Dim objBlkRef As AcadBlockReference
    Dim blockNow As AcadBlock
    Dim objb As AcadBlockReference
    Dim BlockY As AcadBlock
    Dim BlockYorg As ACAD_POINT


                    Set objBlkRef = elem
                    Set BlockY = ThisDrawing.Blocks.Item(objBlkRef.EffectiveName)
                    BlockYorg = BlockY.Origin
                    
                    Set blockNow = ThisDrawing.Blocks.Add(BlockYorg, objBlkRef.ObjectID)
                    Set objb = blockNow.InsertBlock(BlockYorg, objBlkRef.name, 1, 1, 1, 0)
                    objb.Explode
                    objb.Delete
                    objBlkRef.name = blockNow.name

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

本版积分规则

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

GMT+8, 2024-11-25 22:42 , Processed in 0.176093 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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