[已解决]如何给两个同名的块重命名?
本帖最后由 作者 于 2010-8-5 13:02:26 编辑 <br /><br /> <p><font face="Verdana">我将一个块复制黏贴成另外一个块后,如何在VBA里给两个块重命名啊? 以下代码执行后,两个块还是变成一样的名字</font></p><p><font face="Verdana"></font> </p>
<p><font face="Verdana"> Dim sset As AcadSelectionSet<br/> Set sset = ThisDrawing.SelectionSets.Add("Selection")<br/> ' Define the filter list, only Circle objects<br/> ' will be selectable<br/> Dim FilterType(0) As Integer<br/> Dim FilterData(0) As Variant<br/> FilterType(0) = 0<br/> FilterData(0) = "Block"<br/> <br/> ' Prompt the user to select objects<br/> ' and add them to the selection set<br/> sset.Select acSelectionSetAll, FilterType, FilterData<br/> <br/> MsgBox "Number of objects selected: " & sset.Count</font></p>
<p><font face="Verdana"> For Count = 0 To sset.Count - 1<br/> Set BlockObj = ThisDrawing.Blocks(sset.Item(Count).EffectiveName) '感觉是这里有问题,但是不知道怎么分别查找这两个同名块<br/> BlockObj.name = sset.Item(Count).ObjectID</font></p>
<p><font face="Verdana"> Next Count <br/> sset.Delete</font></p> <p>参考代码 <font face="Verdana"><a href="http://bbs.mjtd.com/forum.php?mod=viewthread&tid=79706">http://bbs.mjtd.com/forum.php?mod=viewthread&tid=79706</a></font></p>
<p> Dim objBlkRef As AcadBlockReference<br/> Dim blockNow As AcadBlock<br/> Dim objb As AcadBlockReference<br/> Dim BlockY As AcadBlock<br/> Dim BlockYorg As ACAD_POINT<br/><br/><br/> Set objBlkRef = elem<br/> Set BlockY = ThisDrawing.Blocks.Item(objBlkRef.EffectiveName)<br/> BlockYorg = BlockY.Origin<br/> <br/> Set blockNow = ThisDrawing.Blocks.Add(BlockYorg, objBlkRef.ObjectID)<br/> Set objb = blockNow.InsertBlock(BlockYorg, objBlkRef.name, 1, 1, 1, 0)<br/> objb.Explode<br/> objb.Delete<br/> objBlkRef.name = blockNow.name</p>
页:
[1]